diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/builder/builderUtils.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/builder/builderUtils.kt index 42373788625..a61efe9be9a 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/builder/builderUtils.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/builder/builderUtils.kt @@ -121,7 +121,7 @@ internal fun CirSimpleType.buildType( } val simpleType = simpleType( - annotations = annotations.buildDescriptors(targetComponents), + annotations = Annotations.EMPTY, constructor = classifier.typeConstructor, arguments = arguments.map { it.buildArgument(targetComponents, typeParameterResolver) }, nullable = isMarkedNullable, diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/ir/CirType.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/ir/CirType.kt index e5aa6379bd4..124f1aeb8ee 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/ir/CirType.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/ir/CirType.kt @@ -34,9 +34,10 @@ sealed class CirType { * expanded type represents right-hand side declaration that should be processed separately. * * There is no difference between "abbreviation" and "expanded" for types representing classes and type parameters. + * + * Note: Annotations at simple types are not preserved. After commonization all annotations assigned to types will be lost. */ class CirSimpleType private constructor(original: SimpleType) : CirType() { - val annotations: List val kind: CirSimpleTypeKind val fqName: FqName val arguments: List @@ -48,7 +49,6 @@ class CirSimpleType private constructor(original: SimpleType) : CirType() { val abbreviation = (original as? AbbreviatedType)?.abbreviation ?: original val expanded = (original as? AbbreviatedType)?.expandedType ?: original - annotations = abbreviation.annotations.map(CirAnnotation.Companion::create) kind = CirSimpleTypeKind.determineKind(abbreviation.declarationDescriptor) fqName = abbreviation.fqNameInterned arguments = abbreviation.arguments.map(::CirTypeProjection) @@ -68,7 +68,6 @@ class CirSimpleType private constructor(original: SimpleType) : CirType() { && kind == other.kind && arguments == other.arguments && fqNameWithTypeParameters == other.fqNameWithTypeParameters - && annotations == other.annotations && isDefinitelyNotNullType == other.isDefinitelyNotNullType } else -> false @@ -77,8 +76,7 @@ class CirSimpleType private constructor(original: SimpleType) : CirType() { // See also org.jetbrains.kotlin.types.KotlinType.cachedHashCode private var cachedHashCode = 0 - private fun computeHashCode() = hashCode(annotations) - .appendHashCode(kind) + private fun computeHashCode() = hashCode(kind) .appendHashCode(fqName) .appendHashCode(arguments) .appendHashCode(isMarkedNullable) diff --git a/native/commonizer/testData/generalCommonization/annotations/commonized/js/package_root.kt b/native/commonizer/testData/generalCommonization/annotations/commonized/js/package_root.kt index d06a97a31f2..ce2640e2667 100644 --- a/native/commonizer/testData/generalCommonization/annotations/commonized/js/package_root.kt +++ b/native/commonizer/testData/generalCommonization/annotations/commonized/js/package_root.kt @@ -47,7 +47,7 @@ actual fun function1(@JsAnnotation("parameter") @CommonAnnotation("parameter") t @JsAnnotation("function") @CommonAnnotation("function") -actual fun <@JsAnnotation("type-parameter") @CommonAnnotation("type-parameter") Q : @JsAnnotation("type1") @CommonAnnotation("type1") Number> @receiver:JsAnnotation("receiver") @receiver:CommonAnnotation("receiver") Q.function2(): @JsAnnotation("type2") @CommonAnnotation("type2") Q = this +actual fun <@JsAnnotation("type-parameter") @CommonAnnotation("type-parameter") Q : Number> @receiver:JsAnnotation("receiver") @receiver:CommonAnnotation("receiver") Q.function2(): Q = this @JsAnnotation("class") @CommonAnnotation("class") diff --git a/native/commonizer/testData/generalCommonization/annotations/commonized/jvm/package_root.kt b/native/commonizer/testData/generalCommonization/annotations/commonized/jvm/package_root.kt index 7b7d2bdc2cf..2956c294786 100644 --- a/native/commonizer/testData/generalCommonization/annotations/commonized/jvm/package_root.kt +++ b/native/commonizer/testData/generalCommonization/annotations/commonized/jvm/package_root.kt @@ -47,7 +47,7 @@ actual fun function1(@JvmAnnotation("parameter") @CommonAnnotation("parameter") @JvmAnnotation("function") @CommonAnnotation("function") -actual fun <@JvmAnnotation("type-parameter") @CommonAnnotation("type-parameter") Q : @JvmAnnotation("type1") @CommonAnnotation("type1") Number> @receiver:JvmAnnotation("receiver") @receiver:CommonAnnotation("receiver") Q.function2(): @JvmAnnotation("type2") @CommonAnnotation("type2") Q = this +actual fun <@JvmAnnotation("type-parameter") @CommonAnnotation("type-parameter") Q : Number> @receiver:JvmAnnotation("receiver") @receiver:CommonAnnotation("receiver") Q.function2(): Q = this @JvmAnnotation("class") @CommonAnnotation("class")