[Commonizer] ClassCommonizer: Support annotation commonization
^KT-62028 Verification Pending
This commit is contained in:
committed by
Space Team
parent
c33a6a665d
commit
f5b107d4f0
@@ -23,10 +23,11 @@ class ClassCommonizer internal constructor(
|
||||
private val typeParameterListCommonizer: TypeParameterListCommonizer = TypeParameterListCommonizer(typeCommonizer)
|
||||
private val modalityCommonizer: ModalityCommonizer = ModalityCommonizer()
|
||||
private val visibilityCommonizer: VisibilityCommonizer = VisibilityCommonizer.equalizing()
|
||||
private val annotationCommonizer = AnnotationsCommonizer.asCommonizer()
|
||||
|
||||
override fun commonizationResult(): CirClass? {
|
||||
return CirClass.create(
|
||||
annotations = emptyList(),
|
||||
annotations = annotationCommonizer.result,
|
||||
name = name,
|
||||
typeParameters = typeParameterListCommonizer.result ?: return null,
|
||||
supertypes = supertypesCommonizer.result,
|
||||
@@ -62,5 +63,6 @@ class ClassCommonizer internal constructor(
|
||||
&& visibilityCommonizer.commonizeWith(next)
|
||||
&& typeParameterListCommonizer.commonizeWith(next.typeParameters)
|
||||
&& supertypesCommonizer.commonizeWith(next.supertypes)
|
||||
&& annotationCommonizer.commonizeWith(next.annotations)
|
||||
}
|
||||
}
|
||||
|
||||
+68
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.commonizer.hierarchical
|
||||
import org.jetbrains.kotlin.commonizer.AbstractInlineSourcesCommonizationTest
|
||||
import org.jetbrains.kotlin.commonizer.assertCommonized
|
||||
|
||||
|
||||
class HierarchicalClassCommonizationTest : AbstractInlineSourcesCommonizationTest() {
|
||||
|
||||
fun `test simple class`() {
|
||||
@@ -96,4 +97,71 @@ class HierarchicalClassCommonizationTest : AbstractInlineSourcesCommonizationTes
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
fun `test annotations on class and interface`() {
|
||||
val result = commonize {
|
||||
outputTarget("(a, b)", "(a, b, c)")
|
||||
registerDependency("a", "b", "c", "(a, b)", "(a, b, c)") {
|
||||
source(
|
||||
"""
|
||||
annotation class A1
|
||||
annotation class A2
|
||||
annotation class A3
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
simpleSingleSourceTarget(
|
||||
"a", """
|
||||
@A1 @A2 @A3
|
||||
class MyClass
|
||||
|
||||
@A1 @A2 @A3
|
||||
interface MyInterface
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
simpleSingleSourceTarget(
|
||||
"b", """
|
||||
@A1 @A2
|
||||
class MyClass
|
||||
|
||||
@A1 @A2
|
||||
interface MyInterface
|
||||
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
simpleSingleSourceTarget(
|
||||
"c", """
|
||||
@A1
|
||||
class MyClass
|
||||
|
||||
@A1
|
||||
interface MyInterface
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
result.assertCommonized(
|
||||
"(a, b)", """
|
||||
@A1 @A2
|
||||
expect class MyClass()
|
||||
|
||||
@A1 @A2
|
||||
expect interface MyInterface
|
||||
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
result.assertCommonized(
|
||||
"(a, b, c)", """
|
||||
@A1
|
||||
expect class MyClass()
|
||||
|
||||
@A1
|
||||
expect interface MyInterface
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user