[Commonizer] Rework mocks for tests to drop descriptors
This commit is contained in:
+19
-17
@@ -5,10 +5,12 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.descriptors.commonizer.core
|
package org.jetbrains.kotlin.descriptors.commonizer.core
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.*
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirAnnotation
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirConstantValue
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirConstantValue.*
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirConstantValue.*
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirEntityId
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirName
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirAnnotationFactory
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirAnnotationFactory
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirTypeFactory
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.mockClassType
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.mockClassType
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import kotlin.DeprecationLevel.*
|
import kotlin.DeprecationLevel.*
|
||||||
@@ -28,13 +30,13 @@ class AnnotationsCommonizerTest : AbstractCommonizerTest<List<CirAnnotation>, Li
|
|||||||
expected = emptyList(),
|
expected = emptyList(),
|
||||||
emptyList(),
|
emptyList(),
|
||||||
emptyList(),
|
emptyList(),
|
||||||
listOf(mockAnnotation("org.sample.Foo"))
|
listOf(mockAnnotation("org/sample/Foo"))
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun noRelevantAnnotations2() = doTestSuccess(
|
fun noRelevantAnnotations2() = doTestSuccess(
|
||||||
expected = emptyList(),
|
expected = emptyList(),
|
||||||
listOf(mockAnnotation("org.sample.Foo")),
|
listOf(mockAnnotation("org/sample/Foo")),
|
||||||
emptyList(),
|
emptyList(),
|
||||||
emptyList()
|
emptyList()
|
||||||
)
|
)
|
||||||
@@ -42,25 +44,25 @@ class AnnotationsCommonizerTest : AbstractCommonizerTest<List<CirAnnotation>, Li
|
|||||||
@Test
|
@Test
|
||||||
fun noRelevantAnnotations3() = doTestSuccess(
|
fun noRelevantAnnotations3() = doTestSuccess(
|
||||||
expected = emptyList(),
|
expected = emptyList(),
|
||||||
listOf(mockAnnotation("org.sample.Foo")),
|
listOf(mockAnnotation("org/sample/Foo")),
|
||||||
listOf(mockAnnotation("org.sample.Foo")),
|
listOf(mockAnnotation("org/sample/Foo")),
|
||||||
listOf(mockAnnotation("org.sample.Foo"))
|
listOf(mockAnnotation("org/sample/Foo"))
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun noRelevantAnnotations4() = doTestSuccess(
|
fun noRelevantAnnotations4() = doTestSuccess(
|
||||||
expected = emptyList(),
|
expected = emptyList(),
|
||||||
listOf(mockAnnotation("org.sample.Foo")),
|
listOf(mockAnnotation("org/sample/Foo")),
|
||||||
listOf(mockAnnotation("org.sample.Bar")),
|
listOf(mockAnnotation("org/sample/Bar")),
|
||||||
listOf(mockAnnotation("org.sample.Baz"))
|
listOf(mockAnnotation("org/sample/Baz"))
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun noRelevantAnnotations5() = doTestSuccess(
|
fun noRelevantAnnotations5() = doTestSuccess(
|
||||||
expected = emptyList(),
|
expected = emptyList(),
|
||||||
listOf(mockAnnotation("kotlin.PublishedApi")),
|
listOf(mockAnnotation("kotlin/PublishedApi")),
|
||||||
listOf(mockAnnotation("kotlin.PublishedApi")),
|
listOf(mockAnnotation("kotlin/PublishedApi")),
|
||||||
listOf(mockAnnotation("kotlin.PublishedApi"))
|
listOf(mockAnnotation("kotlin/PublishedApi"))
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -279,11 +281,11 @@ class AnnotationsCommonizerTest : AbstractCommonizerTest<List<CirAnnotation>, Li
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun mockAnnotation(
|
private fun mockAnnotation(
|
||||||
fqName: String,
|
classId: String,
|
||||||
constantValueArguments: Map<CirName, CirConstantValue<*>> = emptyMap(),
|
constantValueArguments: Map<CirName, CirConstantValue<*>> = emptyMap(),
|
||||||
annotationValueArguments: Map<CirName, CirAnnotation> = emptyMap()
|
annotationValueArguments: Map<CirName, CirAnnotation> = emptyMap()
|
||||||
): CirAnnotation = CirAnnotationFactory.create(
|
): CirAnnotation = CirAnnotationFactory.create(
|
||||||
type = CirTypeFactory.create(mockClassType(fqName)) as CirClassType,
|
type = mockClassType(classId),
|
||||||
constantValueArguments = constantValueArguments,
|
constantValueArguments = constantValueArguments,
|
||||||
annotationValueArguments = annotationValueArguments
|
annotationValueArguments = annotationValueArguments
|
||||||
)
|
)
|
||||||
@@ -296,7 +298,7 @@ private fun mockDeprecated(
|
|||||||
): CirAnnotation {
|
): CirAnnotation {
|
||||||
val replaceWith: CirAnnotation? = if (replaceWithExpression.isNotEmpty() || replaceWithImports.isNotEmpty()) {
|
val replaceWith: CirAnnotation? = if (replaceWithExpression.isNotEmpty() || replaceWithImports.isNotEmpty()) {
|
||||||
mockAnnotation(
|
mockAnnotation(
|
||||||
fqName = "kotlin.ReplaceWith",
|
classId = "kotlin/ReplaceWith",
|
||||||
constantValueArguments = mapOf(
|
constantValueArguments = mapOf(
|
||||||
CirName.create("expression") to StringValue(replaceWithExpression),
|
CirName.create("expression") to StringValue(replaceWithExpression),
|
||||||
CirName.create("imports") to ArrayValue(replaceWithImports.map(::StringValue))
|
CirName.create("imports") to ArrayValue(replaceWithImports.map(::StringValue))
|
||||||
@@ -306,7 +308,7 @@ private fun mockDeprecated(
|
|||||||
} else null
|
} else null
|
||||||
|
|
||||||
return mockAnnotation(
|
return mockAnnotation(
|
||||||
fqName = "kotlin.Deprecated",
|
classId = "kotlin/Deprecated",
|
||||||
constantValueArguments = HashMap<CirName, CirConstantValue<*>>().apply {
|
constantValueArguments = HashMap<CirName, CirConstantValue<*>>().apply {
|
||||||
this[CirName.create("message")] = StringValue(message)
|
this[CirName.create("message")] = StringValue(message)
|
||||||
|
|
||||||
|
|||||||
+12
-13
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.descriptors.commonizer.core
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirExtensionReceiver
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirExtensionReceiver
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirExtensionReceiverFactory
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirExtensionReceiverFactory
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirTypeFactory
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.MOCK_CLASSIFIERS
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.MOCK_CLASSIFIERS
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.mockClassType
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.mockClassType
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
@@ -22,23 +21,23 @@ class ExtensionReceiverCommonizerTest : AbstractCommonizerTest<CirExtensionRecei
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun sameReceiver() = doTestSuccess(
|
fun sameReceiver() = doTestSuccess(
|
||||||
expected = mockExtensionReceiver("kotlin.String"),
|
expected = mockExtensionReceiver("kotlin/String"),
|
||||||
mockExtensionReceiver("kotlin.String"),
|
mockExtensionReceiver("kotlin/String"),
|
||||||
mockExtensionReceiver("kotlin.String"),
|
mockExtensionReceiver("kotlin/String"),
|
||||||
mockExtensionReceiver("kotlin.String")
|
mockExtensionReceiver("kotlin/String")
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun differentReceivers() = doTestFailure(
|
fun differentReceivers() = doTestFailure(
|
||||||
mockExtensionReceiver("kotlin.String"),
|
mockExtensionReceiver("kotlin/String"),
|
||||||
mockExtensionReceiver("kotlin.String"),
|
mockExtensionReceiver("kotlin/String"),
|
||||||
mockExtensionReceiver("kotlin.Int")
|
mockExtensionReceiver("kotlin/Int")
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun nullAndNonNullReceivers1() = doTestFailure(
|
fun nullAndNonNullReceivers1() = doTestFailure(
|
||||||
mockExtensionReceiver("kotlin.String"),
|
mockExtensionReceiver("kotlin/String"),
|
||||||
mockExtensionReceiver("kotlin.String"),
|
mockExtensionReceiver("kotlin/String"),
|
||||||
null
|
null
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -46,13 +45,13 @@ class ExtensionReceiverCommonizerTest : AbstractCommonizerTest<CirExtensionRecei
|
|||||||
fun nullAndNonNullReceivers2() = doTestFailure(
|
fun nullAndNonNullReceivers2() = doTestFailure(
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
mockExtensionReceiver("kotlin.String")
|
mockExtensionReceiver("kotlin/String")
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun createCommonizer() = ExtensionReceiverCommonizer(MOCK_CLASSIFIERS)
|
override fun createCommonizer() = ExtensionReceiverCommonizer(MOCK_CLASSIFIERS)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun mockExtensionReceiver(typeFqName: String) = CirExtensionReceiverFactory.create(
|
private fun mockExtensionReceiver(receiverClassId: String) = CirExtensionReceiverFactory.create(
|
||||||
annotations = emptyList(),
|
annotations = emptyList(),
|
||||||
type = CirTypeFactory.create(mockClassType(typeFqName))
|
type = mockClassType(receiverClassId)
|
||||||
)
|
)
|
||||||
|
|||||||
+218
-217
@@ -5,21 +5,15 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.descriptors.commonizer.core
|
package org.jetbrains.kotlin.descriptors.commonizer.core
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.*
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirEntityId
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirType
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirClassFactory
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirClassFactory
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirTypeAliasFactory
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirTypeAliasFactory
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirTypeFactory
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.*
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.*
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.classifierId
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.isUnderStandardKotlinPackages
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.isUnderStandardKotlinPackages
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.mockClassType
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.mockClassType
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.mockTAType
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.mockTAType
|
||||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
|
||||||
import org.jetbrains.kotlin.types.getAbbreviation
|
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
@@ -42,222 +36,222 @@ class TypeCommonizerTest : AbstractCommonizerTest<CirType, CirType>() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun classTypesInKotlinPackageWithSameName() = doTestSuccess(
|
fun classTypesInKotlinPackageWithSameName() = doTestSuccess(
|
||||||
expected = mockClassType("kotlin.collections.List"),
|
expected = mockClassType("kotlin/collections/List"),
|
||||||
mockClassType("kotlin.collections.List"),
|
mockClassType("kotlin/collections/List"),
|
||||||
mockClassType("kotlin.collections.List"),
|
mockClassType("kotlin/collections/List"),
|
||||||
mockClassType("kotlin.collections.List")
|
mockClassType("kotlin/collections/List")
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun classTypesInKotlinPackageWithDifferentNames1() = doTestFailure(
|
fun classTypesInKotlinPackageWithDifferentNames1() = doTestFailure(
|
||||||
mockClassType("kotlin.collections.List"),
|
mockClassType("kotlin/collections/List"),
|
||||||
mockClassType("kotlin.collections.List"),
|
mockClassType("kotlin/collections/List"),
|
||||||
mockClassType("kotlin.fictitiousPackageName.List")
|
mockClassType("kotlin/fictitiousPackageName/List")
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun classTypesInKotlinPackageWithDifferentNames2() = doTestFailure(
|
fun classTypesInKotlinPackageWithDifferentNames2() = doTestFailure(
|
||||||
mockClassType("kotlin.collections.List"),
|
mockClassType("kotlin/collections/List"),
|
||||||
mockClassType("kotlin.collections.List"),
|
mockClassType("kotlin/collections/List"),
|
||||||
mockClassType("kotlin.collections.Set")
|
mockClassType("kotlin/collections/Set")
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun classTypesInKotlinPackageWithDifferentNames3() = doTestFailure(
|
fun classTypesInKotlinPackageWithDifferentNames3() = doTestFailure(
|
||||||
mockClassType("kotlin.collections.List"),
|
mockClassType("kotlin/collections/List"),
|
||||||
mockClassType("kotlin.collections.List"),
|
mockClassType("kotlin/collections/List"),
|
||||||
mockClassType("org.sample.Foo")
|
mockClassType("org/sample/Foo")
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun classTypesInKotlinxPackageWithSameName() = doTestSuccess(
|
fun classTypesInKotlinxPackageWithSameName() = doTestSuccess(
|
||||||
expected = mockClassType("kotlinx.cinterop.CPointer"),
|
expected = mockClassType("kotlinx/cinterop/CPointer"),
|
||||||
mockClassType("kotlinx.cinterop.CPointer"),
|
mockClassType("kotlinx/cinterop/CPointer"),
|
||||||
mockClassType("kotlinx.cinterop.CPointer"),
|
mockClassType("kotlinx/cinterop/CPointer"),
|
||||||
mockClassType("kotlinx.cinterop.CPointer")
|
mockClassType("kotlinx/cinterop/CPointer")
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun classTypesInKotlinxPackageWithDifferentNames1() = doTestFailure(
|
fun classTypesInKotlinxPackageWithDifferentNames1() = doTestFailure(
|
||||||
mockClassType("kotlinx.cinterop.CPointer"),
|
mockClassType("kotlinx/cinterop/CPointer"),
|
||||||
mockClassType("kotlinx.cinterop.CPointer"),
|
mockClassType("kotlinx/cinterop/CPointer"),
|
||||||
mockClassType("kotlinx.fictitiousPackageName.CPointer")
|
mockClassType("kotlinx/fictitiousPackageName/CPointer")
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun classTypesInKotlinxPackageWithDifferentNames2() = doTestFailure(
|
fun classTypesInKotlinxPackageWithDifferentNames2() = doTestFailure(
|
||||||
mockClassType("kotlinx.cinterop.CPointer"),
|
mockClassType("kotlinx/cinterop/CPointer"),
|
||||||
mockClassType("kotlinx.cinterop.CPointer"),
|
mockClassType("kotlinx/cinterop/CPointer"),
|
||||||
mockClassType("kotlinx.cinterop.ObjCObject")
|
mockClassType("kotlinx/cinterop/ObjCObject")
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun classTypesInKotlinxPackageWithDifferentNames3() = doTestFailure(
|
fun classTypesInKotlinxPackageWithDifferentNames3() = doTestFailure(
|
||||||
mockClassType("kotlinx.cinterop.CPointer"),
|
mockClassType("kotlinx/cinterop/CPointer"),
|
||||||
mockClassType("kotlinx.cinterop.CPointer"),
|
mockClassType("kotlinx/cinterop/CPointer"),
|
||||||
mockClassType("org.sample.Foo")
|
mockClassType("org/sample/Foo")
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun classTypesInUserPackageWithSameName() = doTestSuccess(
|
fun classTypesInUserPackageWithSameName() = doTestSuccess(
|
||||||
expected = mockClassType("org.sample.Foo"),
|
expected = mockClassType("org/sample/Foo"),
|
||||||
mockClassType("org.sample.Foo"),
|
mockClassType("org/sample/Foo"),
|
||||||
mockClassType("org.sample.Foo"),
|
mockClassType("org/sample/Foo"),
|
||||||
mockClassType("org.sample.Foo")
|
mockClassType("org/sample/Foo")
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun classTypesInUserPackageWithDifferentNames1() = doTestFailure(
|
fun classTypesInUserPackageWithDifferentNames1() = doTestFailure(
|
||||||
mockClassType("org.sample.Foo"),
|
mockClassType("org/sample/Foo"),
|
||||||
mockClassType("org.fictitiousPackageName.Foo"),
|
mockClassType("org/fictitiousPackageName/Foo"),
|
||||||
shouldFailOnFirstVariant = true
|
shouldFailOnFirstVariant = true
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun classTypesInUserPackageWithDifferentNames2() = doTestFailure(
|
fun classTypesInUserPackageWithDifferentNames2() = doTestFailure(
|
||||||
mockClassType("org.sample.Foo"),
|
mockClassType("org/sample/Foo"),
|
||||||
mockClassType("org.sample.Bar"),
|
mockClassType("org/sample/Bar"),
|
||||||
shouldFailOnFirstVariant = true
|
shouldFailOnFirstVariant = true
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun classTypesInUserPackageWithDifferentNames3() = doTestFailure(
|
fun classTypesInUserPackageWithDifferentNames3() = doTestFailure(
|
||||||
mockClassType("org.sample.Foo"),
|
mockClassType("org/sample/Foo"),
|
||||||
mockClassType("kotlin.String"),
|
mockClassType("kotlin/String"),
|
||||||
shouldFailOnFirstVariant = true
|
shouldFailOnFirstVariant = true
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun classTypesInKotlinPackageWithSameNullability1() = doTestSuccess(
|
fun classTypesInKotlinPackageWithSameNullability1() = doTestSuccess(
|
||||||
expected = mockClassType("kotlin.collections.List", nullable = false),
|
expected = mockClassType("kotlin/collections/List", nullable = false),
|
||||||
mockClassType("kotlin.collections.List", nullable = false),
|
mockClassType("kotlin/collections/List", nullable = false),
|
||||||
mockClassType("kotlin.collections.List", nullable = false),
|
mockClassType("kotlin/collections/List", nullable = false),
|
||||||
mockClassType("kotlin.collections.List", nullable = false)
|
mockClassType("kotlin/collections/List", nullable = false)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun classTypesInKotlinPackageWithSameNullability2() = doTestSuccess(
|
fun classTypesInKotlinPackageWithSameNullability2() = doTestSuccess(
|
||||||
expected = mockClassType("kotlin.collections.List", nullable = true),
|
expected = mockClassType("kotlin/collections/List", nullable = true),
|
||||||
mockClassType("kotlin.collections.List", nullable = true),
|
mockClassType("kotlin/collections/List", nullable = true),
|
||||||
mockClassType("kotlin.collections.List", nullable = true),
|
mockClassType("kotlin/collections/List", nullable = true),
|
||||||
mockClassType("kotlin.collections.List", nullable = true)
|
mockClassType("kotlin/collections/List", nullable = true)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun classTypesInKotlinPackageWithDifferentNullability1() = doTestFailure(
|
fun classTypesInKotlinPackageWithDifferentNullability1() = doTestFailure(
|
||||||
mockClassType("kotlin.collections.List", nullable = false),
|
mockClassType("kotlin/collections/List", nullable = false),
|
||||||
mockClassType("kotlin.collections.List", nullable = false),
|
mockClassType("kotlin/collections/List", nullable = false),
|
||||||
mockClassType("kotlin.collections.List", nullable = true)
|
mockClassType("kotlin/collections/List", nullable = true)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun classTypesInKotlinPackageWithDifferentNullability2() = doTestFailure(
|
fun classTypesInKotlinPackageWithDifferentNullability2() = doTestFailure(
|
||||||
mockClassType("kotlin.collections.List", nullable = true),
|
mockClassType("kotlin/collections/List", nullable = true),
|
||||||
mockClassType("kotlin.collections.List", nullable = true),
|
mockClassType("kotlin/collections/List", nullable = true),
|
||||||
mockClassType("kotlin.collections.List", nullable = false)
|
mockClassType("kotlin/collections/List", nullable = false)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun classTypesInUserPackageWithSameNullability1() = doTestSuccess(
|
fun classTypesInUserPackageWithSameNullability1() = doTestSuccess(
|
||||||
expected = mockClassType("org.sample.Foo", nullable = false),
|
expected = mockClassType("org/sample/Foo", nullable = false),
|
||||||
mockClassType("org.sample.Foo", nullable = false),
|
mockClassType("org/sample/Foo", nullable = false),
|
||||||
mockClassType("org.sample.Foo", nullable = false),
|
mockClassType("org/sample/Foo", nullable = false),
|
||||||
mockClassType("org.sample.Foo", nullable = false)
|
mockClassType("org/sample/Foo", nullable = false)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun classTypesInUserPackageWithSameNullability2() = doTestSuccess(
|
fun classTypesInUserPackageWithSameNullability2() = doTestSuccess(
|
||||||
expected = mockClassType("org.sample.Foo", nullable = true),
|
expected = mockClassType("org/sample/Foo", nullable = true),
|
||||||
mockClassType("org.sample.Foo", nullable = true),
|
mockClassType("org/sample/Foo", nullable = true),
|
||||||
mockClassType("org.sample.Foo", nullable = true),
|
mockClassType("org/sample/Foo", nullable = true),
|
||||||
mockClassType("org.sample.Foo", nullable = true)
|
mockClassType("org/sample/Foo", nullable = true)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun classTypesInUserPackageWithDifferentNullability1() = doTestFailure(
|
fun classTypesInUserPackageWithDifferentNullability1() = doTestFailure(
|
||||||
mockClassType("org.sample.Foo", nullable = false),
|
mockClassType("org/sample/Foo", nullable = false),
|
||||||
mockClassType("org.sample.Foo", nullable = false),
|
mockClassType("org/sample/Foo", nullable = false),
|
||||||
mockClassType("org.sample.Foo", nullable = true)
|
mockClassType("org/sample/Foo", nullable = true)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun classTypesInUserPackageWithDifferentNullability2() = doTestFailure(
|
fun classTypesInUserPackageWithDifferentNullability2() = doTestFailure(
|
||||||
mockClassType("org.sample.Foo", nullable = true),
|
mockClassType("org/sample/Foo", nullable = true),
|
||||||
mockClassType("org.sample.Foo", nullable = true),
|
mockClassType("org/sample/Foo", nullable = true),
|
||||||
mockClassType("org.sample.Foo", nullable = false)
|
mockClassType("org/sample/Foo", nullable = false)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// why success: matching FQNs from the standard Kotlin packages
|
// why success: matching FQNs from the standard Kotlin packages
|
||||||
fun taTypesInKotlinPackageWithSameNameAndClass() = doTestSuccess(
|
fun taTypesInKotlinPackageWithSameNameAndClass() = doTestSuccess(
|
||||||
expected = mockTAType("kotlin.sequences.SequenceBuilder") { mockClassType("kotlin.sequences.SequenceScope") },
|
expected = mockTAType("kotlin/sequences/SequenceBuilder") { mockClassType("kotlin/sequences/SequenceScope") },
|
||||||
mockTAType("kotlin.sequences.SequenceBuilder") { mockClassType("kotlin.sequences.SequenceScope") },
|
mockTAType("kotlin/sequences/SequenceBuilder") { mockClassType("kotlin/sequences/SequenceScope") },
|
||||||
mockTAType("kotlin.sequences.SequenceBuilder") { mockClassType("kotlin.sequences.SequenceScope") },
|
mockTAType("kotlin/sequences/SequenceBuilder") { mockClassType("kotlin/sequences/SequenceScope") },
|
||||||
mockTAType("kotlin.sequences.SequenceBuilder") { mockClassType("kotlin.sequences.SequenceScope") }
|
mockTAType("kotlin/sequences/SequenceBuilder") { mockClassType("kotlin/sequences/SequenceScope") }
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun taTypesInKotlinPackageWithDifferentNames() = doTestFailure(
|
fun taTypesInKotlinPackageWithDifferentNames() = doTestFailure(
|
||||||
mockTAType("kotlin.sequences.SequenceBuilder") { mockClassType("kotlin.sequences.SequenceScope") },
|
mockTAType("kotlin/sequences/SequenceBuilder") { mockClassType("kotlin/sequences/SequenceScope") },
|
||||||
mockTAType("kotlin.sequences.SequenceBuilder") { mockClassType("kotlin.sequences.SequenceScope") },
|
mockTAType("kotlin/sequences/SequenceBuilder") { mockClassType("kotlin/sequences/SequenceScope") },
|
||||||
mockTAType("kotlin.sequences.FictitiousTypeAlias") { mockClassType("kotlin.sequences.SequenceScope") }
|
mockTAType("kotlin/sequences/FictitiousTypeAlias") { mockClassType("kotlin/sequences/SequenceScope") }
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// why success: matching FQNs from the standard Kotlin packages
|
// why success: matching FQNs from the standard Kotlin packages
|
||||||
fun taTypesInKotlinPackageWithDifferentClasses() = doTestSuccess(
|
fun taTypesInKotlinPackageWithDifferentClasses() = doTestSuccess(
|
||||||
expected = mockTAType("kotlin.sequences.SequenceBuilder") { mockClassType("kotlin.sequences.SequenceScope") },
|
expected = mockTAType("kotlin/sequences/SequenceBuilder") { mockClassType("kotlin/sequences/SequenceScope") },
|
||||||
mockTAType("kotlin.sequences.SequenceBuilder") { mockClassType("kotlin.sequences.SequenceScope") },
|
mockTAType("kotlin/sequences/SequenceBuilder") { mockClassType("kotlin/sequences/SequenceScope") },
|
||||||
mockTAType("kotlin.sequences.SequenceBuilder") { mockClassType("kotlin.sequences.SequenceScope") },
|
mockTAType("kotlin/sequences/SequenceBuilder") { mockClassType("kotlin/sequences/SequenceScope") },
|
||||||
mockTAType("kotlin.sequences.SequenceBuilder") { mockClassType("kotlin.sequences.FictitiousClass") }
|
mockTAType("kotlin/sequences/SequenceBuilder") { mockClassType("kotlin/sequences/FictitiousClass") }
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// why success: matching FQNs from the standard Kotlin packages
|
// why success: matching FQNs from the standard Kotlin packages
|
||||||
fun taTypesInKotlinxPackageWithSameNameAndClass() = doTestSuccess(
|
fun taTypesInKotlinxPackageWithSameNameAndClass() = doTestSuccess(
|
||||||
expected = mockTAType("kotlinx.cinterop.CArrayPointer") { mockClassType("kotlinx.cinterop.CPointer") },
|
expected = mockTAType("kotlinx/cinterop/CArrayPointer") { mockClassType("kotlinx/cinterop/CPointer") },
|
||||||
mockTAType("kotlinx.cinterop.CArrayPointer") { mockClassType("kotlinx.cinterop.CPointer") },
|
mockTAType("kotlinx/cinterop/CArrayPointer") { mockClassType("kotlinx/cinterop/CPointer") },
|
||||||
mockTAType("kotlinx.cinterop.CArrayPointer") { mockClassType("kotlinx.cinterop.CPointer") },
|
mockTAType("kotlinx/cinterop/CArrayPointer") { mockClassType("kotlinx/cinterop/CPointer") },
|
||||||
mockTAType("kotlinx.cinterop.CArrayPointer") { mockClassType("kotlinx.cinterop.CPointer") }
|
mockTAType("kotlinx/cinterop/CArrayPointer") { mockClassType("kotlinx/cinterop/CPointer") }
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun taTypesInKotlinxPackageWithDifferentNames() = doTestFailure(
|
fun taTypesInKotlinxPackageWithDifferentNames() = doTestFailure(
|
||||||
mockTAType("kotlinx.cinterop.CArrayPointer") { mockClassType("kotlinx.cinterop.CPointer") },
|
mockTAType("kotlinx/cinterop/CArrayPointer") { mockClassType("kotlinx/cinterop/CPointer") },
|
||||||
mockTAType("kotlinx.cinterop.CArrayPointer") { mockClassType("kotlinx.cinterop.CPointer") },
|
mockTAType("kotlinx/cinterop/CArrayPointer") { mockClassType("kotlinx/cinterop/CPointer") },
|
||||||
mockTAType("kotlinx.cinterop.FictitiousTypeAlias") { mockClassType("kotlinx.cinterop.CPointer") }
|
mockTAType("kotlinx/cinterop/FictitiousTypeAlias") { mockClassType("kotlinx/cinterop/CPointer") }
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// why success: matching FQNs from the standard Kotlin packages
|
// why success: matching FQNs from the standard Kotlin packages
|
||||||
fun taTypesInKotlinxPackageWithDifferentClasses() = doTestSuccess(
|
fun taTypesInKotlinxPackageWithDifferentClasses() = doTestSuccess(
|
||||||
expected = mockTAType("kotlinx.cinterop.CArrayPointer") { mockClassType("kotlinx.cinterop.CPointer") },
|
expected = mockTAType("kotlinx/cinterop/CArrayPointer") { mockClassType("kotlinx/cinterop/CPointer") },
|
||||||
mockTAType("kotlinx.cinterop.CArrayPointer") { mockClassType("kotlinx.cinterop.CPointer") },
|
mockTAType("kotlinx/cinterop/CArrayPointer") { mockClassType("kotlinx/cinterop/CPointer") },
|
||||||
mockTAType("kotlinx.cinterop.CArrayPointer") { mockClassType("kotlinx.cinterop.CPointer") },
|
mockTAType("kotlinx/cinterop/CArrayPointer") { mockClassType("kotlinx/cinterop/CPointer") },
|
||||||
mockTAType("kotlinx.cinterop.CArrayPointer") { mockClassType("kotlinx.cinterop.FictitiousClass") }
|
mockTAType("kotlinx/cinterop/CArrayPointer") { mockClassType("kotlinx/cinterop/FictitiousClass") }
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// why success: matching FQNs from the standard Kotlin packages
|
// why success: matching FQNs from the standard Kotlin packages
|
||||||
fun multilevelTATypesInKotlinPackageWithSameNameAndRightHandSideClass() = doTestSuccess(
|
fun multilevelTATypesInKotlinPackageWithSameNameAndRightHandSideClass() = doTestSuccess(
|
||||||
expected = mockTAType("kotlin.FictitiousTypeAlias") {
|
expected = mockTAType("kotlin/FictitiousTypeAlias") {
|
||||||
mockClassType("kotlin.FictitiousClass")
|
mockClassType("kotlin/FictitiousClass")
|
||||||
},
|
},
|
||||||
|
|
||||||
mockTAType("kotlin.FictitiousTypeAlias") {
|
mockTAType("kotlin/FictitiousTypeAlias") {
|
||||||
mockClassType("kotlin.FictitiousClass")
|
mockClassType("kotlin/FictitiousClass")
|
||||||
},
|
},
|
||||||
|
|
||||||
mockTAType("kotlin.FictitiousTypeAlias") {
|
mockTAType("kotlin/FictitiousTypeAlias") {
|
||||||
mockTAType("kotlin.FictitiousTypeAliasL2") {
|
mockTAType("kotlin/FictitiousTypeAliasL2") {
|
||||||
mockClassType("kotlin.FictitiousClass")
|
mockClassType("kotlin/FictitiousClass")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
mockTAType("kotlin.FictitiousTypeAlias") {
|
mockTAType("kotlin/FictitiousTypeAlias") {
|
||||||
mockTAType("kotlin.FictitiousTypeAliasL2") {
|
mockTAType("kotlin/FictitiousTypeAliasL2") {
|
||||||
mockTAType("kotlin.FictitiousTypeAliasL3") {
|
mockTAType("kotlin/FictitiousTypeAliasL3") {
|
||||||
mockClassType("kotlin.FictitiousClass")
|
mockClassType("kotlin/FictitiousClass")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -266,41 +260,41 @@ class TypeCommonizerTest : AbstractCommonizerTest<CirType, CirType>() {
|
|||||||
@Test
|
@Test
|
||||||
// why success: lifting up
|
// why success: lifting up
|
||||||
fun taTypesInUserPackageWithSameNameAndClass() = doTestSuccess(
|
fun taTypesInUserPackageWithSameNameAndClass() = doTestSuccess(
|
||||||
expected = mockTAType("org.sample.FooAlias") { mockClassType("org.sample.Foo") },
|
expected = mockTAType("org/sample/FooAlias") { mockClassType("org/sample/Foo") },
|
||||||
mockTAType("org.sample.FooAlias") { mockClassType("org.sample.Foo") },
|
mockTAType("org/sample/FooAlias") { mockClassType("org/sample/Foo") },
|
||||||
mockTAType("org.sample.FooAlias") { mockClassType("org.sample.Foo") },
|
mockTAType("org/sample/FooAlias") { mockClassType("org/sample/Foo") },
|
||||||
mockTAType("org.sample.FooAlias") { mockClassType("org.sample.Foo") }
|
mockTAType("org/sample/FooAlias") { mockClassType("org/sample/Foo") }
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun taTypesInUserPackageWithDifferentNames() = doTestFailure(
|
fun taTypesInUserPackageWithDifferentNames() = doTestFailure(
|
||||||
mockTAType("org.sample.FooAlias") { mockClassType("org.sample.Foo") },
|
mockTAType("org/sample/FooAlias") { mockClassType("org/sample/Foo") },
|
||||||
mockTAType("org.sample.BarAlias") { mockClassType("org.sample.Foo") },
|
mockTAType("org/sample/BarAlias") { mockClassType("org/sample/Foo") },
|
||||||
shouldFailOnFirstVariant = true
|
shouldFailOnFirstVariant = true
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// why success: expect class/actual TAs
|
// why success: expect class/actual TAs
|
||||||
fun taTypesInUserPackageWithDifferentClasses() = doTestSuccess(
|
fun taTypesInUserPackageWithDifferentClasses() = doTestSuccess(
|
||||||
expected = mockClassType("org.sample.FooAlias"),
|
expected = mockClassType("org/sample/FooAlias"),
|
||||||
mockTAType("org.sample.FooAlias") { mockClassType("org.sample.Foo") },
|
mockTAType("org/sample/FooAlias") { mockClassType("org/sample/Foo") },
|
||||||
mockTAType("org.sample.FooAlias") { mockClassType("org.sample.Bar") }
|
mockTAType("org/sample/FooAlias") { mockClassType("org/sample/Bar") }
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// why success: short-circuiting & lifting up
|
// why success: short-circuiting & lifting up
|
||||||
fun multilevelTATypesInUserPackageWithSameNameAndRightHandSideClass1() = doTestSuccess(
|
fun multilevelTATypesInUserPackageWithSameNameAndRightHandSideClass1() = doTestSuccess(
|
||||||
expected = mockTAType("org.sample.FooAlias") {
|
expected = mockTAType("org/sample/FooAlias") {
|
||||||
mockClassType("org.sample.Foo")
|
mockClassType("org/sample/Foo")
|
||||||
},
|
},
|
||||||
|
|
||||||
mockTAType("org.sample.FooAlias") {
|
mockTAType("org/sample/FooAlias") {
|
||||||
mockClassType("org.sample.Foo")
|
mockClassType("org/sample/Foo")
|
||||||
},
|
},
|
||||||
|
|
||||||
mockTAType("org.sample.FooAlias") {
|
mockTAType("org/sample/FooAlias") {
|
||||||
mockTAType("org.sample.FooAliasL2") {
|
mockTAType("org/sample/FooAliasL2") {
|
||||||
mockClassType("org.sample.Foo")
|
mockClassType("org/sample/Foo")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -308,39 +302,39 @@ class TypeCommonizerTest : AbstractCommonizerTest<CirType, CirType>() {
|
|||||||
@Test
|
@Test
|
||||||
// why success: short-circuiting & lifting up
|
// why success: short-circuiting & lifting up
|
||||||
fun multilevelTATypesInUserPackageWithSameNameAndRightHandSideClass2() = doTestSuccess(
|
fun multilevelTATypesInUserPackageWithSameNameAndRightHandSideClass2() = doTestSuccess(
|
||||||
expected = mockTAType("org.sample.FooAlias") {
|
expected = mockTAType("org/sample/FooAlias") {
|
||||||
mockClassType("org.sample.Foo")
|
mockClassType("org/sample/Foo")
|
||||||
},
|
},
|
||||||
|
|
||||||
mockTAType("org.sample.FooAlias") {
|
mockTAType("org/sample/FooAlias") {
|
||||||
mockTAType("org.sample.FooAliasL2") {
|
mockTAType("org/sample/FooAliasL2") {
|
||||||
mockClassType("org.sample.Foo")
|
mockClassType("org/sample/Foo")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
mockTAType("org.sample.FooAlias") {
|
mockTAType("org/sample/FooAlias") {
|
||||||
mockClassType("org.sample.Foo")
|
mockClassType("org/sample/Foo")
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// why success: lifting up (inner and outer TAs)
|
// why success: lifting up (inner and outer TAs)
|
||||||
fun multilevelTATypesInUserPackageWithSameNameAndRightHandSideClass3() = doTestSuccess(
|
fun multilevelTATypesInUserPackageWithSameNameAndRightHandSideClass3() = doTestSuccess(
|
||||||
expected = mockTAType("org.sample.FooAlias") {
|
expected = mockTAType("org/sample/FooAlias") {
|
||||||
mockTAType("org.sample.FooAliasL2") {
|
mockTAType("org/sample/FooAliasL2") {
|
||||||
mockClassType("org.sample.Foo")
|
mockClassType("org/sample/Foo")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
mockTAType("org.sample.FooAlias") {
|
mockTAType("org/sample/FooAlias") {
|
||||||
mockTAType("org.sample.FooAliasL2") {
|
mockTAType("org/sample/FooAliasL2") {
|
||||||
mockClassType("org.sample.Foo")
|
mockClassType("org/sample/Foo")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
mockTAType("org.sample.FooAlias") {
|
mockTAType("org/sample/FooAlias") {
|
||||||
mockTAType("org.sample.FooAliasL2") {
|
mockTAType("org/sample/FooAliasL2") {
|
||||||
mockClassType("org.sample.Foo")
|
mockClassType("org/sample/Foo")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -348,21 +342,21 @@ class TypeCommonizerTest : AbstractCommonizerTest<CirType, CirType>() {
|
|||||||
@Test
|
@Test
|
||||||
// why success: lifting up outer TA and expect class for inner TA
|
// why success: lifting up outer TA and expect class for inner TA
|
||||||
fun multilevelTATypesInUserPackageWithSameNameAndRightHandSideClass4() = doTestSuccess(
|
fun multilevelTATypesInUserPackageWithSameNameAndRightHandSideClass4() = doTestSuccess(
|
||||||
expected = mockTAType("org.sample.FooAlias") {
|
expected = mockTAType("org/sample/FooAlias") {
|
||||||
mockTAType("org.sample.FooAliasL2") {
|
mockTAType("org/sample/FooAliasL2") {
|
||||||
mockClassType("org.sample.Foo")
|
mockClassType("org/sample/Foo")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
mockTAType("org.sample.FooAlias") {
|
mockTAType("org/sample/FooAlias") {
|
||||||
mockTAType("org.sample.FooAliasL2") {
|
mockTAType("org/sample/FooAliasL2") {
|
||||||
mockClassType("org.sample.Bar")
|
mockClassType("org/sample/Bar")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
mockTAType("org.sample.FooAlias") {
|
mockTAType("org/sample/FooAlias") {
|
||||||
mockTAType("org.sample.FooAliasL2") {
|
mockTAType("org/sample/FooAliasL2") {
|
||||||
mockClassType("org.sample.Baz")
|
mockClassType("org/sample/Baz")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -370,136 +364,151 @@ class TypeCommonizerTest : AbstractCommonizerTest<CirType, CirType>() {
|
|||||||
@Test
|
@Test
|
||||||
// why success: types with the same nullability are treated as equal
|
// why success: types with the same nullability are treated as equal
|
||||||
fun taTypesInKotlinPackageWithSameNullability1() = doTestSuccess(
|
fun taTypesInKotlinPackageWithSameNullability1() = doTestSuccess(
|
||||||
expected = mockTAType("kotlin.sequences.SequenceBuilder", nullable = false) { mockClassType("kotlin.sequences.SequenceScope") },
|
expected = mockTAType("kotlin/sequences/SequenceBuilder", nullable = false) { mockClassType("kotlin/sequences/SequenceScope") },
|
||||||
mockTAType("kotlin.sequences.SequenceBuilder", nullable = false) { mockClassType("kotlin.sequences.SequenceScope") },
|
mockTAType("kotlin/sequences/SequenceBuilder", nullable = false) { mockClassType("kotlin/sequences/SequenceScope") },
|
||||||
mockTAType("kotlin.sequences.SequenceBuilder", nullable = false) { mockClassType("kotlin.sequences.SequenceScope") },
|
mockTAType("kotlin/sequences/SequenceBuilder", nullable = false) { mockClassType("kotlin/sequences/SequenceScope") },
|
||||||
mockTAType("kotlin.sequences.SequenceBuilder", nullable = false) { mockClassType("kotlin.sequences.SequenceScope") }
|
mockTAType("kotlin/sequences/SequenceBuilder", nullable = false) { mockClassType("kotlin/sequences/SequenceScope") }
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// why success: types with the same nullability are treated as equal
|
// why success: types with the same nullability are treated as equal
|
||||||
fun taTypesInKotlinPackageWithSameNullability2() = doTestSuccess(
|
fun taTypesInKotlinPackageWithSameNullability2() = doTestSuccess(
|
||||||
expected = mockTAType("kotlin.sequences.SequenceBuilder", nullable = true) { mockClassType("kotlin.sequences.SequenceScope") },
|
expected = mockTAType("kotlin/sequences/SequenceBuilder", nullable = true) { mockClassType("kotlin/sequences/SequenceScope") },
|
||||||
mockTAType("kotlin.sequences.SequenceBuilder", nullable = true) { mockClassType("kotlin.sequences.SequenceScope") },
|
mockTAType("kotlin/sequences/SequenceBuilder", nullable = true) { mockClassType("kotlin/sequences/SequenceScope") },
|
||||||
mockTAType("kotlin.sequences.SequenceBuilder", nullable = true) { mockClassType("kotlin.sequences.SequenceScope") },
|
mockTAType("kotlin/sequences/SequenceBuilder", nullable = true) { mockClassType("kotlin/sequences/SequenceScope") },
|
||||||
mockTAType("kotlin.sequences.SequenceBuilder", nullable = true) { mockClassType("kotlin.sequences.SequenceScope") }
|
mockTAType("kotlin/sequences/SequenceBuilder", nullable = true) { mockClassType("kotlin/sequences/SequenceScope") }
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun taTypesInKotlinPackageWithDifferentNullability1() = doTestFailure(
|
fun taTypesInKotlinPackageWithDifferentNullability1() = doTestFailure(
|
||||||
mockTAType("kotlin.sequences.SequenceBuilder", nullable = false) { mockClassType("kotlin.sequences.SequenceScope") },
|
mockTAType("kotlin/sequences/SequenceBuilder", nullable = false) { mockClassType("kotlin/sequences/SequenceScope") },
|
||||||
mockTAType("kotlin.sequences.SequenceBuilder", nullable = false) { mockClassType("kotlin.sequences.SequenceScope") },
|
mockTAType("kotlin/sequences/SequenceBuilder", nullable = false) { mockClassType("kotlin/sequences/SequenceScope") },
|
||||||
mockTAType("kotlin.sequences.SequenceBuilder", nullable = true) { mockClassType("kotlin.sequences.SequenceScope") }
|
mockTAType("kotlin/sequences/SequenceBuilder", nullable = true) { mockClassType("kotlin/sequences/SequenceScope") }
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun taTypesInKotlinPackageWithDifferentNullability2() = doTestFailure(
|
fun taTypesInKotlinPackageWithDifferentNullability2() = doTestFailure(
|
||||||
mockTAType("kotlin.sequences.SequenceBuilder", nullable = true) { mockClassType("kotlin.sequences.SequenceScope") },
|
mockTAType("kotlin/sequences/SequenceBuilder", nullable = true) { mockClassType("kotlin/sequences/SequenceScope") },
|
||||||
mockTAType("kotlin.sequences.SequenceBuilder", nullable = true) { mockClassType("kotlin.sequences.SequenceScope") },
|
mockTAType("kotlin/sequences/SequenceBuilder", nullable = true) { mockClassType("kotlin/sequences/SequenceScope") },
|
||||||
mockTAType("kotlin.sequences.SequenceBuilder", nullable = false) { mockClassType("kotlin.sequences.SequenceScope") }
|
mockTAType("kotlin/sequences/SequenceBuilder", nullable = false) { mockClassType("kotlin/sequences/SequenceScope") }
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// why success: nullability of underlying type does not matter if typealias belongs to one of the standard Kotlin packages
|
// why success: nullability of underlying type does not matter if typealias belongs to one of the standard Kotlin packages
|
||||||
fun taTypesInKotlinPackageWithDifferentNullability3() = doTestSuccess(
|
fun taTypesInKotlinPackageWithDifferentNullability3() = doTestSuccess(
|
||||||
expected = mockTAType("kotlin.sequences.SequenceBuilder") { mockClassType("kotlin.sequences.SequenceScope", nullable = false) },
|
expected = mockTAType("kotlin/sequences/SequenceBuilder") { mockClassType("kotlin/sequences/SequenceScope", nullable = false) },
|
||||||
mockTAType("kotlin.sequences.SequenceBuilder") { mockClassType("kotlin.sequences.SequenceScope", nullable = false) },
|
mockTAType("kotlin/sequences/SequenceBuilder") { mockClassType("kotlin/sequences/SequenceScope", nullable = false) },
|
||||||
mockTAType("kotlin.sequences.SequenceBuilder") { mockClassType("kotlin.sequences.SequenceScope", nullable = false) },
|
mockTAType("kotlin/sequences/SequenceBuilder") { mockClassType("kotlin/sequences/SequenceScope", nullable = false) },
|
||||||
mockTAType("kotlin.sequences.SequenceBuilder") { mockClassType("kotlin.sequences.SequenceScope", nullable = true) }
|
mockTAType("kotlin/sequences/SequenceBuilder") { mockClassType("kotlin/sequences/SequenceScope", nullable = true) }
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// why success: nullability of underlying type does not matter if typealias belongs to one of the standard Kotlin packages
|
// why success: nullability of underlying type does not matter if typealias belongs to one of the standard Kotlin packages
|
||||||
fun taTypesInKotlinPackageWithDifferentNullability4() = doTestSuccess(
|
fun taTypesInKotlinPackageWithDifferentNullability4() = doTestSuccess(
|
||||||
expected = mockTAType("kotlin.sequences.SequenceBuilder") { mockClassType("kotlin.sequences.SequenceScope", nullable = true) },
|
expected = mockTAType("kotlin/sequences/SequenceBuilder") { mockClassType("kotlin/sequences/SequenceScope", nullable = true) },
|
||||||
mockTAType("kotlin.sequences.SequenceBuilder") { mockClassType("kotlin.sequences.SequenceScope", nullable = true) },
|
mockTAType("kotlin/sequences/SequenceBuilder") { mockClassType("kotlin/sequences/SequenceScope", nullable = true) },
|
||||||
mockTAType("kotlin.sequences.SequenceBuilder") { mockClassType("kotlin.sequences.SequenceScope", nullable = true) },
|
mockTAType("kotlin/sequences/SequenceBuilder") { mockClassType("kotlin/sequences/SequenceScope", nullable = true) },
|
||||||
mockTAType("kotlin.sequences.SequenceBuilder") { mockClassType("kotlin.sequences.SequenceScope", nullable = false) }
|
mockTAType("kotlin/sequences/SequenceBuilder") { mockClassType("kotlin/sequences/SequenceScope", nullable = false) }
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// why success: types with the same nullability are treated as equal
|
// why success: types with the same nullability are treated as equal
|
||||||
fun taTypesInUserPackageWithSameNullability1() = doTestSuccess(
|
fun taTypesInUserPackageWithSameNullability1() = doTestSuccess(
|
||||||
expected = mockTAType("org.sample.FooAlias", nullable = false) { mockClassType("org.sample.Foo") },
|
expected = mockTAType("org/sample/FooAlias", nullable = false) { mockClassType("org/sample/Foo") },
|
||||||
mockTAType("org.sample.FooAlias", nullable = false) { mockClassType("org.sample.Foo") },
|
mockTAType("org/sample/FooAlias", nullable = false) { mockClassType("org/sample/Foo") },
|
||||||
mockTAType("org.sample.FooAlias", nullable = false) { mockClassType("org.sample.Foo") },
|
mockTAType("org/sample/FooAlias", nullable = false) { mockClassType("org/sample/Foo") },
|
||||||
mockTAType("org.sample.FooAlias", nullable = false) { mockClassType("org.sample.Foo") }
|
mockTAType("org/sample/FooAlias", nullable = false) { mockClassType("org/sample/Foo") }
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// why success: types with the same nullability are treated as equal
|
// why success: types with the same nullability are treated as equal
|
||||||
fun taTypesInUserPackageWithSameNullability2() = doTestSuccess(
|
fun taTypesInUserPackageWithSameNullability2() = doTestSuccess(
|
||||||
expected = mockTAType("org.sample.FooAlias", nullable = true) { mockClassType("org.sample.Foo") },
|
expected = mockTAType("org/sample/FooAlias", nullable = true) { mockClassType("org/sample/Foo") },
|
||||||
mockTAType("org.sample.FooAlias", nullable = true) { mockClassType("org.sample.Foo") },
|
mockTAType("org/sample/FooAlias", nullable = true) { mockClassType("org/sample/Foo") },
|
||||||
mockTAType("org.sample.FooAlias", nullable = true) { mockClassType("org.sample.Foo") },
|
mockTAType("org/sample/FooAlias", nullable = true) { mockClassType("org/sample/Foo") },
|
||||||
mockTAType("org.sample.FooAlias", nullable = true) { mockClassType("org.sample.Foo") }
|
mockTAType("org/sample/FooAlias", nullable = true) { mockClassType("org/sample/Foo") }
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun taTypesInUserPackageWithDifferentNullability1() = doTestFailure(
|
fun taTypesInUserPackageWithDifferentNullability1() = doTestFailure(
|
||||||
mockTAType("org.sample.FooAlias", nullable = false) { mockClassType("org.sample.Foo") },
|
mockTAType("org/sample/FooAlias", nullable = false) { mockClassType("org/sample/Foo") },
|
||||||
mockTAType("org.sample.FooAlias", nullable = false) { mockClassType("org.sample.Foo") },
|
mockTAType("org/sample/FooAlias", nullable = false) { mockClassType("org/sample/Foo") },
|
||||||
mockTAType("org.sample.FooAlias", nullable = true) { mockClassType("org.sample.Foo") }
|
mockTAType("org/sample/FooAlias", nullable = true) { mockClassType("org/sample/Foo") }
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun taTypesInUserPackageWithDifferentNullability2() = doTestFailure(
|
fun taTypesInUserPackageWithDifferentNullability2() = doTestFailure(
|
||||||
mockTAType("org.sample.FooAlias", nullable = true) { mockClassType("org.sample.Foo") },
|
mockTAType("org/sample/FooAlias", nullable = true) { mockClassType("org/sample/Foo") },
|
||||||
mockTAType("org.sample.FooAlias", nullable = true) { mockClassType("org.sample.Foo") },
|
mockTAType("org/sample/FooAlias", nullable = true) { mockClassType("org/sample/Foo") },
|
||||||
mockTAType("org.sample.FooAlias", nullable = false) { mockClassType("org.sample.Foo") }
|
mockTAType("org/sample/FooAlias", nullable = false) { mockClassType("org/sample/Foo") }
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// why success: nullability of underlying type does not matter if expect class/actual TAs created
|
// why success: nullability of underlying type does not matter if expect class/actual TAs created
|
||||||
fun taTypesInUserPackageWithDifferentNullability3() = doTestSuccess(
|
fun taTypesInUserPackageWithDifferentNullability3() = doTestSuccess(
|
||||||
expected = mockClassType("org.sample.FooAlias"),
|
expected = mockClassType("org/sample/FooAlias"),
|
||||||
mockTAType("org.sample.FooAlias") { mockClassType("org.sample.Foo", nullable = false) },
|
mockTAType("org/sample/FooAlias") { mockClassType("org/sample/Foo", nullable = false) },
|
||||||
mockTAType("org.sample.FooAlias") { mockClassType("org.sample.Foo", nullable = true) }
|
mockTAType("org/sample/FooAlias") { mockClassType("org/sample/Foo", nullable = true) }
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// why success: nullability of underlying type does not matter if expect class/actual TAs created
|
// why success: nullability of underlying type does not matter if expect class/actual TAs created
|
||||||
fun taTypesInUserPackageWithDifferentNullability4() = doTestSuccess(
|
fun taTypesInUserPackageWithDifferentNullability4() = doTestSuccess(
|
||||||
expected = mockClassType("org.sample.FooAlias"),
|
expected = mockClassType("org/sample/FooAlias"),
|
||||||
mockTAType("org.sample.FooAlias") { mockClassType("org.sample.Foo", nullable = true) },
|
mockTAType("org/sample/FooAlias") { mockClassType("org/sample/Foo", nullable = true) },
|
||||||
mockTAType("org.sample.FooAlias") { mockClassType("org.sample.Foo", nullable = false) }
|
mockTAType("org/sample/FooAlias") { mockClassType("org/sample/Foo", nullable = false) }
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun prepareCache(variants: Array<out KotlinType>) {
|
private fun prepareCache(variants: Array<out CirClassOrTypeAliasType>) {
|
||||||
check(variants.isNotEmpty())
|
check(variants.isNotEmpty())
|
||||||
|
|
||||||
fun recurse(type: KotlinType, index: Int) {
|
fun recurse(type: CirClassOrTypeAliasType, index: Int) {
|
||||||
@Suppress("MoveVariableDeclarationIntoWhen")
|
when (type) {
|
||||||
val descriptor = (type.getAbbreviation() ?: type).constructor.declarationDescriptor
|
is CirClassType -> {
|
||||||
when (descriptor) {
|
val node = classifiers.classNode(type.classifierId) {
|
||||||
is ClassDescriptor -> {
|
|
||||||
val classId = descriptor.classifierId
|
|
||||||
val node = classifiers.classNode(classId) {
|
|
||||||
buildClassNode(
|
buildClassNode(
|
||||||
storageManager = LockBasedStorageManager.NO_LOCKS,
|
storageManager = LockBasedStorageManager.NO_LOCKS,
|
||||||
size = variants.size,
|
size = variants.size,
|
||||||
classifiers = classifiers,
|
classifiers = classifiers,
|
||||||
parentCommonDeclaration = null,
|
parentCommonDeclaration = null,
|
||||||
classId = classId
|
classId = type.classifierId
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
node.targetDeclarations[index] = CirClassFactory.create(descriptor)
|
node.targetDeclarations[index] = CirClassFactory.create(
|
||||||
|
annotations = emptyList(),
|
||||||
|
name = type.classifierId.relativeNameSegments.last(),
|
||||||
|
typeParameters = emptyList(),
|
||||||
|
visibility = DescriptorVisibilities.PUBLIC,
|
||||||
|
modality = Modality.FINAL,
|
||||||
|
kind = ClassKind.CLASS,
|
||||||
|
companion = null,
|
||||||
|
isCompanion = false,
|
||||||
|
isData = false,
|
||||||
|
isInline = false,
|
||||||
|
isInner = false,
|
||||||
|
isExternal = false
|
||||||
|
)
|
||||||
}
|
}
|
||||||
is TypeAliasDescriptor -> {
|
is CirTypeAliasType -> {
|
||||||
val typeAliasId = descriptor.classifierId
|
val node = classifiers.typeAliasNode(type.classifierId) {
|
||||||
val node = classifiers.typeAliasNode(typeAliasId) {
|
|
||||||
buildTypeAliasNode(
|
buildTypeAliasNode(
|
||||||
storageManager = LockBasedStorageManager.NO_LOCKS,
|
storageManager = LockBasedStorageManager.NO_LOCKS,
|
||||||
size = variants.size,
|
size = variants.size,
|
||||||
classifiers = classifiers,
|
classifiers = classifiers,
|
||||||
typeAliasId = typeAliasId
|
typeAliasId = type.classifierId
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
node.targetDeclarations[index] = CirTypeAliasFactory.create(descriptor)
|
node.targetDeclarations[index] = CirTypeAliasFactory.create(
|
||||||
|
annotations = emptyList(),
|
||||||
|
name = type.classifierId.relativeNameSegments.last(),
|
||||||
|
typeParameters = emptyList(),
|
||||||
|
visibility = DescriptorVisibilities.PUBLIC,
|
||||||
|
underlyingType = type.underlyingType,
|
||||||
|
expandedType = computeExpandedType(type.underlyingType)
|
||||||
|
)
|
||||||
|
|
||||||
recurse(descriptor.underlyingType, index) // expand underlying types recursively
|
recurse(type.underlyingType, index) // expand underlying types recursively
|
||||||
}
|
}
|
||||||
else -> error("Unexpected descriptor of KotlinType: $descriptor, $type")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -508,22 +517,14 @@ class TypeCommonizerTest : AbstractCommonizerTest<CirType, CirType>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun doTestSuccess(expected: KotlinType, vararg variants: KotlinType) {
|
fun doTestSuccess(expected: CirClassOrTypeAliasType, vararg variants: CirClassOrTypeAliasType) {
|
||||||
prepareCache(variants)
|
prepareCache(variants)
|
||||||
|
super.doTestSuccess(expected, *variants)
|
||||||
doTestSuccess(
|
|
||||||
expected = CirTypeFactory.create(expected),
|
|
||||||
variants = variants.map(CirTypeFactory::create).toTypedArray()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun doTestFailure(vararg variants: KotlinType, shouldFailOnFirstVariant: Boolean = false) {
|
fun doTestFailure(vararg variants: CirClassOrTypeAliasType, shouldFailOnFirstVariant: Boolean = false) {
|
||||||
prepareCache(variants)
|
prepareCache(variants)
|
||||||
|
super.doTestFailure(*variants, shouldFailOnFirstVariant = shouldFailOnFirstVariant)
|
||||||
doTestFailure(
|
|
||||||
variants = variants.map(CirTypeFactory::create).toTypedArray(),
|
|
||||||
shouldFailOnFirstVariant = shouldFailOnFirstVariant
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createCommonizer() = TypeCommonizer(classifiers)
|
override fun createCommonizer() = TypeCommonizer(classifiers)
|
||||||
|
|||||||
+11
-12
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.descriptors.commonizer.core
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirName
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirName
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirTypeParameter
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirTypeParameter
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirTypeFactory
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirTypeParameterFactory
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirTypeParameterFactory
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.MOCK_CLASSIFIERS
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.MOCK_CLASSIFIERS
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.mockClassType
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.mockClassType
|
||||||
@@ -63,23 +62,23 @@ class TypeParameterCommonizerTest : AbstractCommonizerTest<CirTypeParameter, Cir
|
|||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun differentUpperBounds1() = doTestFailure(
|
fun differentUpperBounds1() = doTestFailure(
|
||||||
mockTypeParam(upperBounds = listOf("kotlin.String")),
|
mockTypeParam(upperBounds = listOf("kotlin/String")),
|
||||||
mockTypeParam(upperBounds = listOf("kotlin.String")),
|
mockTypeParam(upperBounds = listOf("kotlin/String")),
|
||||||
mockTypeParam(upperBounds = listOf("kotlin.Int"))
|
mockTypeParam(upperBounds = listOf("kotlin/Int"))
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun differentUpperBounds2() = doTestFailure(
|
fun differentUpperBounds2() = doTestFailure(
|
||||||
mockTypeParam(upperBounds = listOf("kotlin.String", "kotlin.Int")),
|
mockTypeParam(upperBounds = listOf("kotlin/String", "kotlin/Int")),
|
||||||
mockTypeParam(upperBounds = listOf("kotlin.String", "kotlin.Int")),
|
mockTypeParam(upperBounds = listOf("kotlin/String", "kotlin/Int")),
|
||||||
mockTypeParam(upperBounds = listOf("kotlin.String"))
|
mockTypeParam(upperBounds = listOf("kotlin/String"))
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun differentUpperBounds3() = doTestFailure(
|
fun differentUpperBounds3() = doTestFailure(
|
||||||
mockTypeParam(upperBounds = listOf("kotlin.String", "kotlin.Int")),
|
mockTypeParam(upperBounds = listOf("kotlin/String", "kotlin/Int")),
|
||||||
mockTypeParam(upperBounds = listOf("kotlin.String", "kotlin.Int")),
|
mockTypeParam(upperBounds = listOf("kotlin/String", "kotlin/Int")),
|
||||||
mockTypeParam(upperBounds = listOf("kotlin.Int", "kotlin.String"))
|
mockTypeParam(upperBounds = listOf("kotlin/Int", "kotlin/String"))
|
||||||
)
|
)
|
||||||
|
|
||||||
internal companion object {
|
internal companion object {
|
||||||
@@ -87,13 +86,13 @@ class TypeParameterCommonizerTest : AbstractCommonizerTest<CirTypeParameter, Cir
|
|||||||
name: String = "T",
|
name: String = "T",
|
||||||
isReified: Boolean = false,
|
isReified: Boolean = false,
|
||||||
variance: Variance = Variance.INVARIANT,
|
variance: Variance = Variance.INVARIANT,
|
||||||
upperBounds: List<String> = listOf("kotlin.Any")
|
upperBounds: List<String> = listOf("kotlin/Any")
|
||||||
) = CirTypeParameterFactory.create(
|
) = CirTypeParameterFactory.create(
|
||||||
annotations = emptyList(),
|
annotations = emptyList(),
|
||||||
name = CirName.create(name),
|
name = CirName.create(name),
|
||||||
isReified = isReified,
|
isReified = isReified,
|
||||||
variance = variance,
|
variance = variance,
|
||||||
upperBounds = upperBounds.map { CirTypeFactory.create(mockClassType(it)) }
|
upperBounds = upperBounds.map(::mockClassType)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+42
-42
@@ -22,38 +22,38 @@ class TypeParameterListCommonizerTest : AbstractCommonizerTest<List<CirTypeParam
|
|||||||
@Test
|
@Test
|
||||||
fun matchedParameters() = doTestSuccess(
|
fun matchedParameters() = doTestSuccess(
|
||||||
expected = mockTypeParams(
|
expected = mockTypeParams(
|
||||||
"T" to "kotlin.Any?",
|
"T" to "kotlin/Any",
|
||||||
"R" to "kotlin.CharSequence",
|
"R" to "kotlin/CharSequence",
|
||||||
"Q" to "org.sample.Foo?"
|
"Q" to "org/sample/Foo"
|
||||||
),
|
),
|
||||||
mockTypeParams(
|
mockTypeParams(
|
||||||
"T" to "kotlin.Any?",
|
"T" to "kotlin/Any",
|
||||||
"R" to "kotlin.CharSequence",
|
"R" to "kotlin/CharSequence",
|
||||||
"Q" to "org.sample.Foo?"
|
"Q" to "org/sample/Foo"
|
||||||
),
|
),
|
||||||
mockTypeParams(
|
mockTypeParams(
|
||||||
"T" to "kotlin.Any?",
|
"T" to "kotlin/Any",
|
||||||
"R" to "kotlin.CharSequence",
|
"R" to "kotlin/CharSequence",
|
||||||
"Q" to "org.sample.Foo?"
|
"Q" to "org/sample/Foo"
|
||||||
),
|
),
|
||||||
mockTypeParams(
|
mockTypeParams(
|
||||||
"T" to "kotlin.Any?",
|
"T" to "kotlin/Any",
|
||||||
"R" to "kotlin.CharSequence",
|
"R" to "kotlin/CharSequence",
|
||||||
"Q" to "org.sample.Foo?"
|
"Q" to "org/sample/Foo"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun mismatchedParameterListSize1() = doTestFailure(
|
fun mismatchedParameterListSize1() = doTestFailure(
|
||||||
mockTypeParams(
|
mockTypeParams(
|
||||||
"T" to "kotlin.Any?",
|
"T" to "kotlin/Any",
|
||||||
"R" to "kotlin.CharSequence",
|
"R" to "kotlin/CharSequence",
|
||||||
"Q" to "org.sample.Foo?"
|
"Q" to "org/sample/Foo"
|
||||||
),
|
),
|
||||||
mockTypeParams(
|
mockTypeParams(
|
||||||
"T" to "kotlin.Any?",
|
"T" to "kotlin/Any",
|
||||||
"R" to "kotlin.CharSequence",
|
"R" to "kotlin/CharSequence",
|
||||||
"Q" to "org.sample.Foo?"
|
"Q" to "org/sample/Foo"
|
||||||
),
|
),
|
||||||
emptyList()
|
emptyList()
|
||||||
)
|
)
|
||||||
@@ -61,50 +61,50 @@ class TypeParameterListCommonizerTest : AbstractCommonizerTest<List<CirTypeParam
|
|||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun mismatchedParameterListSize2() = doTestFailure(
|
fun mismatchedParameterListSize2() = doTestFailure(
|
||||||
mockTypeParams(
|
mockTypeParams(
|
||||||
"T" to "kotlin.Any?",
|
"T" to "kotlin/Any",
|
||||||
"R" to "kotlin.CharSequence",
|
"R" to "kotlin/CharSequence",
|
||||||
"Q" to "org.sample.Foo?"
|
"Q" to "org/sample/Foo"
|
||||||
),
|
),
|
||||||
mockTypeParams(
|
mockTypeParams(
|
||||||
"T" to "kotlin.Any?",
|
"T" to "kotlin/Any",
|
||||||
"R" to "kotlin.CharSequence",
|
"R" to "kotlin/CharSequence",
|
||||||
"Q" to "org.sample.Foo?"
|
"Q" to "org/sample/Foo"
|
||||||
),
|
),
|
||||||
mockTypeParams(
|
mockTypeParams(
|
||||||
"T" to "kotlin.Any?",
|
"T" to "kotlin/Any",
|
||||||
"R" to "kotlin.CharSequence"
|
"R" to "kotlin/CharSequence"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun mismatchedParameterListSize3() = doTestFailure(
|
fun mismatchedParameterListSize3() = doTestFailure(
|
||||||
mockTypeParams(
|
mockTypeParams(
|
||||||
"T" to "kotlin.Any?",
|
"T" to "kotlin/Any",
|
||||||
"R" to "kotlin.CharSequence",
|
"R" to "kotlin/CharSequence",
|
||||||
"Q" to "org.sample.Foo?"
|
"Q" to "org/sample/Foo"
|
||||||
),
|
),
|
||||||
mockTypeParams(
|
mockTypeParams(
|
||||||
"T" to "kotlin.Any?",
|
"T" to "kotlin/Any",
|
||||||
"R" to "kotlin.CharSequence",
|
"R" to "kotlin/CharSequence",
|
||||||
"Q" to "org.sample.Foo?"
|
"Q" to "org/sample/Foo"
|
||||||
),
|
),
|
||||||
mockTypeParams(
|
mockTypeParams(
|
||||||
"T" to "kotlin.Any?",
|
"T" to "kotlin/Any",
|
||||||
"R" to "kotlin.CharSequence",
|
"R" to "kotlin/CharSequence",
|
||||||
"Q" to "org.sample.Foo?",
|
"Q" to "org/sample/Foo",
|
||||||
"V" to "org.sample.Bar"
|
"V" to "org/sample/Bar"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun mismatchedParameterNames() = doTestFailure(
|
fun mismatchedParameterNames() = doTestFailure(
|
||||||
mockTypeParams(
|
mockTypeParams(
|
||||||
"T" to "kotlin.Any?",
|
"T" to "kotlin/Any",
|
||||||
"R" to "kotlin.CharSequence"
|
"R" to "kotlin/CharSequence"
|
||||||
),
|
),
|
||||||
mockTypeParams(
|
mockTypeParams(
|
||||||
"T" to "kotlin.Any?",
|
"T" to "kotlin/Any",
|
||||||
"Q" to "kotlin.CharSequence"
|
"Q" to "kotlin/CharSequence"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -113,10 +113,10 @@ class TypeParameterListCommonizerTest : AbstractCommonizerTest<List<CirTypeParam
|
|||||||
private companion object {
|
private companion object {
|
||||||
fun mockTypeParams(vararg params: Pair<String, String>): List<CirTypeParameter> {
|
fun mockTypeParams(vararg params: Pair<String, String>): List<CirTypeParameter> {
|
||||||
check(params.isNotEmpty())
|
check(params.isNotEmpty())
|
||||||
return params.map { (name, returnTypeFqName) ->
|
return params.map { (name, upperBounds) ->
|
||||||
TypeParameterCommonizerTest.mockTypeParam(
|
TypeParameterCommonizerTest.mockTypeParam(
|
||||||
name = name,
|
name = name,
|
||||||
upperBounds = listOf(returnTypeFqName)
|
upperBounds = listOf(upperBounds)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+60
-61
@@ -9,7 +9,6 @@ import org.jetbrains.kotlin.descriptors.commonizer.cir.CirAnnotation
|
|||||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirName
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirName
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirType
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirType
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirValueParameter
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirValueParameter
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirTypeFactory
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.core.CirTestValueParameter.Companion.areEqual
|
import org.jetbrains.kotlin.descriptors.commonizer.core.CirTestValueParameter.Companion.areEqual
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.core.TypeCommonizerTest.Companion.areEqual
|
import org.jetbrains.kotlin.descriptors.commonizer.core.TypeCommonizerTest.Companion.areEqual
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirKnownClassifiers
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirKnownClassifiers
|
||||||
@@ -21,124 +20,124 @@ class ValueParameterCommonizerTest : AbstractCommonizerTest<CirValueParameter, C
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun sameReturnType1() = doTestSuccess(
|
fun sameReturnType1() = doTestSuccess(
|
||||||
expected = mockValueParam("kotlin.String"),
|
expected = mockValueParam("kotlin/String"),
|
||||||
mockValueParam("kotlin.String"),
|
mockValueParam("kotlin/String"),
|
||||||
mockValueParam("kotlin.String"),
|
mockValueParam("kotlin/String"),
|
||||||
mockValueParam("kotlin.String")
|
mockValueParam("kotlin/String")
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun sameReturnType2() = doTestSuccess(
|
fun sameReturnType2() = doTestSuccess(
|
||||||
expected = mockValueParam("org.sample.Foo"),
|
expected = mockValueParam("org/sample/Foo"),
|
||||||
mockValueParam("org.sample.Foo"),
|
mockValueParam("org/sample/Foo"),
|
||||||
mockValueParam("org.sample.Foo"),
|
mockValueParam("org/sample/Foo"),
|
||||||
mockValueParam("org.sample.Foo")
|
mockValueParam("org/sample/Foo")
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun differentReturnTypes1() = doTestFailure(
|
fun differentReturnTypes1() = doTestFailure(
|
||||||
mockValueParam("kotlin.String"),
|
mockValueParam("kotlin/String"),
|
||||||
mockValueParam("kotlin.String"),
|
mockValueParam("kotlin/String"),
|
||||||
mockValueParam("kotlin.Int")
|
mockValueParam("kotlin/Int")
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun differentReturnTypes2() = doTestFailure(
|
fun differentReturnTypes2() = doTestFailure(
|
||||||
mockValueParam("kotlin.String"),
|
mockValueParam("kotlin/String"),
|
||||||
mockValueParam("kotlin.String"),
|
mockValueParam("kotlin/String"),
|
||||||
mockValueParam("org.sample.Foo")
|
mockValueParam("org/sample/Foo")
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun differentReturnTypes3() = doTestFailure(
|
fun differentReturnTypes3() = doTestFailure(
|
||||||
mockValueParam("org.sample.Foo"),
|
mockValueParam("org/sample/Foo"),
|
||||||
mockValueParam("org.sample.Foo"),
|
mockValueParam("org/sample/Foo"),
|
||||||
mockValueParam("org.sample.Bar")
|
mockValueParam("org/sample/Bar")
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun allHaveVararg1() = doTestSuccess(
|
fun allHaveVararg1() = doTestSuccess(
|
||||||
expected = mockValueParam("kotlin.String", hasVarargElementType = true),
|
expected = mockValueParam("kotlin/String", hasVarargElementType = true),
|
||||||
mockValueParam("kotlin.String", hasVarargElementType = true),
|
mockValueParam("kotlin/String", hasVarargElementType = true),
|
||||||
mockValueParam("kotlin.String", hasVarargElementType = true),
|
mockValueParam("kotlin/String", hasVarargElementType = true),
|
||||||
mockValueParam("kotlin.String", hasVarargElementType = true)
|
mockValueParam("kotlin/String", hasVarargElementType = true)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun allHaveVararg2() = doTestSuccess(
|
fun allHaveVararg2() = doTestSuccess(
|
||||||
expected = mockValueParam("org.sample.Foo", hasVarargElementType = true),
|
expected = mockValueParam("org/sample/Foo", hasVarargElementType = true),
|
||||||
mockValueParam("org.sample.Foo", hasVarargElementType = true),
|
mockValueParam("org/sample/Foo", hasVarargElementType = true),
|
||||||
mockValueParam("org.sample.Foo", hasVarargElementType = true),
|
mockValueParam("org/sample/Foo", hasVarargElementType = true),
|
||||||
mockValueParam("org.sample.Foo", hasVarargElementType = true)
|
mockValueParam("org/sample/Foo", hasVarargElementType = true)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun someDoesNotHaveVararg1() = doTestFailure(
|
fun someDoesNotHaveVararg1() = doTestFailure(
|
||||||
mockValueParam("kotlin.String", hasVarargElementType = true),
|
mockValueParam("kotlin/String", hasVarargElementType = true),
|
||||||
mockValueParam("kotlin.String", hasVarargElementType = true),
|
mockValueParam("kotlin/String", hasVarargElementType = true),
|
||||||
mockValueParam("kotlin.String", hasVarargElementType = false)
|
mockValueParam("kotlin/String", hasVarargElementType = false)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun someDoesNotHaveVararg2() = doTestFailure(
|
fun someDoesNotHaveVararg2() = doTestFailure(
|
||||||
mockValueParam("org.sample.Foo", hasVarargElementType = false),
|
mockValueParam("org/sample/Foo", hasVarargElementType = false),
|
||||||
mockValueParam("org.sample.Foo", hasVarargElementType = false),
|
mockValueParam("org/sample/Foo", hasVarargElementType = false),
|
||||||
mockValueParam("org.sample.Foo", hasVarargElementType = true)
|
mockValueParam("org/sample/Foo", hasVarargElementType = true)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun allHaveCrossinline() = doTestSuccess(
|
fun allHaveCrossinline() = doTestSuccess(
|
||||||
expected = mockValueParam("kotlin.String", isCrossinline = true),
|
expected = mockValueParam("kotlin/String", isCrossinline = true),
|
||||||
mockValueParam("kotlin.String", isCrossinline = true),
|
mockValueParam("kotlin/String", isCrossinline = true),
|
||||||
mockValueParam("kotlin.String", isCrossinline = true),
|
mockValueParam("kotlin/String", isCrossinline = true),
|
||||||
mockValueParam("kotlin.String", isCrossinline = true)
|
mockValueParam("kotlin/String", isCrossinline = true)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun someHaveCrossinline1() = doTestSuccess(
|
fun someHaveCrossinline1() = doTestSuccess(
|
||||||
expected = mockValueParam("kotlin.String", isCrossinline = false),
|
expected = mockValueParam("kotlin/String", isCrossinline = false),
|
||||||
mockValueParam("kotlin.String", isCrossinline = true),
|
mockValueParam("kotlin/String", isCrossinline = true),
|
||||||
mockValueParam("kotlin.String", isCrossinline = true),
|
mockValueParam("kotlin/String", isCrossinline = true),
|
||||||
mockValueParam("kotlin.String", isCrossinline = false)
|
mockValueParam("kotlin/String", isCrossinline = false)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun someHaveCrossinline2() = doTestSuccess(
|
fun someHaveCrossinline2() = doTestSuccess(
|
||||||
expected = mockValueParam("kotlin.String", isCrossinline = false),
|
expected = mockValueParam("kotlin/String", isCrossinline = false),
|
||||||
mockValueParam("kotlin.String", isCrossinline = false),
|
mockValueParam("kotlin/String", isCrossinline = false),
|
||||||
mockValueParam("kotlin.String", isCrossinline = true),
|
mockValueParam("kotlin/String", isCrossinline = true),
|
||||||
mockValueParam("kotlin.String", isCrossinline = true)
|
mockValueParam("kotlin/String", isCrossinline = true)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun allHaveNoinline() = doTestSuccess(
|
fun allHaveNoinline() = doTestSuccess(
|
||||||
expected = mockValueParam("kotlin.String", isNoinline = true),
|
expected = mockValueParam("kotlin/String", isNoinline = true),
|
||||||
mockValueParam("kotlin.String", isNoinline = true),
|
mockValueParam("kotlin/String", isNoinline = true),
|
||||||
mockValueParam("kotlin.String", isNoinline = true),
|
mockValueParam("kotlin/String", isNoinline = true),
|
||||||
mockValueParam("kotlin.String", isNoinline = true)
|
mockValueParam("kotlin/String", isNoinline = true)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun someHaveNoinline1() = doTestSuccess(
|
fun someHaveNoinline1() = doTestSuccess(
|
||||||
expected = mockValueParam("kotlin.String", isNoinline = false),
|
expected = mockValueParam("kotlin/String", isNoinline = false),
|
||||||
mockValueParam("kotlin.String", isNoinline = true),
|
mockValueParam("kotlin/String", isNoinline = true),
|
||||||
mockValueParam("kotlin.String", isNoinline = true),
|
mockValueParam("kotlin/String", isNoinline = true),
|
||||||
mockValueParam("kotlin.String", isNoinline = false)
|
mockValueParam("kotlin/String", isNoinline = false)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun someHaveNoinline2() = doTestSuccess(
|
fun someHaveNoinline2() = doTestSuccess(
|
||||||
expected = mockValueParam("kotlin.String", isNoinline = false),
|
expected = mockValueParam("kotlin/String", isNoinline = false),
|
||||||
mockValueParam("kotlin.String", isNoinline = false),
|
mockValueParam("kotlin/String", isNoinline = false),
|
||||||
mockValueParam("kotlin.String", isNoinline = true),
|
mockValueParam("kotlin/String", isNoinline = true),
|
||||||
mockValueParam("kotlin.String", isNoinline = true)
|
mockValueParam("kotlin/String", isNoinline = true)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun anyDeclaresDefaultValue() = doTestFailure(
|
fun anyDeclaresDefaultValue() = doTestFailure(
|
||||||
mockValueParam("kotlin.String", declaresDefaultValue = false),
|
mockValueParam("kotlin/String", declaresDefaultValue = false),
|
||||||
mockValueParam("kotlin.String", declaresDefaultValue = false),
|
mockValueParam("kotlin/String", declaresDefaultValue = false),
|
||||||
mockValueParam("kotlin.String", declaresDefaultValue = true)
|
mockValueParam("kotlin/String", declaresDefaultValue = true)
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun createCommonizer() = ValueParameterCommonizer(MOCK_CLASSIFIERS)
|
override fun createCommonizer() = ValueParameterCommonizer(MOCK_CLASSIFIERS)
|
||||||
@@ -148,14 +147,14 @@ class ValueParameterCommonizerTest : AbstractCommonizerTest<CirValueParameter, C
|
|||||||
|
|
||||||
internal companion object {
|
internal companion object {
|
||||||
fun mockValueParam(
|
fun mockValueParam(
|
||||||
returnTypeFqName: String,
|
returnTypeClassId: String,
|
||||||
name: String = "myParameter",
|
name: String = "myParameter",
|
||||||
hasVarargElementType: Boolean = false,
|
hasVarargElementType: Boolean = false,
|
||||||
isCrossinline: Boolean = false,
|
isCrossinline: Boolean = false,
|
||||||
isNoinline: Boolean = false,
|
isNoinline: Boolean = false,
|
||||||
declaresDefaultValue: Boolean = false
|
declaresDefaultValue: Boolean = false
|
||||||
): CirValueParameter {
|
): CirValueParameter {
|
||||||
val returnType = CirTypeFactory.create(mockClassType(returnTypeFqName))
|
val returnType = mockClassType(returnTypeClassId)
|
||||||
|
|
||||||
return CirTestValueParameter(
|
return CirTestValueParameter(
|
||||||
name = CirName.create(name),
|
name = CirName.create(name),
|
||||||
|
|||||||
+65
-65
@@ -23,38 +23,38 @@ class ValueParameterListCommonizerTest : AbstractCommonizerTest<List<CirValuePar
|
|||||||
@Test
|
@Test
|
||||||
fun matchedParameters() = doTestSuccess(
|
fun matchedParameters() = doTestSuccess(
|
||||||
expected = mockValueParams(
|
expected = mockValueParams(
|
||||||
"a" to "kotlin.String",
|
"a" to "kotlin/String",
|
||||||
"b" to "kotlin.Int",
|
"b" to "kotlin/Int",
|
||||||
"c" to "org.sample.Foo"
|
"c" to "org/sample/Foo"
|
||||||
),
|
),
|
||||||
mockValueParams(
|
mockValueParams(
|
||||||
"a" to "kotlin.String",
|
"a" to "kotlin/String",
|
||||||
"b" to "kotlin.Int",
|
"b" to "kotlin/Int",
|
||||||
"c" to "org.sample.Foo"
|
"c" to "org/sample/Foo"
|
||||||
),
|
),
|
||||||
mockValueParams(
|
mockValueParams(
|
||||||
"a" to "kotlin.String",
|
"a" to "kotlin/String",
|
||||||
"b" to "kotlin.Int",
|
"b" to "kotlin/Int",
|
||||||
"c" to "org.sample.Foo"
|
"c" to "org/sample/Foo"
|
||||||
),
|
),
|
||||||
mockValueParams(
|
mockValueParams(
|
||||||
"a" to "kotlin.String",
|
"a" to "kotlin/String",
|
||||||
"b" to "kotlin.Int",
|
"b" to "kotlin/Int",
|
||||||
"c" to "org.sample.Foo"
|
"c" to "org/sample/Foo"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun mismatchedParameterListSize1() = doTestFailure(
|
fun mismatchedParameterListSize1() = doTestFailure(
|
||||||
mockValueParams(
|
mockValueParams(
|
||||||
"a" to "kotlin.String",
|
"a" to "kotlin/String",
|
||||||
"b" to "kotlin.Int",
|
"b" to "kotlin/Int",
|
||||||
"c" to "org.sample.Foo"
|
"c" to "org/sample/Foo"
|
||||||
),
|
),
|
||||||
mockValueParams(
|
mockValueParams(
|
||||||
"a" to "kotlin.String",
|
"a" to "kotlin/String",
|
||||||
"b" to "kotlin.Int",
|
"b" to "kotlin/Int",
|
||||||
"c" to "org.sample.Foo"
|
"c" to "org/sample/Foo"
|
||||||
),
|
),
|
||||||
emptyList()
|
emptyList()
|
||||||
)
|
)
|
||||||
@@ -62,91 +62,91 @@ class ValueParameterListCommonizerTest : AbstractCommonizerTest<List<CirValuePar
|
|||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun mismatchedParameterListSize2() = doTestFailure(
|
fun mismatchedParameterListSize2() = doTestFailure(
|
||||||
mockValueParams(
|
mockValueParams(
|
||||||
"a" to "kotlin.String",
|
"a" to "kotlin/String",
|
||||||
"b" to "kotlin.Int",
|
"b" to "kotlin/Int",
|
||||||
"c" to "org.sample.Foo"
|
"c" to "org/sample/Foo"
|
||||||
),
|
),
|
||||||
mockValueParams(
|
mockValueParams(
|
||||||
"a" to "kotlin.String",
|
"a" to "kotlin/String",
|
||||||
"b" to "kotlin.Int",
|
"b" to "kotlin/Int",
|
||||||
"c" to "org.sample.Foo"
|
"c" to "org/sample/Foo"
|
||||||
),
|
),
|
||||||
mockValueParams(
|
mockValueParams(
|
||||||
"a" to "kotlin.String",
|
"a" to "kotlin/String",
|
||||||
"b" to "kotlin.Int",
|
"b" to "kotlin/Int",
|
||||||
"c" to "org.sample.Foo"
|
"c" to "org/sample/Foo"
|
||||||
),
|
),
|
||||||
mockValueParams(
|
mockValueParams(
|
||||||
"a" to "kotlin.String",
|
"a" to "kotlin/String",
|
||||||
"b" to "kotlin.Int"
|
"b" to "kotlin/Int"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun mismatchedParameterListSize3() = doTestFailure(
|
fun mismatchedParameterListSize3() = doTestFailure(
|
||||||
mockValueParams(
|
mockValueParams(
|
||||||
"a" to "kotlin.String",
|
"a" to "kotlin/String",
|
||||||
"b" to "kotlin.Int",
|
"b" to "kotlin/Int",
|
||||||
"c" to "org.sample.Foo"
|
"c" to "org/sample/Foo"
|
||||||
),
|
),
|
||||||
mockValueParams(
|
mockValueParams(
|
||||||
"a" to "kotlin.String",
|
"a" to "kotlin/String",
|
||||||
"b" to "kotlin.Int",
|
"b" to "kotlin/Int",
|
||||||
"c" to "org.sample.Foo"
|
"c" to "org/sample/Foo"
|
||||||
),
|
),
|
||||||
mockValueParams(
|
mockValueParams(
|
||||||
"a" to "kotlin.String",
|
"a" to "kotlin/String",
|
||||||
"b" to "kotlin.Int",
|
"b" to "kotlin/Int",
|
||||||
"c" to "org.sample.Foo"
|
"c" to "org/sample/Foo"
|
||||||
),
|
),
|
||||||
mockValueParams(
|
mockValueParams(
|
||||||
"a" to "kotlin.String",
|
"a" to "kotlin/String",
|
||||||
"b" to "kotlin.Int",
|
"b" to "kotlin/Int",
|
||||||
"c" to "org.sample.Foo",
|
"c" to "org/sample/Foo",
|
||||||
"d" to "org.sample.Bar"
|
"d" to "org/sample/Bar"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test // types match, names doesn't match, without rewriting names the commonizer chooses the names from the first list of parameters
|
@Test // types match, names doesn't match, without rewriting names the commonizer chooses the names from the first list of parameters
|
||||||
fun mismatchedParameterNames() = doTestSuccess(
|
fun mismatchedParameterNames() = doTestSuccess(
|
||||||
expected = mockValueParams(
|
expected = mockValueParams(
|
||||||
"a" to "kotlin.String",
|
"a" to "kotlin/String",
|
||||||
"b" to "kotlin.Int",
|
"b" to "kotlin/Int",
|
||||||
"c" to "org.sample.Foo"
|
"c" to "org/sample/Foo"
|
||||||
),
|
),
|
||||||
mockValueParams(
|
mockValueParams(
|
||||||
"a" to "kotlin.String",
|
"a" to "kotlin/String",
|
||||||
"b" to "kotlin.Int",
|
"b" to "kotlin/Int",
|
||||||
"c" to "org.sample.Foo"
|
"c" to "org/sample/Foo"
|
||||||
),
|
),
|
||||||
mockValueParams(
|
mockValueParams(
|
||||||
"d" to "kotlin.String",
|
"d" to "kotlin/String",
|
||||||
"e" to "kotlin.Int",
|
"e" to "kotlin/Int",
|
||||||
"f" to "org.sample.Foo"
|
"f" to "org/sample/Foo"
|
||||||
),
|
),
|
||||||
mockValueParams(
|
mockValueParams(
|
||||||
"h" to "kotlin.String",
|
"h" to "kotlin/String",
|
||||||
"i" to "kotlin.Int",
|
"i" to "kotlin/Int",
|
||||||
"j" to "org.sample.Foo"
|
"j" to "org/sample/Foo"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test(expected = IllegalCommonizerStateException::class)
|
@Test(expected = IllegalCommonizerStateException::class)
|
||||||
fun mismatchedParameterTypes() = doTestFailure(
|
fun mismatchedParameterTypes() = doTestFailure(
|
||||||
mockValueParams(
|
mockValueParams(
|
||||||
"a" to "kotlin.String",
|
"a" to "kotlin/String",
|
||||||
"b" to "kotlin.Int",
|
"b" to "kotlin/Int",
|
||||||
"c" to "org.sample.Foo"
|
"c" to "org/sample/Foo"
|
||||||
),
|
),
|
||||||
mockValueParams(
|
mockValueParams(
|
||||||
"a" to "kotlin.String",
|
"a" to "kotlin/String",
|
||||||
"b" to "kotlin.Int",
|
"b" to "kotlin/Int",
|
||||||
"c" to "org.sample.Foo"
|
"c" to "org/sample/Foo"
|
||||||
),
|
),
|
||||||
mockValueParams(
|
mockValueParams(
|
||||||
"a" to "kotlin.Int",
|
"a" to "kotlin/Int",
|
||||||
"b" to "kotlin.String",
|
"b" to "kotlin/String",
|
||||||
"c" to "org.sample.Bar"
|
"c" to "org/sample/Bar"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -169,10 +169,10 @@ class ValueParameterListCommonizerTest : AbstractCommonizerTest<List<CirValuePar
|
|||||||
private companion object {
|
private companion object {
|
||||||
fun mockValueParams(vararg params: Pair<String, String>): List<CirValueParameter> {
|
fun mockValueParams(vararg params: Pair<String, String>): List<CirValueParameter> {
|
||||||
check(params.isNotEmpty())
|
check(params.isNotEmpty())
|
||||||
return params.map { (name, returnTypeFqName) ->
|
return params.map { (name, returnTypeClassId) ->
|
||||||
ValueParameterCommonizerTest.mockValueParam(
|
ValueParameterCommonizerTest.mockValueParam(
|
||||||
name = name,
|
name = name,
|
||||||
returnTypeFqName = returnTypeFqName
|
returnTypeClassId = returnTypeClassId
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+31
-96
@@ -9,119 +9,48 @@ import org.jetbrains.kotlin.backend.common.serialization.metadata.KlibMetadataMo
|
|||||||
import org.jetbrains.kotlin.backend.common.serialization.metadata.KlibMetadataVersion
|
import org.jetbrains.kotlin.backend.common.serialization.metadata.KlibMetadataVersion
|
||||||
import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl
|
import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.*
|
import org.jetbrains.kotlin.descriptors.commonizer.*
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.ResultsConsumer.ModuleResult
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.ModulesProvider.ModuleInfo
|
import org.jetbrains.kotlin.descriptors.commonizer.ModulesProvider.ModuleInfo
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirEntityId
|
import org.jetbrains.kotlin.descriptors.commonizer.ResultsConsumer.ModuleResult
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.CirName
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.*
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirClassFactory
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirClassFactory
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirTypeFactory
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.konan.NativeSensitiveManifestData
|
import org.jetbrains.kotlin.descriptors.commonizer.konan.NativeSensitiveManifestData
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.konan.TargetedNativeManifestDataProvider
|
import org.jetbrains.kotlin.descriptors.commonizer.konan.TargetedNativeManifestDataProvider
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.*
|
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.*
|
||||||
import org.jetbrains.kotlin.descriptors.impl.AbstractTypeAliasDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorImpl
|
|
||||||
import org.jetbrains.kotlin.library.KotlinLibraryVersioning
|
import org.jetbrains.kotlin.library.KotlinLibraryVersioning
|
||||||
import org.jetbrains.kotlin.library.SerializedMetadata
|
import org.jetbrains.kotlin.library.SerializedMetadata
|
||||||
import org.jetbrains.kotlin.name.FqName
|
|
||||||
import org.jetbrains.kotlin.name.parentOrNull
|
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
|
||||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||||
import org.jetbrains.kotlin.types.*
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import kotlin.random.Random
|
|
||||||
import org.jetbrains.kotlin.storage.getValue
|
|
||||||
|
|
||||||
// expected special name for module
|
|
||||||
internal fun mockEmptyModule(moduleName: String): ModuleDescriptor {
|
|
||||||
val module = KotlinTestUtils.createEmptyModule(moduleName)
|
|
||||||
module.initialize(PackageFragmentProvider.Empty)
|
|
||||||
module.setDependencies(module)
|
|
||||||
return module
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun mockClassType(
|
|
||||||
fqName: String,
|
|
||||||
nullable: Boolean = false
|
|
||||||
): KotlinType = LazyWrappedType(LockBasedStorageManager.NO_LOCKS) {
|
|
||||||
val classFqName = FqName(fqName)
|
|
||||||
|
|
||||||
val classDescriptor = ClassDescriptorImpl(
|
|
||||||
/* containingDeclaration = */ createPackageFragmentForClassifier(classFqName),
|
|
||||||
/* name = */ classFqName.shortName(),
|
|
||||||
/* modality = */ Modality.FINAL,
|
|
||||||
/* classKind = */ ClassKind.CLASS,
|
|
||||||
/* supertypes = */ emptyList(),
|
|
||||||
/* source = */ SourceElement.NO_SOURCE,
|
|
||||||
/* isExternal = */ false,
|
|
||||||
/* storageManager = */ LockBasedStorageManager.NO_LOCKS
|
|
||||||
)
|
|
||||||
|
|
||||||
classDescriptor.initialize(
|
|
||||||
/* unsubstitutedMemberScope = */ MemberScope.Empty,
|
|
||||||
/* constructors = */ emptySet(),
|
|
||||||
/* primaryConstructor = */ null
|
|
||||||
)
|
|
||||||
|
|
||||||
classDescriptor.defaultType.makeNullableAsSpecified(nullable)
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun mockTAType(
|
internal fun mockTAType(
|
||||||
fqName: String,
|
typeAliasId: String,
|
||||||
nullable: Boolean = false,
|
nullable: Boolean = false,
|
||||||
rightHandSideTypeProvider: () -> KotlinType
|
underlyingType: () -> CirClassOrTypeAliasType
|
||||||
): KotlinType = LazyWrappedType(LockBasedStorageManager.NO_LOCKS) {
|
): CirTypeAliasType = CirTypeFactory.createTypeAliasType(
|
||||||
val typeAliasFqName = FqName(fqName)
|
typeAliasId = createValidClassifierId(typeAliasId),
|
||||||
|
underlyingType = CirTypeFactory.makeNullableIfNecessary(underlyingType(), nullable),
|
||||||
|
arguments = emptyList(),
|
||||||
|
isMarkedNullable = nullable
|
||||||
|
)
|
||||||
|
|
||||||
val rightHandSideType = rightHandSideTypeProvider().lowerIfFlexible()
|
internal fun mockClassType(
|
||||||
|
classId: String,
|
||||||
|
nullable: Boolean = false
|
||||||
|
): CirClassType = CirTypeFactory.createClassType(
|
||||||
|
classId = createValidClassifierId(classId),
|
||||||
|
outerType = null,
|
||||||
|
visibility = DescriptorVisibilities.PUBLIC,
|
||||||
|
arguments = emptyList(),
|
||||||
|
isMarkedNullable = nullable
|
||||||
|
)
|
||||||
|
|
||||||
val typeAliasDescriptor = object : AbstractTypeAliasDescriptor(
|
private fun createValidClassifierId(classifierId: String): CirEntityId {
|
||||||
containingDeclaration = createPackageFragmentForClassifier(typeAliasFqName),
|
check(classifierId.none { it == '.' || it == '\\' || it == '?' }) { "Malformed classifier ID: $classifierId" }
|
||||||
annotations = Annotations.EMPTY,
|
return CirEntityId.create(classifierId)
|
||||||
name = typeAliasFqName.shortName(),
|
|
||||||
sourceElement = SourceElement.NO_SOURCE,
|
|
||||||
visibilityImpl = DescriptorVisibilities.PUBLIC
|
|
||||||
) {
|
|
||||||
override val storageManager get() = LockBasedStorageManager.NO_LOCKS
|
|
||||||
|
|
||||||
private val defaultTypeImpl = storageManager.createLazyValue { computeDefaultType() }
|
|
||||||
override fun getDefaultType() = defaultTypeImpl()
|
|
||||||
|
|
||||||
override val underlyingType by storageManager.createLazyValue { rightHandSideType.getAbbreviation() ?: rightHandSideType }
|
|
||||||
override val expandedType by storageManager.createLazyValue { rightHandSideType }
|
|
||||||
|
|
||||||
override val classDescriptor get() = expandedType.constructor.declarationDescriptor as? ClassDescriptor
|
|
||||||
override val constructors by storageManager.createLazyValue { getTypeAliasConstructors() }
|
|
||||||
|
|
||||||
private val typeConstructorTypeParametersImpl by storageManager.createLazyValue { computeConstructorTypeParameters() }
|
|
||||||
override fun getTypeConstructorTypeParameters() = typeConstructorTypeParametersImpl
|
|
||||||
|
|
||||||
override fun substitute(substitutor: TypeSubstitutor) = error("Unsupported")
|
|
||||||
}
|
|
||||||
|
|
||||||
typeAliasDescriptor.initialize(declaredTypeParameters = emptyList())
|
|
||||||
|
|
||||||
(rightHandSideType.getAbbreviatedType()?.expandedType ?: rightHandSideType)
|
|
||||||
.withAbbreviation(typeAliasDescriptor.defaultType)
|
|
||||||
.makeNullableAsSpecified(nullable)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createPackageFragmentForClassifier(classifierFqName: FqName): PackageFragmentDescriptor =
|
|
||||||
object : PackageFragmentDescriptor {
|
|
||||||
private val module: ModuleDescriptor by lazy { mockEmptyModule("<module4_${classifierFqName.shortName()}_x${Random.nextInt()}>") }
|
|
||||||
override fun getContainingDeclaration(): ModuleDescriptor = module
|
|
||||||
override val fqName = classifierFqName.parentOrNull() ?: FqName.ROOT
|
|
||||||
override fun getMemberScope() = MemberScope.Empty
|
|
||||||
override fun getOriginal() = this
|
|
||||||
override fun getName() = fqName.shortNameOrSpecial()
|
|
||||||
override fun getSource() = SourceElement.NO_SOURCE
|
|
||||||
override val annotations = Annotations.EMPTY
|
|
||||||
override fun <R : Any?, D : Any?> accept(visitor: DeclarationDescriptorVisitor<R, D>?, data: D): R = error("not supported")
|
|
||||||
override fun acceptVoid(visitor: DeclarationDescriptorVisitor<Void, Void>?) = error("not supported")
|
|
||||||
override fun toString() = "package $name"
|
|
||||||
}
|
|
||||||
|
|
||||||
internal val MOCK_CLASSIFIERS = CirKnownClassifiers(
|
internal val MOCK_CLASSIFIERS = CirKnownClassifiers(
|
||||||
commonizedNodes = object : CirCommonizedClassifierNodes {
|
commonizedNodes = object : CirCommonizedClassifierNodes {
|
||||||
private val MOCK_CLASS_NODE = CirClassNode(
|
private val MOCK_CLASS_NODE = CirClassNode(
|
||||||
@@ -173,7 +102,13 @@ internal class MockModulesProvider private constructor(
|
|||||||
companion object {
|
companion object {
|
||||||
@JvmName("createByModuleNames")
|
@JvmName("createByModuleNames")
|
||||||
fun create(moduleNames: List<String>) = MockModulesProvider(
|
fun create(moduleNames: List<String>) = MockModulesProvider(
|
||||||
moduleNames.associateWith { name -> mockEmptyModule("<$name>") }
|
moduleNames.associateWith { name ->
|
||||||
|
// expected special name for module
|
||||||
|
val module = KotlinTestUtils.createEmptyModule("<$name>")
|
||||||
|
module.initialize(PackageFragmentProvider.Empty)
|
||||||
|
module.setDependencies(module)
|
||||||
|
module
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@JvmName("createByModules")
|
@JvmName("createByModules")
|
||||||
|
|||||||
Reference in New Issue
Block a user