JVM: Take inline class mangling state into account for default methods

This commit is contained in:
Steven Schäfer
2021-01-22 16:57:55 +01:00
committed by Ilmir Usmanov
parent f85263ca7f
commit 3e820ff3b1
21 changed files with 493 additions and 2 deletions
@@ -375,13 +375,27 @@ class KotlinTypeMapper @JvmOverloads constructor(
kind: OwnerKind? = null,
resolvedCall: ResolvedCall<*>? = null
): CallableMethod {
fun mapDefaultCallback(descriptor: FunctionDescriptor, kind: OwnerKind): () -> Method {
if (useOldManglingRulesForFunctionAcceptingInlineClass && !useOldInlineClassesManglingScheme) {
return {
val prevManglingState = useOldManglingRulesForFunctionAcceptingInlineClass
useOldManglingRulesForFunctionAcceptingInlineClass = true
mapDefaultMethod(descriptor, kind).also {
useOldManglingRulesForFunctionAcceptingInlineClass = prevManglingState
}
}
} else {
return { mapDefaultMethod(descriptor, kind) }
}
}
// we generate constructors of inline classes as usual functions
if (descriptor is ConstructorDescriptor && kind != OwnerKind.ERASED_INLINE_CLASS) {
val method = mapSignatureSkipGeneric(descriptor.original)
val owner = mapOwner(descriptor)
val originalDescriptor = descriptor.original
return CallableMethod(
owner, owner, { mapDefaultMethod(originalDescriptor, OwnerKind.IMPLEMENTATION) }, method, INVOKESPECIAL,
owner, owner, mapDefaultCallback(originalDescriptor, OwnerKind.IMPLEMENTATION), method, INVOKESPECIAL,
null, null, null, null, null, originalDescriptor.returnType, isInterfaceMethod = false, isDefaultMethodInInterface = false,
boxInlineClassBeforeInvoke = false
)
@@ -557,7 +571,7 @@ class KotlinTypeMapper @JvmOverloads constructor(
return CallableMethod(
owner, ownerForDefaultImpl,
{ mapDefaultMethod(baseMethodDescriptor, getKindForDefaultImplCall(baseMethodDescriptor)) },
mapDefaultCallback(baseMethodDescriptor, getKindForDefaultImplCall(baseMethodDescriptor)),
signature, invokeOpcode, thisClass, dispatchReceiverKotlinType, receiverParameterType, extensionReceiverKotlinType,
calleeType, returnKotlinType,
if (jvmTarget >= JvmTarget.JVM_1_8) isInterfaceMember else invokeOpcode == INVOKEINTERFACE,