[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
|
import org.jetbrains.kotlin.utils.SmartList
|
||||||
|
|
||||||
class PlatformIntegerCommonizer(
|
class PlatformIntegerCommonizer(
|
||||||
typeArgumentListCommonizer: TypeArgumentListCommonizer,
|
private val typeCommonizer: TypeCommonizer,
|
||||||
classifiers: CirKnownClassifiers,
|
private val classifiers: CirKnownClassifiers,
|
||||||
) : NullableSingleInvocationCommonizer<CirClassOrTypeAliasType> {
|
) : NullableSingleInvocationCommonizer<CirClassOrTypeAliasType> {
|
||||||
constructor(typeCommonizer: TypeCommonizer, classifiers: CirKnownClassifiers)
|
|
||||||
: this(TypeArgumentListCommonizer(typeCommonizer), classifiers)
|
|
||||||
|
|
||||||
override fun invoke(values: List<CirClassOrTypeAliasType>): CirClassOrTypeAliasType? {
|
override fun invoke(values: List<CirClassOrTypeAliasType>): CirClassOrTypeAliasType? {
|
||||||
return platformDependentTypeCommonizers.firstNotNullOfOrNull { commonizer ->
|
return platformDependentTypeCommonizers.firstNotNullOfOrNull { commonizer ->
|
||||||
@@ -30,18 +28,19 @@ class PlatformIntegerCommonizer(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val platformDependentTypeCommonizers = listOf(
|
private val platformDependentTypeCommonizers: List<PlatformDependentTypeCommonizer>
|
||||||
PlatformIntCommonizer(classifiers),
|
get() = listOf(
|
||||||
PlatformUIntCommonizer(classifiers),
|
PlatformIntCommonizer(classifiers),
|
||||||
PlatformIntArrayCommonizer(classifiers),
|
PlatformUIntCommonizer(classifiers),
|
||||||
PlatformUIntArrayCommonizer(classifiers),
|
PlatformIntArrayCommonizer(classifiers),
|
||||||
PlatformIntRangeCommonizer(classifiers),
|
PlatformUIntArrayCommonizer(classifiers),
|
||||||
PlatformUIntRangeCommonizer(classifiers),
|
PlatformIntRangeCommonizer(classifiers),
|
||||||
PlatformIntProgressionCommonizer(classifiers),
|
PlatformUIntRangeCommonizer(classifiers),
|
||||||
PlatformUIntProgressionCommonizer(classifiers),
|
PlatformIntProgressionCommonizer(classifiers),
|
||||||
PlatformIntVarOfCommonizer(classifiers, typeArgumentListCommonizer),
|
PlatformUIntProgressionCommonizer(classifiers),
|
||||||
PlatformUIntVarOfCommonizer(classifiers, typeArgumentListCommonizer),
|
PlatformIntVarOfCommonizer(classifiers, TypeArgumentListCommonizer(typeCommonizer)),
|
||||||
)
|
PlatformUIntVarOfCommonizer(classifiers, TypeArgumentListCommonizer(typeCommonizer)),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private sealed class PlatformDependentTypeCommonizer(
|
private sealed class PlatformDependentTypeCommonizer(
|
||||||
|
|||||||
+47
@@ -671,4 +671,51 @@ class HierarchicalPlatformIntegerCommonizationTest : AbstractInlineSourcesCommon
|
|||||||
"(unknown, ${IOS_ARM32.name})", "".trimIndent()
|
"(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