JVM IR: Fix value class mangling in SAM wrappers from different modules
KT-49659
This commit is contained in:
committed by
Alexander Udalov
parent
771b79d045
commit
a6dae0b37b
@@ -353,6 +353,7 @@ private val jvmFilePhases = listOf(
|
||||
rangeContainsLoweringPhase,
|
||||
forLoopsPhase,
|
||||
collectionStubMethodLowering,
|
||||
singleAbstractMethodPhase,
|
||||
jvmInlineClassPhase,
|
||||
tailrecPhase,
|
||||
makePatchParentsPhase(1),
|
||||
@@ -360,7 +361,6 @@ private val jvmFilePhases = listOf(
|
||||
enumWhenPhase,
|
||||
singletonReferencesPhase,
|
||||
|
||||
singleAbstractMethodPhase,
|
||||
assertionPhase,
|
||||
returnableBlocksPhase,
|
||||
sharedVariablesPhase,
|
||||
|
||||
+2
-1
@@ -47,7 +47,8 @@ val jvmInlineClassPhase = makeIrFilePhase(
|
||||
// forLoopsPhase may produce UInt and ULong which are inline classes.
|
||||
// Standard library replacements are done on the unmangled names for UInt and ULong classes.
|
||||
// Collection stubs may require mangling by inline class rules.
|
||||
prerequisite = setOf(forLoopsPhase, jvmBuiltInsPhase, collectionStubMethodLowering)
|
||||
// SAM wrappers may require mangling for fun interfaces with inline class parameters
|
||||
prerequisite = setOf(forLoopsPhase, jvmBuiltInsPhase, collectionStubMethodLowering, singleAbstractMethodPhase),
|
||||
)
|
||||
|
||||
/**
|
||||
|
||||
+3
-2
@@ -19,7 +19,6 @@ import org.jetbrains.kotlin.ir.builders.declarations.IrFunctionBuilder
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||
import org.jetbrains.kotlin.ir.expressions.IrTypeOperatorCall
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.types.getClass
|
||||
@@ -29,7 +28,9 @@ import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
internal val singleAbstractMethodPhase = makeIrFilePhase(
|
||||
::JvmSingleAbstractMethodLowering,
|
||||
name = "SingleAbstractMethod",
|
||||
description = "Replace SAM conversions with instances of interface-implementing classes"
|
||||
description = "Replace SAM conversions with instances of interface-implementing classes",
|
||||
// FunctionReferenceLowering produces optimized SAM wrappers.
|
||||
prerequisite = setOf(functionReferencePhase),
|
||||
)
|
||||
|
||||
private class JvmSingleAbstractMethodLowering(context: JvmBackendContext) : SingleAbstractMethodLowering(context) {
|
||||
|
||||
+2
-2
@@ -54,11 +54,11 @@ class MemoizedInlineClassReplacements(
|
||||
val getReplacementFunction: (IrFunction) -> IrSimpleFunction? =
|
||||
storageManager.createMemoizedFunctionWithNullableValues {
|
||||
when {
|
||||
// Don't mangle anonymous or synthetic functions
|
||||
// Don't mangle anonymous or synthetic functions, except for generated SAM wrapper methods
|
||||
(it.isLocal && it is IrSimpleFunction && it.overriddenSymbols.isEmpty()) ||
|
||||
(it.origin == IrDeclarationOrigin.DELEGATED_PROPERTY_ACCESSOR && it.visibility == DescriptorVisibilities.LOCAL) ||
|
||||
it.isStaticInlineClassReplacement ||
|
||||
it.origin.isSynthetic ->
|
||||
it.origin.isSynthetic && it.origin != IrDeclarationOrigin.SYNTHETIC_GENERATED_SAM_IMPLEMENTATION ->
|
||||
null
|
||||
|
||||
it.isInlineClassFieldGetter ->
|
||||
|
||||
Reference in New Issue
Block a user