diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt index 1923fa8d8c9..8bd18bef580 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt @@ -367,8 +367,9 @@ class ExpressionCodegen( classCodegen.context.irIntrinsics.getIntrinsic(expression.symbol) ?.invoke(expression, this, data)?.let { return it } - val callable = methodSignatureMapper.mapToCallableMethod(irFunction, expression) val callee = expression.symbol.owner + require(callee.parent is IrClass) { "Unhandled intrinsic in ExpressionCodegen: ${callee.render()}" } + val callable = methodSignatureMapper.mapToCallableMethod(irFunction, expression) val callGenerator = getOrCreateCallGenerator(expression, data, callable.signature) val asmType = if (expression is IrConstructorCall) typeMapper.mapTypeAsDeclaration(expression.type) else expression.asmType @@ -1022,7 +1023,7 @@ class ExpressionCodegen( } } - val methodOwner = callee.parent.safeAs()?.let(typeMapper::mapClass) ?: MethodSignatureMapper.FAKE_OWNER_TYPE + val methodOwner = typeMapper.mapClass(callee.parentAsClass) val sourceCompiler = IrSourceCompilerForInline(state, element, callee, this, data) val reifiedTypeInliner = ReifiedTypeInliner(mappings, object : ReifiedTypeInliner.IntrinsicsSupport { diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt index a8d083e34a3..27bc878ef3f 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt @@ -285,15 +285,7 @@ class MethodSignatureMapper(private val context: JvmBackendContext) { fun mapToCallableMethod(caller: IrFunction, expression: IrFunctionAccessExpression): IrCallableMethod { val callee = expression.symbol.owner.getOrCreateSuspendFunctionViewIfNeeded(context) - val calleeParent = callee.parent - if (calleeParent !is IrClass) { - // Non-class parent is only possible for intrinsics created in IrBuiltIns, such as dataClassArrayMemberHashCode. In that case, - // we still need to return some IrCallableMethod with some owner instance, but that owner will be ignored at the call site. - // Here we return a fake type, but this needs to be refactored so that we never call mapToCallableMethod on intrinsics. - // TODO: get rid of fake owner here - return IrCallableMethod(FAKE_OWNER_TYPE, Opcodes.INVOKESTATIC, mapSignatureSkipGeneric(callee), false) - } - + val calleeParent = callee.parentAsClass val owner = typeMapper.mapClass(calleeParent) if (callee !is IrSimpleFunction) { @@ -351,8 +343,4 @@ class MethodSignatureMapper(private val context: JvmBackendContext) { } return current } - - companion object { - val FAKE_OWNER_TYPE = Type.getObjectType("kotlin/internal/ir/Intrinsic") - } }