diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/annotations/KtFirAnnotationListForType.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/annotations/KtFirAnnotationListForType.kt index 8e14c16fa91..a6bf82d99a3 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/annotations/KtFirAnnotationListForType.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/annotations/KtFirAnnotationListForType.kt @@ -81,6 +81,6 @@ private fun ConeKotlinType.customAnnotationsWithLazyResolve(phase: FirResolvePha val custom = attributes.custom ?: return emptyList() val annotations = custom.annotations.ifEmpty { return emptyList() } - custom.containerDeclaration?.lazyResolveToPhase(phase) + custom.containerSymbol?.lazyResolveToPhase(phase) return annotations } diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/CopyUtils.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/CopyUtils.kt index 2b4e6366fd4..ffbc44522f0 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/CopyUtils.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/CopyUtils.kt @@ -108,9 +108,11 @@ fun List.computeTypeAttributes( } } } + if (customAnnotations.isNotEmpty()) { - attributes += CustomAnnotationTypeAttribute(customAnnotations, containerDeclaration) + attributes += CustomAnnotationTypeAttribute(customAnnotations, containerDeclaration?.symbol) } + return ConeAttributes.create(attributes) } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/CustomAnnotationTypeAttribute.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/CustomAnnotationTypeAttribute.kt index ee97d1cb833..d613656bc99 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/CustomAnnotationTypeAttribute.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/CustomAnnotationTypeAttribute.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -8,11 +8,12 @@ package org.jetbrains.kotlin.fir.types import org.jetbrains.kotlin.fir.declarations.FirDeclaration import org.jetbrains.kotlin.fir.expressions.FirAnnotation import org.jetbrains.kotlin.fir.render +import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol import kotlin.reflect.KClass class CustomAnnotationTypeAttribute( val annotations: List, - val containerDeclaration: FirDeclaration? = null, + val containerSymbol: FirBasedSymbol? = null, ) : ConeAttribute() { override fun union(other: CustomAnnotationTypeAttribute?): CustomAnnotationTypeAttribute? = null @@ -20,7 +21,7 @@ class CustomAnnotationTypeAttribute( override fun add(other: CustomAnnotationTypeAttribute?): CustomAnnotationTypeAttribute { if (other == null || other === this) return this - return CustomAnnotationTypeAttribute(annotations + other.annotations, containerDeclaration) + return CustomAnnotationTypeAttribute(annotations + other.annotations, containerSymbol) } override fun isSubtypeOf(other: CustomAnnotationTypeAttribute?): Boolean = true