From d15270b9e5264df50c69cf17390cf64fddfd3a7a Mon Sep 17 00:00:00 2001 From: Elena Lepilkina Date: Fri, 14 Jan 2022 14:29:00 +0300 Subject: [PATCH] [K/N][BCE] Check indexedObject type to avoid classes without optimized get operators --- .../loops/handlers/IndexedGetIterationHandlers.kt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) 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 c5ce749257c..29f0e895dfa 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 @@ internal class ArrayIterationHandler(context: CommonBackendContext) : IndexedGet 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 @@ internal class ArrayIterationHandler(context: CommonBackendContext) : IndexedGet 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 {