diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/CallableMethod.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/CallableMethod.kt index 732849c9393..01329466178 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/CallableMethod.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/CallableMethod.kt @@ -21,7 +21,7 @@ import org.jetbrains.org.objectweb.asm.util.Printer class CallableMethod( override val owner: Type, private val defaultImplOwner: Type?, - private val defaultMethodDesc: String, + computeDefaultMethodDesc: () -> String, private val signature: JvmMethodSignature, private val invokeOpcode: Int, override val dispatchReceiverType: Type?, @@ -33,6 +33,8 @@ class CallableMethod( private val isInterfaceMethod: Boolean = Opcodes.INVOKEINTERFACE == invokeOpcode, private val isDefaultMethodInInterface: Boolean = false ) : Callable { + private val defaultMethodDesc: String by lazy(LazyThreadSafetyMode.PUBLICATION, computeDefaultMethodDesc) + fun getValueParameters(): List = signature.valueParameters @@ -45,7 +47,6 @@ class CallableMethod( override val parameterTypes: Array get() = getAsmMethod().argumentTypes - override fun genInvokeInstruction(v: InstructionAdapter) { v.visitMethodInsn( invokeOpcode, diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java index 89f5bb2871f..666100be7b9 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java @@ -797,10 +797,9 @@ public class KotlinTypeMapper { JvmMethodSignature method = mapSignatureSkipGeneric(descriptor.getOriginal()); Type owner = mapOwner(descriptor); FunctionDescriptor originalDescriptor = descriptor.getOriginal(); - String defaultImplDesc = mapDefaultMethod(originalDescriptor, OwnerKind.IMPLEMENTATION).getDescriptor(); return new CallableMethod( - owner, owner, defaultImplDesc, method, INVOKESPECIAL, - null, null, null, null, null, originalDescriptor.getReturnType(), false, false + owner, owner, () -> mapDefaultMethod(originalDescriptor, OwnerKind.IMPLEMENTATION).getDescriptor(), method, + INVOKESPECIAL, null, null, null, null, null, originalDescriptor.getReturnType(), false, false ); } @@ -956,11 +955,11 @@ public class KotlinTypeMapper { receiverParameterType = null; } - String defaultImplDesc = mapDefaultMethod(baseMethodDescriptor, getKindForDefaultImplCall(baseMethodDescriptor)).getDescriptor(); - return new CallableMethod( - owner, ownerForDefaultImpl, defaultImplDesc, signature, invokeOpcode, - thisClass, dispatchReceiverKotlinType, receiverParameterType, extensionReceiverKotlinType, calleeType, returnKotlinType, + owner, ownerForDefaultImpl, + () -> mapDefaultMethod(baseMethodDescriptor, getKindForDefaultImplCall(baseMethodDescriptor)).getDescriptor(), + signature, invokeOpcode, thisClass, dispatchReceiverKotlinType, receiverParameterType, extensionReceiverKotlinType, + calleeType, returnKotlinType, jvmTarget.compareTo(JvmTarget.JVM_1_8) >= 0 ? isInterfaceMember : invokeOpcode == INVOKEINTERFACE, isDefaultMethodInInterface );