diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InheritedDefaultMethodsOnClassesLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InheritedDefaultMethodsOnClassesLowering.kt index cae41c764fb..6629fa2f492 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InheritedDefaultMethodsOnClassesLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InheritedDefaultMethodsOnClassesLowering.kt @@ -32,6 +32,8 @@ import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction import org.jetbrains.kotlin.ir.expressions.IrCall import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrTypeOperator +import org.jetbrains.kotlin.ir.expressions.impl.IrTypeOperatorCallImpl import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid @@ -198,7 +200,19 @@ private class InterfaceObjectCallsLowering(val context: JvmBackendContext) : IrE if (resolved?.isMethodOfAny() != true) return super.visitCall(expression) val newSuperQualifierSymbol = context.irBuiltIns.anyClass.takeIf { expression.superQualifierSymbol != null } - return super.visitCall(irCall(expression, resolved, newSuperQualifierSymbol = newSuperQualifierSymbol)) + return super.visitCall(irCall(expression, resolved, newSuperQualifierSymbol = newSuperQualifierSymbol).apply { + dispatchReceiver?.let { receiver -> + val receiverType = resolved.parentAsClass.defaultType + dispatchReceiver = IrTypeOperatorCallImpl( + receiver.startOffset, + receiver.endOffset, + receiverType, + IrTypeOperator.IMPLICIT_CAST, + receiverType, + receiver + ) + } + }) } } @@ -229,4 +243,4 @@ internal fun IrSimpleFunction.findInterfaceImplementation(): IrSimpleFunction? { } return implementation -} \ No newline at end of file +}