[MPP] Fix incorrect reuse of type argument commonizer
If the same NullableSingleInvocationCommonizer is reused for any reason, it will store next inputs alongside previous, which is totally not expected ^KT-51528 Fixed
This commit is contained in:
committed by
teamcity
parent
42a2ce1610
commit
9162faaf39
+15
-16
@@ -18,11 +18,9 @@ import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
|
||||
class PlatformIntegerCommonizer(
|
||||
typeArgumentListCommonizer: TypeArgumentListCommonizer,
|
||||
classifiers: CirKnownClassifiers,
|
||||
private val typeCommonizer: TypeCommonizer,
|
||||
private val classifiers: CirKnownClassifiers,
|
||||
) : NullableSingleInvocationCommonizer<CirClassOrTypeAliasType> {
|
||||
constructor(typeCommonizer: TypeCommonizer, classifiers: CirKnownClassifiers)
|
||||
: this(TypeArgumentListCommonizer(typeCommonizer), classifiers)
|
||||
|
||||
override fun invoke(values: List<CirClassOrTypeAliasType>): CirClassOrTypeAliasType? {
|
||||
return platformDependentTypeCommonizers.firstNotNullOfOrNull { commonizer ->
|
||||
@@ -30,18 +28,19 @@ class PlatformIntegerCommonizer(
|
||||
}
|
||||
}
|
||||
|
||||
private val platformDependentTypeCommonizers = listOf(
|
||||
PlatformIntCommonizer(classifiers),
|
||||
PlatformUIntCommonizer(classifiers),
|
||||
PlatformIntArrayCommonizer(classifiers),
|
||||
PlatformUIntArrayCommonizer(classifiers),
|
||||
PlatformIntRangeCommonizer(classifiers),
|
||||
PlatformUIntRangeCommonizer(classifiers),
|
||||
PlatformIntProgressionCommonizer(classifiers),
|
||||
PlatformUIntProgressionCommonizer(classifiers),
|
||||
PlatformIntVarOfCommonizer(classifiers, typeArgumentListCommonizer),
|
||||
PlatformUIntVarOfCommonizer(classifiers, typeArgumentListCommonizer),
|
||||
)
|
||||
private val platformDependentTypeCommonizers: List<PlatformDependentTypeCommonizer>
|
||||
get() = listOf(
|
||||
PlatformIntCommonizer(classifiers),
|
||||
PlatformUIntCommonizer(classifiers),
|
||||
PlatformIntArrayCommonizer(classifiers),
|
||||
PlatformUIntArrayCommonizer(classifiers),
|
||||
PlatformIntRangeCommonizer(classifiers),
|
||||
PlatformUIntRangeCommonizer(classifiers),
|
||||
PlatformIntProgressionCommonizer(classifiers),
|
||||
PlatformUIntProgressionCommonizer(classifiers),
|
||||
PlatformIntVarOfCommonizer(classifiers, TypeArgumentListCommonizer(typeCommonizer)),
|
||||
PlatformUIntVarOfCommonizer(classifiers, TypeArgumentListCommonizer(typeCommonizer)),
|
||||
)
|
||||
}
|
||||
|
||||
private sealed class PlatformDependentTypeCommonizer(
|
||||
|
||||
+47
@@ -671,4 +671,51 @@ class HierarchicalPlatformIntegerCommonizationTest : AbstractInlineSourcesCommon
|
||||
"(unknown, ${IOS_ARM32.name})", "".trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
// Issue: KT-51528
|
||||
fun `test multiple argument function with over the edge type alias available`() {
|
||||
val result = commonize {
|
||||
outputTarget("(${IOS_ARM32.name}, ${IOS_ARM64.name})")
|
||||
setting(PlatformIntegerCommonizationEnabledKey, true)
|
||||
registerFakeStdlibIntegersDependency("(${IOS_ARM32.name}, ${IOS_ARM64.name})")
|
||||
|
||||
IOS_ARM32.name withSource """
|
||||
typealias Arm32Alias = UInt
|
||||
typealias OtherAlias = UInt
|
||||
|
||||
class Box<T>
|
||||
|
||||
fun fn(
|
||||
arg1: Box<kotlinx.cinterop.UIntVarOf<Arm32Alias>>,
|
||||
arg2: Box<kotlinx.cinterop.UIntVarOf<Arm32Alias>>
|
||||
) {}
|
||||
""".trimIndent()
|
||||
|
||||
IOS_ARM64.name withSource """
|
||||
typealias Arm64Alias = ULong
|
||||
typealias OtherAlias = ULong
|
||||
|
||||
class Box<T>
|
||||
|
||||
fun fn(
|
||||
arg1: Box<kotlinx.cinterop.ULongVarOf<Arm64Alias>>,
|
||||
arg2: Box<kotlinx.cinterop.ULongVarOf<Arm64Alias>>
|
||||
) {}
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
result.assertCommonized(
|
||||
"(${IOS_ARM32.name}, ${IOS_ARM64.name})", """
|
||||
@UnsafeNumber(["${IOS_ARM32.name}: kotlin.UInt", "${IOS_ARM64.name}: kotlin.ULong"])
|
||||
typealias OtherAlias = PlatformUInt
|
||||
|
||||
expect class Box<T>()
|
||||
|
||||
expect fun fn(
|
||||
arg1: Box<kotlinx.cinterop.PlatformUIntVarOf<OtherAlias>>,
|
||||
arg2: Box<kotlinx.cinterop.PlatformUIntVarOf<OtherAlias>>
|
||||
)
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user