[MPP] Commonize to platform integers considering target's bit width
Commonized type should match the platform's `platform.posix.ssize_t` type alias' width. The implementation hard-codes platform widths for all the targets, this can be potentially changed to search for ssize_t in dependencies and get width from its type. Use real targets in platform int commonization tests. KT-41509
This commit is contained in:
committed by
teamcity
parent
8f4d04dad2
commit
f257297505
+10
-5
@@ -30,7 +30,7 @@ internal class ClassOrTypeAliasTypeCommonizer(
|
|||||||
)
|
)
|
||||||
|
|
||||||
private val isMarkedNullableCommonizer = TypeNullabilityCommonizer(typeCommonizer.context)
|
private val isMarkedNullableCommonizer = TypeNullabilityCommonizer(typeCommonizer.context)
|
||||||
private val platformIntegerCommonizer = PlatformIntegerCommonizer(typeCommonizer)
|
private val platformIntegerCommonizer = PlatformIntegerCommonizer(typeCommonizer, classifiers)
|
||||||
private val typeDistanceMeasurement = TypeDistanceMeasurement(typeCommonizer.context)
|
private val typeDistanceMeasurement = TypeDistanceMeasurement(typeCommonizer.context)
|
||||||
|
|
||||||
override fun invoke(values: List<CirClassOrTypeAliasType>): CirClassOrTypeAliasType? {
|
override fun invoke(values: List<CirClassOrTypeAliasType>): CirClassOrTypeAliasType? {
|
||||||
@@ -39,11 +39,16 @@ internal class ClassOrTypeAliasTypeCommonizer(
|
|||||||
val isMarkedNullable = isMarkedNullableCommonizer.commonize(expansions.map { it.isMarkedNullable }) ?: return null
|
val isMarkedNullable = isMarkedNullableCommonizer.commonize(expansions.map { it.isMarkedNullable }) ?: return null
|
||||||
|
|
||||||
val substitutedTypes = substituteTypesIfNecessary(values)
|
val substitutedTypes = substituteTypesIfNecessary(values)
|
||||||
?: isPlatformIntegerCommonizationEnabled.ifTrue {
|
|
||||||
return platformIntegerCommonizer.commonize(expansions)?.makeNullableIfNecessary(isMarkedNullable)
|
if (substitutedTypes == null) {
|
||||||
|
val integerCommonizationResultIfApplicable = isPlatformIntegerCommonizationEnabled.ifTrue {
|
||||||
|
platformIntegerCommonizer(expansions)?.makeNullableIfNecessary(isMarkedNullable)
|
||||||
} ?: isOptimisticNumberTypeCommonizationEnabled.ifTrue {
|
} ?: isOptimisticNumberTypeCommonizationEnabled.ifTrue {
|
||||||
return OptimisticNumbersTypeCommonizer.commonize(expansions)?.makeNullableIfNecessary(isMarkedNullable)
|
OptimisticNumbersTypeCommonizer.commonize(expansions)?.makeNullableIfNecessary(isMarkedNullable)
|
||||||
} ?: return null
|
}
|
||||||
|
|
||||||
|
return integerCommonizationResultIfApplicable
|
||||||
|
}
|
||||||
|
|
||||||
val classifierId = substitutedTypes.singleDistinctValueOrNull { it.classifierId } ?: return null
|
val classifierId = substitutedTypes.singleDistinctValueOrNull { it.classifierId } ?: return null
|
||||||
|
|
||||||
|
|||||||
+176
-76
@@ -5,113 +5,213 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.commonizer.core
|
package org.jetbrains.kotlin.commonizer.core
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.commonizer.CommonizerTarget
|
||||||
import org.jetbrains.kotlin.commonizer.cir.*
|
import org.jetbrains.kotlin.commonizer.cir.*
|
||||||
|
import org.jetbrains.kotlin.commonizer.mergedtree.CirKnownClassifiers
|
||||||
|
import org.jetbrains.kotlin.commonizer.mergedtree.PlatformIntWidth
|
||||||
|
import org.jetbrains.kotlin.commonizer.mergedtree.PlatformWidthIndex
|
||||||
import org.jetbrains.kotlin.descriptors.konan.*
|
import org.jetbrains.kotlin.descriptors.konan.*
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
import org.jetbrains.kotlin.utils.SmartList
|
import org.jetbrains.kotlin.utils.SmartList
|
||||||
|
|
||||||
class PlatformIntegerCommonizer(
|
class PlatformIntegerCommonizer(
|
||||||
private val typeArgumentListCommonizer: TypeArgumentListCommonizer
|
typeArgumentListCommonizer: TypeArgumentListCommonizer,
|
||||||
) : AssociativeCommonizer<CirClassOrTypeAliasType> {
|
classifiers: CirKnownClassifiers,
|
||||||
constructor(typeCommonizer: TypeCommonizer) : this(TypeArgumentListCommonizer(typeCommonizer))
|
) : NullableSingleInvocationCommonizer<CirClassOrTypeAliasType> {
|
||||||
|
constructor(typeCommonizer: TypeCommonizer, classifiers: CirKnownClassifiers)
|
||||||
|
: this(TypeArgumentListCommonizer(typeCommonizer), classifiers)
|
||||||
|
|
||||||
override fun commonize(first: CirClassOrTypeAliasType, second: CirClassOrTypeAliasType): CirClassOrTypeAliasType? {
|
override fun invoke(values: List<CirClassOrTypeAliasType>): CirClassOrTypeAliasType? {
|
||||||
return when {
|
return platformDependentTypeCommonizers.firstNotNullOfOrNull { commonizer ->
|
||||||
both(first, second) { it.classifierId in commonizableSignedIntegerIds } -> platformIntType
|
commonizer.invoke(values)
|
||||||
both(first, second) { it.classifierId in commonizableUnsignedIntegerIds } -> platformUIntType
|
|
||||||
both(first, second) { it.classifierId in commonizableSignedVarIds } -> commonizeVarOf(first, second, isSigned = true)
|
|
||||||
both(first, second) { it.classifierId in commonizableUnsignedVarIds } -> commonizeVarOf(first, second, isSigned = false)
|
|
||||||
both(first, second) { it.classifierId in commonizableSignedArrayIds } -> platformIntArrayType
|
|
||||||
both(first, second) { it.classifierId in commonizableUnsignedArrayIds } -> platformUIntArrayType
|
|
||||||
both(first, second) { it.classifierId in commonizableSignedRangeIds } -> platformIntRangeType
|
|
||||||
both(first, second) { it.classifierId in commonizableUnsignedRangeIds } -> platformUIntRangeType
|
|
||||||
both(first, second) { it.classifierId in commonizableSignedProgressionIds } -> platformIntProgressionType
|
|
||||||
both(first, second) { it.classifierId in commonizableUnsignedProgressionIds } -> platformUIntProgressionType
|
|
||||||
else -> null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private inline fun <T> both(first: T, second: T, predicate: (T) -> Boolean) =
|
|
||||||
predicate(first) && predicate(second)
|
|
||||||
|
|
||||||
private fun commonizeVarOf(
|
private val platformDependentTypeCommonizers = listOf(
|
||||||
first: CirClassOrTypeAliasType,
|
PlatformIntCommonizer(classifiers),
|
||||||
second: CirClassOrTypeAliasType,
|
PlatformUIntCommonizer(classifiers),
|
||||||
isSigned: Boolean
|
PlatformIntArrayCommonizer(classifiers),
|
||||||
): CirClassOrTypeAliasType? {
|
PlatformUIntArrayCommonizer(classifiers),
|
||||||
if (first !is CirClassType || second !is CirClassType) return null
|
PlatformIntRangeCommonizer(classifiers),
|
||||||
|
PlatformUIntRangeCommonizer(classifiers),
|
||||||
|
PlatformIntProgressionCommonizer(classifiers),
|
||||||
|
PlatformUIntProgressionCommonizer(classifiers),
|
||||||
|
PlatformIntVarOfCommonizer(classifiers, typeArgumentListCommonizer),
|
||||||
|
PlatformUIntVarOfCommonizer(classifiers, typeArgumentListCommonizer),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
val argument = typeArgumentListCommonizer.commonize(listOf(first.arguments, second.arguments))?.singleOrNull()
|
private sealed class PlatformDependentTypeCommonizer(
|
||||||
|
private val classifiers: CirKnownClassifiers,
|
||||||
|
private val intPlatformId: CirEntityId,
|
||||||
|
private val longPlatformId: CirEntityId,
|
||||||
|
private val mixedPlatformId: CirEntityId,
|
||||||
|
) : NullableSingleInvocationCommonizer<CirClassOrTypeAliasType> {
|
||||||
|
|
||||||
|
protected abstract fun doCommonize(values: List<CirClassOrTypeAliasType>): CirClassOrTypeAliasType?
|
||||||
|
|
||||||
|
override fun invoke(values: List<CirClassOrTypeAliasType>): CirClassOrTypeAliasType? {
|
||||||
|
val typesToCommonizeWithTargets = values.zip(classifiers.classifierIndices.targets)
|
||||||
|
if (typesToCommonizeWithTargets.any { (type, target) -> !inputTypeIsKnownAndMatchesPlatformBitWidth(type, target) }) return null
|
||||||
|
|
||||||
|
return doCommonize(values)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun inputTypeIsKnownAndMatchesPlatformBitWidth(type: CirClassOrTypeAliasType, target: CommonizerTarget): Boolean =
|
||||||
|
when (PlatformWidthIndex.platformWidthOf(target)) {
|
||||||
|
PlatformIntWidth.INT -> type.classifierId == intPlatformId
|
||||||
|
PlatformIntWidth.LONG -> type.classifierId == longPlatformId
|
||||||
|
PlatformIntWidth.MIXED -> type.classifierId == mixedPlatformId
|
||||||
|
null -> false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private abstract class PlatformDependentTypeWithoutTypeArgumentCommonizer(
|
||||||
|
classifiers: CirKnownClassifiers,
|
||||||
|
intPlatformId: CirEntityId,
|
||||||
|
longPlatformId: CirEntityId,
|
||||||
|
mixedPlatformId: CirEntityId,
|
||||||
|
private val resultingType: CirClassType,
|
||||||
|
) : PlatformDependentTypeCommonizer(classifiers, intPlatformId, longPlatformId, mixedPlatformId) {
|
||||||
|
|
||||||
|
override fun doCommonize(values: List<CirClassOrTypeAliasType>): CirClassOrTypeAliasType? =
|
||||||
|
resultingType
|
||||||
|
}
|
||||||
|
|
||||||
|
private abstract class PlatformDependentTypeWithSingleArgumentCommonizer(
|
||||||
|
classifiers: CirKnownClassifiers,
|
||||||
|
private val typeArgumentListCommonizer: TypeArgumentListCommonizer,
|
||||||
|
intPlatformId: CirEntityId,
|
||||||
|
longPlatformId: CirEntityId,
|
||||||
|
private val mixedPlatformId: CirEntityId,
|
||||||
|
) : PlatformDependentTypeCommonizer(classifiers, intPlatformId, longPlatformId, mixedPlatformId) {
|
||||||
|
|
||||||
|
override fun doCommonize(values: List<CirClassOrTypeAliasType>): CirClassOrTypeAliasType? {
|
||||||
|
val commonTypeArgument = typeArgumentListCommonizer.commonize(values.map { it.arguments })?.singleOrNull()
|
||||||
?: return null
|
?: return null
|
||||||
|
|
||||||
return createCommonVarOfType(isSigned = isSigned, argument = argument)
|
return createCirTypeWithOneArgument(entityId = mixedPlatformId, argument = commonTypeArgument)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// commonizable groups
|
private class PlatformIntCommonizer(
|
||||||
private val commonizableSignedIntegerIds: Set<CirEntityId> = listOf(
|
classifiers: CirKnownClassifiers,
|
||||||
KOTLIN_INT_ID, KOTLIN_LONG_ID, PLATFORM_INT_ID
|
) : PlatformDependentTypeWithoutTypeArgumentCommonizer(
|
||||||
).toCirEntityIds()
|
classifiers,
|
||||||
|
intPlatformId = KOTLIN_INT_ID.toCirEntityId(),
|
||||||
|
longPlatformId = KOTLIN_LONG_ID.toCirEntityId(),
|
||||||
|
mixedPlatformId = PLATFORM_INT_ID.toCirEntityId(),
|
||||||
|
resultingType = platformIntType,
|
||||||
|
)
|
||||||
|
|
||||||
private val commonizableUnsignedIntegerIds: Set<CirEntityId> = listOf(
|
private class PlatformUIntCommonizer(
|
||||||
KOTLIN_UINT_ID, KOTLIN_ULONG_ID, PLATFORM_UINT_ID
|
classifiers: CirKnownClassifiers,
|
||||||
).toCirEntityIds()
|
) : PlatformDependentTypeWithoutTypeArgumentCommonizer(
|
||||||
|
classifiers,
|
||||||
|
intPlatformId = KOTLIN_UINT_ID.toCirEntityId(),
|
||||||
|
longPlatformId = KOTLIN_ULONG_ID.toCirEntityId(),
|
||||||
|
mixedPlatformId = PLATFORM_UINT_ID.toCirEntityId(),
|
||||||
|
resultingType = platformUIntType,
|
||||||
|
)
|
||||||
|
|
||||||
private val commonizableSignedVarIds: Set<CirEntityId> = listOf(
|
private class PlatformIntArrayCommonizer(
|
||||||
INT_VAR_OF_ID, LONG_VAR_OF_ID, PLATFORM_INT_VAR_OF_ID
|
classifiers: CirKnownClassifiers,
|
||||||
).toCirEntityIds()
|
) : PlatformDependentTypeWithoutTypeArgumentCommonizer(
|
||||||
|
classifiers = classifiers,
|
||||||
|
intPlatformId = INT_ARRAY_ID.toCirEntityId(),
|
||||||
|
longPlatformId = LONG_ARRAY_ID.toCirEntityId(),
|
||||||
|
mixedPlatformId = PLATFORM_INT_ARRAY_ID.toCirEntityId(),
|
||||||
|
resultingType = platformIntArrayType,
|
||||||
|
)
|
||||||
|
|
||||||
private val commonizableUnsignedVarIds: Set<CirEntityId> = listOf(
|
private class PlatformUIntArrayCommonizer(
|
||||||
UINT_VAR_OF_ID, ULONG_VAR_OF_ID, PLATFORM_UINT_VAR_OF_ID
|
classifiers: CirKnownClassifiers,
|
||||||
).toCirEntityIds()
|
) : PlatformDependentTypeWithoutTypeArgumentCommonizer(
|
||||||
|
classifiers,
|
||||||
|
intPlatformId = UINT_ARRAY_ID.toCirEntityId(),
|
||||||
|
longPlatformId = ULONG_ARRAY_ID.toCirEntityId(),
|
||||||
|
mixedPlatformId = PLATFORM_UINT_ARRAY_ID.toCirEntityId(),
|
||||||
|
resultingType = platformUIntArrayType,
|
||||||
|
)
|
||||||
|
|
||||||
private val commonizableSignedArrayIds: Set<CirEntityId> = listOf(
|
private class PlatformIntRangeCommonizer(
|
||||||
INT_ARRAY_ID, LONG_ARRAY_ID, PLATFORM_INT_ARRAY_ID
|
classifiers: CirKnownClassifiers,
|
||||||
).toCirEntityIds()
|
) : PlatformDependentTypeWithoutTypeArgumentCommonizer(
|
||||||
|
classifiers,
|
||||||
|
intPlatformId = INT_RANGE_ID.toCirEntityId(),
|
||||||
|
longPlatformId = LONG_RANGE_ID.toCirEntityId(),
|
||||||
|
mixedPlatformId = PLATFORM_INT_RANGE_ID.toCirEntityId(),
|
||||||
|
resultingType = platformIntRangeType,
|
||||||
|
)
|
||||||
|
|
||||||
private val commonizableUnsignedArrayIds: Set<CirEntityId> = listOf(
|
private class PlatformUIntRangeCommonizer(
|
||||||
UINT_ARRAY_ID, ULONG_ARRAY_ID, PLATFORM_UINT_ARRAY_ID
|
classifiers: CirKnownClassifiers,
|
||||||
).toCirEntityIds()
|
) : PlatformDependentTypeWithoutTypeArgumentCommonizer(
|
||||||
|
classifiers,
|
||||||
|
intPlatformId = UINT_RANGE_ID.toCirEntityId(),
|
||||||
|
longPlatformId = ULONG_RANGE_ID.toCirEntityId(),
|
||||||
|
mixedPlatformId = PLATFORM_UINT_RANGE_ID.toCirEntityId(),
|
||||||
|
resultingType = platformUIntRangeType,
|
||||||
|
)
|
||||||
|
|
||||||
private val commonizableSignedRangeIds: Set<CirEntityId> = listOf(
|
private class PlatformIntProgressionCommonizer(
|
||||||
INT_RANGE_ID, LONG_RANGE_ID, PLATFORM_INT_RANGE_ID
|
classifiers: CirKnownClassifiers,
|
||||||
).toCirEntityIds()
|
) : PlatformDependentTypeWithoutTypeArgumentCommonizer(
|
||||||
|
classifiers,
|
||||||
|
intPlatformId = INT_PROGRESSION_ID.toCirEntityId(),
|
||||||
|
longPlatformId = LONG_PROGRESSION_ID.toCirEntityId(),
|
||||||
|
mixedPlatformId = PLATFORM_INT_PROGRESSION_ID.toCirEntityId(),
|
||||||
|
resultingType = platformIntProgressionType,
|
||||||
|
)
|
||||||
|
|
||||||
private val commonizableUnsignedRangeIds: Set<CirEntityId> = listOf(
|
private class PlatformUIntProgressionCommonizer(
|
||||||
UINT_RANGE_ID, ULONG_RANGE_ID, PLATFORM_UINT_RANGE_ID
|
classifiers: CirKnownClassifiers,
|
||||||
).toCirEntityIds()
|
) : PlatformDependentTypeWithoutTypeArgumentCommonizer(
|
||||||
|
classifiers,
|
||||||
|
intPlatformId = UINT_PROGRESSION_ID.toCirEntityId(),
|
||||||
|
longPlatformId = ULONG_PROGRESSION_ID.toCirEntityId(),
|
||||||
|
mixedPlatformId = PLATFORM_UINT_PROGRESSION_ID.toCirEntityId(),
|
||||||
|
resultingType = platformUIntProgressionType,
|
||||||
|
)
|
||||||
|
|
||||||
private val commonizableSignedProgressionIds: Set<CirEntityId> = listOf(
|
private class PlatformIntVarOfCommonizer(
|
||||||
INT_PROGRESSION_ID, LONG_PROGRESSION_ID, PLATFORM_INT_PROGRESSION_ID
|
classifiers: CirKnownClassifiers,
|
||||||
).toCirEntityIds()
|
typeArgumentListCommonizer: TypeArgumentListCommonizer,
|
||||||
|
) : PlatformDependentTypeWithSingleArgumentCommonizer(
|
||||||
|
classifiers,
|
||||||
|
typeArgumentListCommonizer,
|
||||||
|
intPlatformId = INT_VAR_OF_ID.toCirEntityId(),
|
||||||
|
longPlatformId = LONG_VAR_OF_ID.toCirEntityId(),
|
||||||
|
mixedPlatformId = PLATFORM_INT_VAR_OF_ID.toCirEntityId(),
|
||||||
|
)
|
||||||
|
|
||||||
private val commonizableUnsignedProgressionIds: Set<CirEntityId> = listOf(
|
private class PlatformUIntVarOfCommonizer(
|
||||||
UINT_PROGRESSION, ULONG_PROGRESSION, PLATFORM_UINT_PROGRESSION_ID
|
classifiers: CirKnownClassifiers,
|
||||||
).toCirEntityIds()
|
typeArgumentListCommonizer: TypeArgumentListCommonizer,
|
||||||
|
) : PlatformDependentTypeWithSingleArgumentCommonizer(
|
||||||
|
classifiers,
|
||||||
|
typeArgumentListCommonizer,
|
||||||
|
intPlatformId = UINT_VAR_OF_ID.toCirEntityId(),
|
||||||
|
longPlatformId = ULONG_VAR_OF_ID.toCirEntityId(),
|
||||||
|
mixedPlatformId = PLATFORM_UINT_VAR_OF_ID.toCirEntityId(),
|
||||||
|
)
|
||||||
|
|
||||||
private fun ClassId.toCirEntityId(): CirEntityId =
|
private fun ClassId.toCirEntityId(): CirEntityId =
|
||||||
CirEntityId.create(this)
|
CirEntityId.create(this)
|
||||||
|
|
||||||
private fun Collection<ClassId>.toCirEntityIds(): Set<CirEntityId> =
|
private val platformIntType: CirClassType = createCirTypeWithoutArguments(PLATFORM_INT_ID.toCirEntityId())
|
||||||
map { it.toCirEntityId()}.toSet()
|
private val platformUIntType: CirClassType = createCirTypeWithoutArguments(PLATFORM_UINT_ID.toCirEntityId())
|
||||||
|
|
||||||
// plain integers
|
private val platformIntArrayType: CirClassType = createCirTypeWithoutArguments(PLATFORM_INT_ARRAY_ID.toCirEntityId())
|
||||||
private val platformIntType: CirClassType = createSimpleCirTypeWithoutArguments(PLATFORM_INT_ID.toCirEntityId())
|
private val platformUIntArrayType: CirClassType = createCirTypeWithoutArguments(PLATFORM_UINT_ARRAY_ID.toCirEntityId())
|
||||||
private val platformUIntType: CirClassType = createSimpleCirTypeWithoutArguments(PLATFORM_UINT_ID.toCirEntityId())
|
|
||||||
|
|
||||||
// arrays
|
private val platformIntRangeType: CirClassType = createCirTypeWithoutArguments(PLATFORM_INT_RANGE_ID.toCirEntityId())
|
||||||
private val platformIntArrayType: CirClassType = createSimpleCirTypeWithoutArguments(PLATFORM_INT_ARRAY_ID.toCirEntityId())
|
private val platformUIntRangeType: CirClassType = createCirTypeWithoutArguments(PLATFORM_UINT_RANGE_ID.toCirEntityId())
|
||||||
private val platformUIntArrayType: CirClassType = createSimpleCirTypeWithoutArguments(PLATFORM_UINT_ARRAY_ID.toCirEntityId())
|
|
||||||
|
|
||||||
// ranges
|
private val platformIntProgressionType: CirClassType = createCirTypeWithoutArguments(PLATFORM_INT_PROGRESSION_ID.toCirEntityId())
|
||||||
private val platformIntRangeType: CirClassType = createSimpleCirTypeWithoutArguments(PLATFORM_INT_RANGE_ID.toCirEntityId())
|
private val platformUIntProgressionType: CirClassType = createCirTypeWithoutArguments(PLATFORM_UINT_PROGRESSION_ID.toCirEntityId())
|
||||||
private val platformUIntRangeType: CirClassType = createSimpleCirTypeWithoutArguments(PLATFORM_UINT_RANGE_ID.toCirEntityId())
|
|
||||||
|
|
||||||
// progressions
|
private fun createCirTypeWithoutArguments(id: CirEntityId): CirClassType =
|
||||||
private val platformIntProgressionType: CirClassType = createSimpleCirTypeWithoutArguments(PLATFORM_INT_PROGRESSION_ID.toCirEntityId())
|
|
||||||
private val platformUIntProgressionType: CirClassType = createSimpleCirTypeWithoutArguments(PLATFORM_UINT_PROGRESSION_ID.toCirEntityId())
|
|
||||||
|
|
||||||
private fun createSimpleCirTypeWithoutArguments(id: CirEntityId): CirClassType =
|
|
||||||
CirClassType.createInterned(
|
CirClassType.createInterned(
|
||||||
classId = id,
|
classId = id,
|
||||||
outerType = null,
|
outerType = null,
|
||||||
@@ -119,9 +219,9 @@ private fun createSimpleCirTypeWithoutArguments(id: CirEntityId): CirClassType =
|
|||||||
isMarkedNullable = false,
|
isMarkedNullable = false,
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun createCommonVarOfType(isSigned: Boolean, argument: CirTypeProjection): CirClassType {
|
private fun createCirTypeWithOneArgument(entityId: CirEntityId, argument: CirTypeProjection): CirClassType {
|
||||||
return CirClassType.createInterned(
|
return CirClassType.createInterned(
|
||||||
classId = if (isSigned) PLATFORM_INT_VAR_OF_ID.toCirEntityId() else PLATFORM_UINT_VAR_OF_ID.toCirEntityId(),
|
classId = entityId,
|
||||||
outerType = null,
|
outerType = null,
|
||||||
arguments = SmartList(argument),
|
arguments = SmartList(argument),
|
||||||
isMarkedNullable = false,
|
isMarkedNullable = false,
|
||||||
|
|||||||
+58
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.commonizer.mergedtree
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.commonizer.CommonizerTarget
|
||||||
|
import org.jetbrains.kotlin.commonizer.LeafCommonizerTarget
|
||||||
|
import org.jetbrains.kotlin.commonizer.SharedCommonizerTarget
|
||||||
|
import org.jetbrains.kotlin.commonizer.allLeaves
|
||||||
|
import org.jetbrains.kotlin.commonizer.utils.singleDistinctValueOrNull
|
||||||
|
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||||
|
import org.jetbrains.kotlin.utils.addToStdlib.ifTrue
|
||||||
|
|
||||||
|
enum class PlatformIntWidth {
|
||||||
|
INT, LONG, MIXED
|
||||||
|
}
|
||||||
|
|
||||||
|
object PlatformWidthIndex {
|
||||||
|
private val widthByLeafTargets = mapOf(
|
||||||
|
LeafCommonizerTarget(KonanTarget.IOS_ARM32) to PlatformIntWidth.INT,
|
||||||
|
LeafCommonizerTarget(KonanTarget.IOS_ARM64) to PlatformIntWidth.LONG,
|
||||||
|
LeafCommonizerTarget(KonanTarget.IOS_X64) to PlatformIntWidth.LONG,
|
||||||
|
LeafCommonizerTarget(KonanTarget.IOS_SIMULATOR_ARM64) to PlatformIntWidth.LONG,
|
||||||
|
LeafCommonizerTarget(KonanTarget.WATCHOS_ARM32) to PlatformIntWidth.INT,
|
||||||
|
LeafCommonizerTarget(KonanTarget.WATCHOS_ARM64) to PlatformIntWidth.INT,
|
||||||
|
LeafCommonizerTarget(KonanTarget.WATCHOS_X86) to PlatformIntWidth.INT,
|
||||||
|
LeafCommonizerTarget(KonanTarget.WATCHOS_X64) to PlatformIntWidth.LONG,
|
||||||
|
LeafCommonizerTarget(KonanTarget.WATCHOS_SIMULATOR_ARM64) to PlatformIntWidth.LONG,
|
||||||
|
LeafCommonizerTarget(KonanTarget.TVOS_ARM64) to PlatformIntWidth.LONG,
|
||||||
|
LeafCommonizerTarget(KonanTarget.TVOS_X64) to PlatformIntWidth.LONG,
|
||||||
|
LeafCommonizerTarget(KonanTarget.TVOS_SIMULATOR_ARM64) to PlatformIntWidth.LONG,
|
||||||
|
LeafCommonizerTarget(KonanTarget.LINUX_X64) to PlatformIntWidth.LONG,
|
||||||
|
LeafCommonizerTarget(KonanTarget.MINGW_X86) to PlatformIntWidth.INT,
|
||||||
|
LeafCommonizerTarget(KonanTarget.MINGW_X64) to PlatformIntWidth.LONG,
|
||||||
|
LeafCommonizerTarget(KonanTarget.MACOS_X64) to PlatformIntWidth.LONG,
|
||||||
|
LeafCommonizerTarget(KonanTarget.MACOS_ARM64) to PlatformIntWidth.LONG,
|
||||||
|
LeafCommonizerTarget(KonanTarget.LINUX_ARM64) to PlatformIntWidth.LONG,
|
||||||
|
LeafCommonizerTarget(KonanTarget.LINUX_ARM32_HFP) to PlatformIntWidth.INT,
|
||||||
|
LeafCommonizerTarget(KonanTarget.LINUX_MIPS32) to PlatformIntWidth.INT,
|
||||||
|
LeafCommonizerTarget(KonanTarget.LINUX_MIPSEL32) to PlatformIntWidth.INT,
|
||||||
|
LeafCommonizerTarget(KonanTarget.WASM32) to PlatformIntWidth.INT,
|
||||||
|
)
|
||||||
|
|
||||||
|
fun platformWidthOf(target: CommonizerTarget): PlatformIntWidth? {
|
||||||
|
return when (target) {
|
||||||
|
is LeafCommonizerTarget -> widthByLeafTargets[target]
|
||||||
|
is SharedCommonizerTarget -> target.allLeaves().toList().let { leafTargets ->
|
||||||
|
val sameForAllLeaves = leafTargets.singleDistinctValueOrNull { platformWidthOf(it) }
|
||||||
|
if (sameForAllLeaves != null) return@let sameForAllLeaves
|
||||||
|
|
||||||
|
leafTargets.all { platformWidthOf(it) != null }.ifTrue { PlatformIntWidth.MIXED }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.commonizer
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.commonizer.mergedtree.PlatformIntWidth
|
||||||
|
import org.jetbrains.kotlin.commonizer.mergedtree.PlatformWidthIndex
|
||||||
|
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||||
|
import org.junit.Test
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
|
class PlatformBitWidthTest {
|
||||||
|
private fun createPlatformBitWidthIndex(): PlatformWidthIndex = PlatformWidthIndex
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test leaf int`() {
|
||||||
|
assertEquals(
|
||||||
|
PlatformIntWidth.INT,
|
||||||
|
createPlatformBitWidthIndex().platformWidthOf(CommonizerTarget(KonanTarget.IOS_ARM32))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test leaf long`() {
|
||||||
|
assertEquals(
|
||||||
|
PlatformIntWidth.LONG,
|
||||||
|
createPlatformBitWidthIndex().platformWidthOf(CommonizerTarget(KonanTarget.MACOS_X64))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test shared int`() {
|
||||||
|
assertEquals(
|
||||||
|
PlatformIntWidth.INT,
|
||||||
|
createPlatformBitWidthIndex().platformWidthOf(CommonizerTarget(KonanTarget.IOS_ARM32, KonanTarget.LINUX_MIPS32))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test shared long`() {
|
||||||
|
assertEquals(
|
||||||
|
PlatformIntWidth.LONG,
|
||||||
|
createPlatformBitWidthIndex().platformWidthOf(CommonizerTarget(KonanTarget.MACOS_X64, KonanTarget.LINUX_X64))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test int and long`() {
|
||||||
|
assertEquals(
|
||||||
|
PlatformIntWidth.MIXED,
|
||||||
|
createPlatformBitWidthIndex().platformWidthOf(CommonizerTarget(KonanTarget.IOS_ARM32, KonanTarget.MACOS_X64))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test int and unknown`() {
|
||||||
|
assertEquals(
|
||||||
|
null,
|
||||||
|
createPlatformBitWidthIndex().platformWidthOf(
|
||||||
|
CommonizerTarget(
|
||||||
|
LeafCommonizerTarget(KonanTarget.IOS_ARM32),
|
||||||
|
LeafCommonizerTarget("unknown_target")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test long and unknown`() {
|
||||||
|
assertEquals(
|
||||||
|
null,
|
||||||
|
createPlatformBitWidthIndex().platformWidthOf(
|
||||||
|
CommonizerTarget(
|
||||||
|
LeafCommonizerTarget(KonanTarget.MACOS_X64),
|
||||||
|
LeafCommonizerTarget("unknown_target")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test the good, the bad and the ugly`() {
|
||||||
|
assertEquals(
|
||||||
|
null,
|
||||||
|
createPlatformBitWidthIndex().platformWidthOf(
|
||||||
|
CommonizerTarget(
|
||||||
|
LeafCommonizerTarget(KonanTarget.MACOS_X64),
|
||||||
|
LeafCommonizerTarget(KonanTarget.IOS_ARM32),
|
||||||
|
LeafCommonizerTarget("unknown_target"),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test watchosArm64 is considered int`() {
|
||||||
|
assertEquals(
|
||||||
|
PlatformIntWidth.INT,
|
||||||
|
createPlatformBitWidthIndex().platformWidthOf(CommonizerTarget(KonanTarget.WATCHOS_ARM64))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
+290
-87
@@ -6,32 +6,61 @@
|
|||||||
package org.jetbrains.kotlin.commonizer.hierarchical
|
package org.jetbrains.kotlin.commonizer.hierarchical
|
||||||
|
|
||||||
import org.jetbrains.kotlin.commonizer.AbstractInlineSourcesCommonizationTest
|
import org.jetbrains.kotlin.commonizer.AbstractInlineSourcesCommonizationTest
|
||||||
|
import org.jetbrains.kotlin.commonizer.OptimisticNumberCommonizationEnabledKey
|
||||||
import org.jetbrains.kotlin.commonizer.PlatformIntegerCommonizationEnabledKey
|
import org.jetbrains.kotlin.commonizer.PlatformIntegerCommonizationEnabledKey
|
||||||
import org.jetbrains.kotlin.commonizer.assertCommonized
|
import org.jetbrains.kotlin.commonizer.assertCommonized
|
||||||
|
import org.jetbrains.kotlin.konan.target.KonanTarget.*
|
||||||
|
|
||||||
class HierarchicalPlatformIntegerCommonizationTest : AbstractInlineSourcesCommonizationTest() {
|
class HierarchicalPlatformIntegerCommonizationTest : AbstractInlineSourcesCommonizationTest() {
|
||||||
fun `test signed ints`() {
|
fun `test signed ints without optimistic commonization`() {
|
||||||
val result = commonize {
|
val result = commonize {
|
||||||
outputTarget("(a, b)")
|
outputTarget("(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})")
|
||||||
setting(PlatformIntegerCommonizationEnabledKey, true)
|
setting(PlatformIntegerCommonizationEnabledKey, true)
|
||||||
registerFakeStdlibIntegersDependency("(a, b)")
|
setting(OptimisticNumberCommonizationEnabledKey, false)
|
||||||
|
registerFakeStdlibIntegersDependency("(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})")
|
||||||
|
|
||||||
"a" withSource """
|
LINUX_ARM64.name withSource """
|
||||||
typealias X = Int
|
typealias X = Int
|
||||||
typealias Y = Long
|
typealias Y = Long
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
"b" withSource """
|
LINUX_ARM32_HFP.name withSource """
|
||||||
typealias X = Long
|
typealias X = Long
|
||||||
typealias Y = Int
|
typealias Y = Int
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
}
|
}
|
||||||
|
|
||||||
result.assertCommonized(
|
result.assertCommonized(
|
||||||
"(a, b)", """
|
"(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})", """
|
||||||
@UnsafeNumber(["a: kotlin.Int", "b: kotlin.Long"])
|
expect class X : Number
|
||||||
typealias X = PlatformInt
|
typealias Y = PlatformInt
|
||||||
@UnsafeNumber(["a: kotlin.Long", "b: kotlin.Int"])
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun `test signed ints with optimistic commonization backup`() {
|
||||||
|
val result = commonize {
|
||||||
|
outputTarget("(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})")
|
||||||
|
setting(PlatformIntegerCommonizationEnabledKey, true)
|
||||||
|
setting(OptimisticNumberCommonizationEnabledKey, true)
|
||||||
|
registerFakeStdlibIntegersDependency("(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})")
|
||||||
|
|
||||||
|
LINUX_ARM64.name withSource """
|
||||||
|
typealias X = Int
|
||||||
|
typealias Y = Long
|
||||||
|
""".trimIndent()
|
||||||
|
|
||||||
|
LINUX_ARM32_HFP.name withSource """
|
||||||
|
typealias X = Long
|
||||||
|
typealias Y = Int
|
||||||
|
""".trimIndent()
|
||||||
|
}
|
||||||
|
|
||||||
|
result.assertCommonized(
|
||||||
|
"(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})", """
|
||||||
|
@UnsafeNumber(["${LINUX_ARM32_HFP.name}: kotlin.Long", "${LINUX_ARM64.name}: kotlin.Int"])
|
||||||
|
typealias X = Int
|
||||||
|
@UnsafeNumber(["${LINUX_ARM32_HFP.name}: kotlin.Int", "${LINUX_ARM64.name}: kotlin.Long"])
|
||||||
typealias Y = PlatformInt
|
typealias Y = PlatformInt
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
@@ -39,26 +68,26 @@ class HierarchicalPlatformIntegerCommonizationTest : AbstractInlineSourcesCommon
|
|||||||
|
|
||||||
fun `test unsigned ints`() {
|
fun `test unsigned ints`() {
|
||||||
val result = commonize {
|
val result = commonize {
|
||||||
outputTarget("(a, b)")
|
outputTarget("(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})")
|
||||||
setting(PlatformIntegerCommonizationEnabledKey, true)
|
setting(PlatformIntegerCommonizationEnabledKey, true)
|
||||||
registerFakeStdlibIntegersDependency("(a, b)")
|
registerFakeStdlibIntegersDependency("(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})")
|
||||||
|
|
||||||
"a" withSource """
|
LINUX_ARM64.name withSource """
|
||||||
typealias X = UInt
|
typealias X = UInt
|
||||||
typealias Y = ULong
|
typealias Y = ULong
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
"b" withSource """
|
LINUX_ARM32_HFP.name withSource """
|
||||||
typealias X = ULong
|
typealias X = ULong
|
||||||
typealias Y = UInt
|
typealias Y = UInt
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
}
|
}
|
||||||
|
|
||||||
result.assertCommonized(
|
result.assertCommonized(
|
||||||
"(a, b)", """
|
"(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})", """
|
||||||
@UnsafeNumber(["a: kotlin.UInt", "b: kotlin.ULong"])
|
@UnsafeNumber(["${LINUX_ARM32_HFP.name}: kotlin.ULong", "${LINUX_ARM64.name}: kotlin.UInt"])
|
||||||
typealias X = PlatformUInt
|
typealias X = UInt
|
||||||
@UnsafeNumber(["a: kotlin.ULong", "b: kotlin.UInt"])
|
@UnsafeNumber(["${LINUX_ARM32_HFP.name}: kotlin.UInt", "${LINUX_ARM64.name}: kotlin.ULong"])
|
||||||
typealias Y = PlatformUInt
|
typealias Y = PlatformUInt
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
@@ -66,11 +95,11 @@ class HierarchicalPlatformIntegerCommonizationTest : AbstractInlineSourcesCommon
|
|||||||
|
|
||||||
fun `test signed vars`() {
|
fun `test signed vars`() {
|
||||||
val result = commonize {
|
val result = commonize {
|
||||||
outputTarget("(a, b)")
|
outputTarget("(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})")
|
||||||
setting(PlatformIntegerCommonizationEnabledKey, true)
|
setting(PlatformIntegerCommonizationEnabledKey, true)
|
||||||
registerFakeStdlibIntegersDependency("(a, b)")
|
registerFakeStdlibIntegersDependency("(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})")
|
||||||
|
|
||||||
"a" withSource """
|
LINUX_ARM64.name withSource """
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
typealias AX = Int
|
typealias AX = Int
|
||||||
@@ -79,7 +108,7 @@ class HierarchicalPlatformIntegerCommonizationTest : AbstractInlineSourcesCommon
|
|||||||
typealias Y = LongVarOf<AY>
|
typealias Y = LongVarOf<AY>
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
"b" withSource """
|
LINUX_ARM32_HFP.name withSource """
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
typealias AX = Long
|
typealias AX = Long
|
||||||
@@ -90,16 +119,16 @@ class HierarchicalPlatformIntegerCommonizationTest : AbstractInlineSourcesCommon
|
|||||||
}
|
}
|
||||||
|
|
||||||
result.assertCommonized(
|
result.assertCommonized(
|
||||||
"(a, b)", """
|
"(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})", """
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
@UnsafeNumber(["a: kotlin.Int", "b: kotlin.Long"])
|
@UnsafeNumber(["${LINUX_ARM32_HFP.name}: kotlin.Long", "${LINUX_ARM64.name}: kotlin.Int"])
|
||||||
typealias AX = PlatformInt
|
typealias AX = Int
|
||||||
@UnsafeNumber(["a: kotlin.Long", "b: kotlin.Int"])
|
@UnsafeNumber(["${LINUX_ARM32_HFP.name}: kotlin.Int", "${LINUX_ARM64.name}: kotlin.Long"])
|
||||||
typealias AY = PlatformInt
|
typealias AY = PlatformInt
|
||||||
@UnsafeNumber(["a: kotlinx.cinterop.IntVarOf", "b: kotlinx.cinterop.LongVarOf"])
|
@UnsafeNumber(["${LINUX_ARM32_HFP.name}: kotlinx.cinterop.LongVarOf", "${LINUX_ARM64.name}: kotlinx.cinterop.IntVarOf"])
|
||||||
typealias X = PlatformIntVarOf<AX>
|
typealias X = IntVarOf<AX>
|
||||||
@UnsafeNumber(["a: kotlinx.cinterop.LongVarOf", "b: kotlinx.cinterop.IntVarOf"])
|
@UnsafeNumber(["${LINUX_ARM32_HFP.name}: kotlinx.cinterop.IntVarOf", "${LINUX_ARM64.name}: kotlinx.cinterop.LongVarOf"])
|
||||||
typealias Y = PlatformIntVarOf<AY>
|
typealias Y = PlatformIntVarOf<AY>
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
@@ -107,11 +136,11 @@ class HierarchicalPlatformIntegerCommonizationTest : AbstractInlineSourcesCommon
|
|||||||
|
|
||||||
fun `test unsigned vars`() {
|
fun `test unsigned vars`() {
|
||||||
val result = commonize {
|
val result = commonize {
|
||||||
outputTarget("(a, b)")
|
outputTarget("(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})")
|
||||||
setting(PlatformIntegerCommonizationEnabledKey, true)
|
setting(PlatformIntegerCommonizationEnabledKey, true)
|
||||||
registerFakeStdlibIntegersDependency("(a, b)")
|
registerFakeStdlibIntegersDependency("(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})")
|
||||||
|
|
||||||
"a" withSource """
|
LINUX_ARM64.name withSource """
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
typealias AX = UInt
|
typealias AX = UInt
|
||||||
@@ -120,7 +149,7 @@ class HierarchicalPlatformIntegerCommonizationTest : AbstractInlineSourcesCommon
|
|||||||
typealias Y = ULongVarOf<AY>
|
typealias Y = ULongVarOf<AY>
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
"b" withSource """
|
LINUX_ARM32_HFP.name withSource """
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
typealias AX = ULong
|
typealias AX = ULong
|
||||||
@@ -131,16 +160,16 @@ class HierarchicalPlatformIntegerCommonizationTest : AbstractInlineSourcesCommon
|
|||||||
}
|
}
|
||||||
|
|
||||||
result.assertCommonized(
|
result.assertCommonized(
|
||||||
"(a, b)", """
|
"(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})", """
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
@UnsafeNumber(["a: kotlin.UInt", "b: kotlin.ULong"])
|
@UnsafeNumber(["${LINUX_ARM32_HFP.name}: kotlin.ULong", "${LINUX_ARM64.name}: kotlin.UInt"])
|
||||||
typealias AX = PlatformUInt
|
typealias AX = UInt
|
||||||
@UnsafeNumber(["a: kotlin.ULong", "b: kotlin.UInt"])
|
@UnsafeNumber(["${LINUX_ARM32_HFP.name}: kotlin.UInt", "${LINUX_ARM64.name}: kotlin.ULong"])
|
||||||
typealias AY = PlatformUInt
|
typealias AY = PlatformUInt
|
||||||
@UnsafeNumber(["a: kotlinx.cinterop.UIntVarOf", "b: kotlinx.cinterop.ULongVarOf"])
|
@UnsafeNumber(["${LINUX_ARM32_HFP.name}: kotlinx.cinterop.ULongVarOf", "${LINUX_ARM64.name}: kotlinx.cinterop.UIntVarOf"])
|
||||||
typealias X = PlatformUIntVarOf<AX>
|
typealias X = UIntVarOf<AX>
|
||||||
@UnsafeNumber(["a: kotlinx.cinterop.ULongVarOf", "b: kotlinx.cinterop.UIntVarOf"])
|
@UnsafeNumber(["${LINUX_ARM32_HFP.name}: kotlinx.cinterop.UIntVarOf", "${LINUX_ARM64.name}: kotlinx.cinterop.ULongVarOf"])
|
||||||
typealias Y = PlatformUIntVarOf<AY>
|
typealias Y = PlatformUIntVarOf<AY>
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
@@ -148,26 +177,26 @@ class HierarchicalPlatformIntegerCommonizationTest : AbstractInlineSourcesCommon
|
|||||||
|
|
||||||
fun `test signed arrays`() {
|
fun `test signed arrays`() {
|
||||||
val result = commonize {
|
val result = commonize {
|
||||||
outputTarget("(a, b)")
|
outputTarget("(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})")
|
||||||
setting(PlatformIntegerCommonizationEnabledKey, true)
|
setting(PlatformIntegerCommonizationEnabledKey, true)
|
||||||
registerFakeStdlibIntegersDependency("(a, b)")
|
registerFakeStdlibIntegersDependency("(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})")
|
||||||
|
|
||||||
"a" withSource """
|
LINUX_ARM64.name withSource """
|
||||||
typealias X = IntArray
|
typealias X = IntArray
|
||||||
typealias Y = LongArray
|
typealias Y = LongArray
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
"b" withSource """
|
LINUX_ARM32_HFP.name withSource """
|
||||||
typealias X = LongArray
|
typealias X = LongArray
|
||||||
typealias Y = IntArray
|
typealias Y = IntArray
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
}
|
}
|
||||||
|
|
||||||
result.assertCommonized(
|
result.assertCommonized(
|
||||||
"(a, b)", """
|
"(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})", """
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
typealias X = PlatformIntArray
|
expect class X
|
||||||
typealias Y = PlatformIntArray
|
typealias Y = PlatformIntArray
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
@@ -175,26 +204,26 @@ class HierarchicalPlatformIntegerCommonizationTest : AbstractInlineSourcesCommon
|
|||||||
|
|
||||||
fun `test unsigned arrays`() {
|
fun `test unsigned arrays`() {
|
||||||
val result = commonize {
|
val result = commonize {
|
||||||
outputTarget("(a, b)")
|
outputTarget("(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})")
|
||||||
setting(PlatformIntegerCommonizationEnabledKey, true)
|
setting(PlatformIntegerCommonizationEnabledKey, true)
|
||||||
registerFakeStdlibIntegersDependency("(a, b)")
|
registerFakeStdlibIntegersDependency("(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})")
|
||||||
|
|
||||||
"a" withSource """
|
LINUX_ARM64.name withSource """
|
||||||
typealias X = UIntArray
|
typealias X = UIntArray
|
||||||
typealias Y = ULongArray
|
typealias Y = ULongArray
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
"b" withSource """
|
LINUX_ARM32_HFP.name withSource """
|
||||||
typealias X = ULongArray
|
typealias X = ULongArray
|
||||||
typealias Y = UIntArray
|
typealias Y = UIntArray
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
}
|
}
|
||||||
|
|
||||||
result.assertCommonized(
|
result.assertCommonized(
|
||||||
"(a, b)", """
|
"(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})", """
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
typealias X = PlatformUIntArray
|
expect class X
|
||||||
typealias Y = PlatformUIntArray
|
typealias Y = PlatformUIntArray
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
@@ -202,28 +231,28 @@ class HierarchicalPlatformIntegerCommonizationTest : AbstractInlineSourcesCommon
|
|||||||
|
|
||||||
fun `test signed ranges`() {
|
fun `test signed ranges`() {
|
||||||
val result = commonize {
|
val result = commonize {
|
||||||
outputTarget("(a, b)")
|
outputTarget("(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})")
|
||||||
setting(PlatformIntegerCommonizationEnabledKey, true)
|
setting(PlatformIntegerCommonizationEnabledKey, true)
|
||||||
registerFakeStdlibIntegersDependency("(a, b)")
|
registerFakeStdlibIntegersDependency("(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})")
|
||||||
|
|
||||||
"a" withSource """
|
LINUX_ARM64.name withSource """
|
||||||
import kotlin.ranges.*
|
import kotlin.ranges.*
|
||||||
|
|
||||||
typealias X = IntRange
|
typealias X = IntRange
|
||||||
typealias Y = LongRange
|
typealias Y = LongRange
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
"b" withSource """
|
LINUX_ARM32_HFP.name withSource """
|
||||||
typealias X = LongRange
|
typealias X = LongRange
|
||||||
typealias Y = IntRange
|
typealias Y = IntRange
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
}
|
}
|
||||||
|
|
||||||
result.assertCommonized(
|
result.assertCommonized(
|
||||||
"(a, b)", """
|
"(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})", """
|
||||||
import kotlin.ranges.*
|
import kotlin.ranges.*
|
||||||
|
|
||||||
typealias X = PlatformIntRange
|
expect class X
|
||||||
typealias Y = PlatformIntRange
|
typealias Y = PlatformIntRange
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
@@ -231,28 +260,28 @@ class HierarchicalPlatformIntegerCommonizationTest : AbstractInlineSourcesCommon
|
|||||||
|
|
||||||
fun `test unsigned ranges`() {
|
fun `test unsigned ranges`() {
|
||||||
val result = commonize {
|
val result = commonize {
|
||||||
outputTarget("(a, b)")
|
outputTarget("(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})")
|
||||||
setting(PlatformIntegerCommonizationEnabledKey, true)
|
setting(PlatformIntegerCommonizationEnabledKey, true)
|
||||||
registerFakeStdlibIntegersDependency("(a, b)")
|
registerFakeStdlibIntegersDependency("(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})")
|
||||||
|
|
||||||
"a" withSource """
|
LINUX_ARM64.name withSource """
|
||||||
import kotlin.ranges.*
|
import kotlin.ranges.*
|
||||||
|
|
||||||
typealias X = UIntRange
|
typealias X = UIntRange
|
||||||
typealias Y = ULongRange
|
typealias Y = ULongRange
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
"b" withSource """
|
LINUX_ARM32_HFP.name withSource """
|
||||||
typealias X = ULongRange
|
typealias X = ULongRange
|
||||||
typealias Y = UIntRange
|
typealias Y = UIntRange
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
}
|
}
|
||||||
|
|
||||||
result.assertCommonized(
|
result.assertCommonized(
|
||||||
"(a, b)", """
|
"(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})", """
|
||||||
import kotlin.ranges.*
|
import kotlin.ranges.*
|
||||||
|
|
||||||
typealias X = PlatformUIntRange
|
expect class X
|
||||||
typealias Y = PlatformUIntRange
|
typealias Y = PlatformUIntRange
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
@@ -260,28 +289,28 @@ class HierarchicalPlatformIntegerCommonizationTest : AbstractInlineSourcesCommon
|
|||||||
|
|
||||||
fun `test signed progressions`() {
|
fun `test signed progressions`() {
|
||||||
val result = commonize {
|
val result = commonize {
|
||||||
outputTarget("(a, b)")
|
outputTarget("(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})")
|
||||||
setting(PlatformIntegerCommonizationEnabledKey, true)
|
setting(PlatformIntegerCommonizationEnabledKey, true)
|
||||||
registerFakeStdlibIntegersDependency("(a, b)")
|
registerFakeStdlibIntegersDependency("(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})")
|
||||||
|
|
||||||
"a" withSource """
|
LINUX_ARM64.name withSource """
|
||||||
import kotlin.ranges.*
|
import kotlin.ranges.*
|
||||||
|
|
||||||
typealias X = IntProgression
|
typealias X = IntProgression
|
||||||
typealias Y = LongProgression
|
typealias Y = LongProgression
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
"b" withSource """
|
LINUX_ARM32_HFP.name withSource """
|
||||||
typealias X = LongProgression
|
typealias X = LongProgression
|
||||||
typealias Y = IntProgression
|
typealias Y = IntProgression
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
}
|
}
|
||||||
|
|
||||||
result.assertCommonized(
|
result.assertCommonized(
|
||||||
"(a, b)", """
|
"(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})", """
|
||||||
import kotlin.ranges.*
|
import kotlin.ranges.*
|
||||||
|
|
||||||
typealias X = PlatformIntProgression
|
expect class X
|
||||||
typealias Y = PlatformIntProgression
|
typealias Y = PlatformIntProgression
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
@@ -289,28 +318,28 @@ class HierarchicalPlatformIntegerCommonizationTest : AbstractInlineSourcesCommon
|
|||||||
|
|
||||||
fun `test unsigned progressions`() {
|
fun `test unsigned progressions`() {
|
||||||
val result = commonize {
|
val result = commonize {
|
||||||
outputTarget("(a, b)")
|
outputTarget("(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})")
|
||||||
setting(PlatformIntegerCommonizationEnabledKey, true)
|
setting(PlatformIntegerCommonizationEnabledKey, true)
|
||||||
registerFakeStdlibIntegersDependency("(a, b)")
|
registerFakeStdlibIntegersDependency("(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})")
|
||||||
|
|
||||||
"a" withSource """
|
LINUX_ARM64.name withSource """
|
||||||
import kotlin.ranges.*
|
import kotlin.ranges.*
|
||||||
|
|
||||||
typealias X = UIntProgression
|
typealias X = UIntProgression
|
||||||
typealias Y = ULongProgression
|
typealias Y = ULongProgression
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
"b" withSource """
|
LINUX_ARM32_HFP.name withSource """
|
||||||
typealias X = ULongProgression
|
typealias X = ULongProgression
|
||||||
typealias Y = UIntProgression
|
typealias Y = UIntProgression
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
}
|
}
|
||||||
|
|
||||||
result.assertCommonized(
|
result.assertCommonized(
|
||||||
"(a, b)", """
|
"(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})", """
|
||||||
import kotlin.ranges.*
|
import kotlin.ranges.*
|
||||||
|
|
||||||
typealias X = PlatformUIntProgression
|
expect class X
|
||||||
typealias Y = PlatformUIntProgression
|
typealias Y = PlatformUIntProgression
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
@@ -318,11 +347,11 @@ class HierarchicalPlatformIntegerCommonizationTest : AbstractInlineSourcesCommon
|
|||||||
|
|
||||||
fun `test platform types in return positions`() {
|
fun `test platform types in return positions`() {
|
||||||
val result = commonize {
|
val result = commonize {
|
||||||
outputTarget("(a, b)")
|
outputTarget("(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})")
|
||||||
setting(PlatformIntegerCommonizationEnabledKey, true)
|
setting(PlatformIntegerCommonizationEnabledKey, true)
|
||||||
registerFakeStdlibIntegersDependency("(a, b)")
|
registerFakeStdlibIntegersDependency("(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})")
|
||||||
|
|
||||||
"a" withSource """
|
LINUX_ARM32_HFP.name withSource """
|
||||||
import kotlin.ranges.*
|
import kotlin.ranges.*
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
@@ -336,7 +365,7 @@ class HierarchicalPlatformIntegerCommonizationTest : AbstractInlineSourcesCommon
|
|||||||
fun p(): IntProgression = null!!
|
fun p(): IntProgression = null!!
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
"b" withSource """
|
LINUX_ARM64.name withSource """
|
||||||
import kotlin.ranges.*
|
import kotlin.ranges.*
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
@@ -352,12 +381,14 @@ class HierarchicalPlatformIntegerCommonizationTest : AbstractInlineSourcesCommon
|
|||||||
}
|
}
|
||||||
|
|
||||||
result.assertCommonized(
|
result.assertCommonized(
|
||||||
"(a, b)", """
|
"(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})", """
|
||||||
import kotlin.ranges.*
|
import kotlin.ranges.*
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
expect class C() {
|
expect class C() {
|
||||||
|
@UnsafeNumber(["${LINUX_ARM32_HFP.name}: kotlin.Int", "${LINUX_ARM64.name}: kotlin.Long"])
|
||||||
val i: PlatformInt
|
val i: PlatformInt
|
||||||
|
@UnsafeNumber(["${LINUX_ARM32_HFP.name}: kotlinx.cinterop.IntVarOf", "${LINUX_ARM64.name}: kotlinx.cinterop.LongVarOf"])
|
||||||
fun v(): PlatformIntVarOf<PlatformInt>
|
fun v(): PlatformIntVarOf<PlatformInt>
|
||||||
fun r(): PlatformIntRange
|
fun r(): PlatformIntRange
|
||||||
}
|
}
|
||||||
@@ -370,11 +401,11 @@ class HierarchicalPlatformIntegerCommonizationTest : AbstractInlineSourcesCommon
|
|||||||
|
|
||||||
fun `test platform types in signatures`() {
|
fun `test platform types in signatures`() {
|
||||||
val result = commonize {
|
val result = commonize {
|
||||||
outputTarget("(a, b)")
|
outputTarget("(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})")
|
||||||
setting(PlatformIntegerCommonizationEnabledKey, true)
|
setting(PlatformIntegerCommonizationEnabledKey, true)
|
||||||
registerFakeStdlibIntegersDependency("(a, b)")
|
registerFakeStdlibIntegersDependency("(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})")
|
||||||
|
|
||||||
"a" withSource """
|
LINUX_ARM64.name withSource """
|
||||||
import kotlin.ranges.*
|
import kotlin.ranges.*
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
@@ -388,7 +419,7 @@ class HierarchicalPlatformIntegerCommonizationTest : AbstractInlineSourcesCommon
|
|||||||
fun p(arg: IntProgression) {}
|
fun p(arg: IntProgression) {}
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
"b" withSource """
|
LINUX_ARM32_HFP.name withSource """
|
||||||
import kotlin.ranges.*
|
import kotlin.ranges.*
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
@@ -404,12 +435,184 @@ class HierarchicalPlatformIntegerCommonizationTest : AbstractInlineSourcesCommon
|
|||||||
}
|
}
|
||||||
|
|
||||||
result.assertCommonized(
|
result.assertCommonized(
|
||||||
"(a, b)", """
|
"(${LINUX_ARM64.name}, ${LINUX_ARM32_HFP.name})", """
|
||||||
import kotlin.ranges.*
|
import kotlin.ranges.*
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
expect class C() {
|
expect class C()
|
||||||
}
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun `test platform integers in multi-target commonization`() {
|
||||||
|
val intTarget1 = LINUX_ARM32_HFP.name
|
||||||
|
val intTarget2 = LINUX_MIPS32.name
|
||||||
|
val intTarget3 = LINUX_MIPSEL32.name
|
||||||
|
val longTarget1 = LINUX_X64.name
|
||||||
|
val longTarget2 = LINUX_ARM64.name
|
||||||
|
val longTarget3 = MACOS_X64.name
|
||||||
|
|
||||||
|
val outputCommonizerTargets = arrayOf(
|
||||||
|
"($intTarget1, $intTarget2)", "($longTarget1, $longTarget2)", "($intTarget3, $longTarget3)",
|
||||||
|
"($intTarget1, $intTarget2, $intTarget3)", "($longTarget1, $longTarget2, $longTarget3)",
|
||||||
|
"($intTarget1, $intTarget2, $intTarget3, $longTarget1)",
|
||||||
|
"($intTarget1, $intTarget2, $longTarget1, $longTarget2)",
|
||||||
|
"($longTarget1, $longTarget2, $longTarget3, $intTarget1)",
|
||||||
|
"($intTarget1, $intTarget2, $intTarget3, $longTarget1, $longTarget2, $longTarget3)",
|
||||||
|
)
|
||||||
|
|
||||||
|
val result = commonize {
|
||||||
|
setting(PlatformIntegerCommonizationEnabledKey, true)
|
||||||
|
outputTarget(*outputCommonizerTargets)
|
||||||
|
registerFakeStdlibIntegersDependency(*outputCommonizerTargets)
|
||||||
|
|
||||||
|
intTarget1 withSource """
|
||||||
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
|
typealias X = Int
|
||||||
|
typealias XV = IntVarOf<X>
|
||||||
|
""".trimIndent()
|
||||||
|
|
||||||
|
intTarget2 withSource """
|
||||||
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
|
typealias X = Int
|
||||||
|
typealias XV = IntVarOf<X>
|
||||||
|
""".trimIndent()
|
||||||
|
|
||||||
|
intTarget3 withSource """
|
||||||
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
|
typealias X = Int
|
||||||
|
typealias XV = IntVarOf<X>
|
||||||
|
""".trimIndent()
|
||||||
|
|
||||||
|
longTarget1 withSource """
|
||||||
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
|
typealias X = Long
|
||||||
|
typealias XV = LongVarOf<X>
|
||||||
|
""".trimIndent()
|
||||||
|
|
||||||
|
longTarget2 withSource """
|
||||||
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
|
typealias X = Long
|
||||||
|
typealias XV = LongVarOf<X>
|
||||||
|
""".trimIndent()
|
||||||
|
|
||||||
|
longTarget3 withSource """
|
||||||
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
|
typealias X = Long
|
||||||
|
typealias XV = LongVarOf<X>
|
||||||
|
""".trimIndent()
|
||||||
|
}
|
||||||
|
|
||||||
|
result.assertCommonized(
|
||||||
|
"($intTarget1, $intTarget2)", """
|
||||||
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
|
typealias X = Int
|
||||||
|
typealias XV = IntVarOf<X>
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
|
||||||
|
result.assertCommonized(
|
||||||
|
"($intTarget1, $intTarget2, $intTarget3)", """
|
||||||
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
|
typealias X = Int
|
||||||
|
typealias XV = IntVarOf<X>
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
|
||||||
|
result.assertCommonized(
|
||||||
|
"($longTarget1, $longTarget2)", """
|
||||||
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
|
typealias X = Long
|
||||||
|
typealias XV = LongVarOf<X>
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
|
||||||
|
result.assertCommonized(
|
||||||
|
"($longTarget1, $longTarget2, $longTarget3)", """
|
||||||
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
|
typealias X = Long
|
||||||
|
typealias XV = LongVarOf<X>
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
|
||||||
|
result.assertCommonized(
|
||||||
|
"($intTarget3, $longTarget3)", """
|
||||||
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
|
@UnsafeNumber(["${LINUX_MIPSEL32.name}: kotlin.Int", "${MACOS_X64.name}: kotlin.Long"])
|
||||||
|
typealias X = PlatformInt
|
||||||
|
@UnsafeNumber(["${LINUX_MIPSEL32.name}: kotlinx.cinterop.IntVarOf", "${MACOS_X64.name}: kotlinx.cinterop.LongVarOf"])
|
||||||
|
typealias XV = PlatformIntVarOf<X>
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
|
||||||
|
result.assertCommonized(
|
||||||
|
"($intTarget1, $intTarget2, $longTarget1, $longTarget2)", """
|
||||||
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
|
@UnsafeNumber([
|
||||||
|
"${LINUX_ARM32_HFP.name}: kotlin.Int", "${LINUX_ARM64.name}: kotlin.Long",
|
||||||
|
"${LINUX_MIPS32.name}: kotlin.Int", "${LINUX_X64.name}: kotlin.Long"
|
||||||
|
])
|
||||||
|
typealias X = PlatformInt
|
||||||
|
@UnsafeNumber([
|
||||||
|
"${LINUX_ARM32_HFP.name}: kotlinx.cinterop.IntVarOf", "${LINUX_ARM64.name}: kotlinx.cinterop.LongVarOf",
|
||||||
|
"${LINUX_MIPS32.name}: kotlinx.cinterop.IntVarOf", "${LINUX_X64.name}: kotlinx.cinterop.LongVarOf"
|
||||||
|
])
|
||||||
|
typealias XV = PlatformIntVarOf<X>
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
|
||||||
|
result.assertCommonized(
|
||||||
|
"($intTarget1, $intTarget2, $intTarget3, $longTarget1)", """
|
||||||
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
|
@UnsafeNumber([
|
||||||
|
"${LINUX_ARM32_HFP.name}: kotlin.Int", "${LINUX_MIPS32.name}: kotlin.Int",
|
||||||
|
"${LINUX_MIPSEL32.name}: kotlin.Int", "${LINUX_X64.name}: kotlin.Long"
|
||||||
|
])
|
||||||
|
typealias X = PlatformInt
|
||||||
|
@UnsafeNumber([
|
||||||
|
"${LINUX_ARM32_HFP.name}: kotlinx.cinterop.IntVarOf", "${LINUX_MIPS32.name}: kotlinx.cinterop.IntVarOf",
|
||||||
|
"${LINUX_MIPSEL32.name}: kotlinx.cinterop.IntVarOf", "${LINUX_X64.name}: kotlinx.cinterop.LongVarOf"
|
||||||
|
])
|
||||||
|
typealias XV = PlatformIntVarOf<X>
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
|
||||||
|
result.assertCommonized(
|
||||||
|
"($longTarget1, $longTarget2, $longTarget3, $intTarget1)", """
|
||||||
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
|
@UnsafeNumber([
|
||||||
|
"${LINUX_ARM32_HFP.name}: kotlin.Int", "${LINUX_ARM64.name}: kotlin.Long",
|
||||||
|
"${LINUX_X64.name}: kotlin.Long", "${MACOS_X64.name}: kotlin.Long"
|
||||||
|
])
|
||||||
|
typealias X = PlatformInt
|
||||||
|
@UnsafeNumber([
|
||||||
|
"${LINUX_ARM32_HFP.name}: kotlinx.cinterop.IntVarOf", "${LINUX_ARM64.name}: kotlinx.cinterop.LongVarOf",
|
||||||
|
"${LINUX_X64.name}: kotlinx.cinterop.LongVarOf", "${MACOS_X64.name}: kotlinx.cinterop.LongVarOf"
|
||||||
|
])
|
||||||
|
typealias XV = PlatformIntVarOf<X>
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
|
||||||
|
result.assertCommonized(
|
||||||
|
"($intTarget1, $intTarget2, $intTarget3, $longTarget1, $longTarget2, $longTarget3)", """
|
||||||
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
|
typealias X = PlatformInt
|
||||||
|
typealias XV = PlatformIntVarOf<X>
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -34,8 +34,8 @@ val ULONG_RANGE_ID = ClassId.fromString("kotlin/ranges/ULongRange")
|
|||||||
val INT_PROGRESSION_ID = ClassId.fromString("kotlin/ranges/IntProgression")
|
val INT_PROGRESSION_ID = ClassId.fromString("kotlin/ranges/IntProgression")
|
||||||
val LONG_PROGRESSION_ID = ClassId.fromString("kotlin/ranges/LongProgression")
|
val LONG_PROGRESSION_ID = ClassId.fromString("kotlin/ranges/LongProgression")
|
||||||
|
|
||||||
val UINT_PROGRESSION = ClassId.fromString("kotlin/ranges/UIntProgression")
|
val UINT_PROGRESSION_ID = ClassId.fromString("kotlin/ranges/UIntProgression")
|
||||||
val ULONG_PROGRESSION = ClassId.fromString("kotlin/ranges/ULongProgression")
|
val ULONG_PROGRESSION_ID = ClassId.fromString("kotlin/ranges/ULongProgression")
|
||||||
|
|
||||||
val PLATFORM_INT_ID = ClassId.fromString("kotlin/PlatformInt")
|
val PLATFORM_INT_ID = ClassId.fromString("kotlin/PlatformInt")
|
||||||
val PLATFORM_UINT_ID = ClassId.fromString("kotlin/PlatformUInt")
|
val PLATFORM_UINT_ID = ClassId.fromString("kotlin/PlatformUInt")
|
||||||
|
|||||||
Reference in New Issue
Block a user