[K/N][BCE] Check indexedObject type to avoid classes without optimized get operators
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/loops/handlers/IndexedGetIterationHandlers.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/loops/handlers/IndexedGetIterationHandlers.kt
index c5ce749..29f0e89 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/loops/handlers/IndexedGetIterationHandlers.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/loops/handlers/IndexedGetIterationHandlers.kt
@@ -78,7 +78,7 @@
private val supportsUnsignedArrays = context.optimizeLoopsOverUnsignedArrays
override fun matchIterable(expression: IrExpression) =
- expression.type.run { isArray() || isPrimitiveArray() || (supportsUnsignedArrays && isUnsignedArray()) } ||
+ expression.type.run { isArrayType() } ||
expression.run {
this is IrCall && reversedArrayMatcher(this)
}
@@ -97,8 +97,17 @@
override val IrType.sizePropertyGetter
get() = getClass()!!.getPropertyGetter("size")!!.owner
- private val getFunctionName: Name
- get() = context.ir.symbols.getWithoutBoundCheckName ?: OperatorNameConventions.GET
+ private fun IrType.isArrayType() =
+ isArray() || isPrimitiveArray() || (supportsUnsignedArrays && isUnsignedArray())
+
+ private val IrType.getFunctionName: Name
+ get() = context.ir.symbols.getWithoutBoundCheckName.let {
+ if (isArrayType() && it != null) {
+ it
+ } else {
+ OperatorNameConventions.GET
+ }
+ }
override val IrType.getFunction
get() = getClass()!!.functions.single {