diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirUpperBoundViolatedHelpers.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirUpperBoundViolatedHelpers.kt index 5362767bbbb..0de775706db 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirUpperBoundViolatedHelpers.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirUpperBoundViolatedHelpers.kt @@ -143,6 +143,8 @@ private class OriginalProjectionTypeAttribute(val data: ConeTypeProjection) : Co override val key: KClass get() = OriginalProjectionTypeAttribute::class + override val keepInInferredDeclarationType: Boolean + get() = false } private val ConeAttributes.originalProjection: OriginalProjectionTypeAttribute? by ConeAttributes.attributeAccessor() @@ -246,6 +248,8 @@ private class SourceAttribute(private val data: FirTypeRefSource) : ConeAttribut override val key: KClass get() = SourceAttribute::class + override val keepInInferredDeclarationType: Boolean + get() = false } private val ConeAttributes.sourceAttribute: SourceAttribute? by ConeAttributes.attributeAccessor() diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/AbbreviatedTypeAttribute.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/AbbreviatedTypeAttribute.kt index ead4c98ed45..5204c9f1106 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/AbbreviatedTypeAttribute.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/AbbreviatedTypeAttribute.kt @@ -18,6 +18,8 @@ class AbbreviatedTypeAttribute( override val key: KClass get() = AbbreviatedTypeAttribute::class + override val keepInInferredDeclarationType: Boolean + get() = true } val ConeAttributes.abbreviatedType: AbbreviatedTypeAttribute? by ConeAttributes.attributeAccessor() diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/CompilerConeAttributes.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/CompilerConeAttributes.kt index 86d62fd5f45..948e4c3c347 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/CompilerConeAttributes.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/CompilerConeAttributes.kt @@ -23,6 +23,7 @@ object CompilerConeAttributes { override fun isSubtypeOf(other: Exact?): Boolean = true override val key: KClass = Exact::class + override val keepInInferredDeclarationType: Boolean get() = false override fun toString(): String = "@Exact" } @@ -36,6 +37,7 @@ object CompilerConeAttributes { override fun isSubtypeOf(other: NoInfer?): Boolean = true override val key: KClass = NoInfer::class + override val keepInInferredDeclarationType: Boolean get() = false override fun toString(): String = "@NoInfer" } @@ -50,6 +52,7 @@ object CompilerConeAttributes { override fun isSubtypeOf(other: EnhancedNullability?): Boolean = true override val key: KClass = EnhancedNullability::class + override val keepInInferredDeclarationType: Boolean get() = true override fun toString(): String = "@EnhancedNullability" } @@ -64,6 +67,7 @@ object CompilerConeAttributes { override fun isSubtypeOf(other: ExtensionFunctionType?): Boolean = true override val key: KClass = ExtensionFunctionType::class + override val keepInInferredDeclarationType: Boolean get() = true override fun toString(): String = "@ExtensionFunctionType" } @@ -75,6 +79,8 @@ object CompilerConeAttributes { override fun isSubtypeOf(other: RawType?): Boolean = true override val key: KClass = RawType::class + override val keepInInferredDeclarationType: Boolean get() = true + override fun toString(): String = "Raw type" } @@ -86,6 +92,7 @@ object CompilerConeAttributes { override fun isSubtypeOf(other: ContextFunctionTypeParams?): Boolean = true override val key: KClass = ContextFunctionTypeParams::class + override val keepInInferredDeclarationType: Boolean get() = true override fun toString(): String = "@${StandardNames.FqNames.contextFunctionTypeParams.shortName().asString()}" @@ -104,6 +111,7 @@ object CompilerConeAttributes { override fun isSubtypeOf(other: UnsafeVariance?): Boolean = true override val key: KClass = UnsafeVariance::class + override val keepInInferredDeclarationType: Boolean get() = false override fun toString(): String = "@UnsafeVariance" } diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeAttributes.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeAttributes.kt index db3fdf52eb0..8ac7479165d 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeAttributes.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeAttributes.kt @@ -17,7 +17,7 @@ abstract class ConeAttribute> : AnnotationMarker { abstract fun union(other: @UnsafeVariance T?): T? abstract fun intersect(other: @UnsafeVariance T?): T? - /* + /** * This function is used to decide how multiple attributes should be united in presence of typealiases: * typealias B = @SomeAttribute(1) A * typealias C = @SomeAttribute(2) B @@ -33,6 +33,11 @@ abstract class ConeAttribute> : AnnotationMarker { open fun renderForReadability(): String = toString() abstract val key: KClass + + /** + * This property indicates whether this attribute should be kept when inferring declaration return type. + */ + abstract val keepInInferredDeclarationType: Boolean } typealias ConeAttributeKey = KClass> 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 7c608c7c8ff..c37ddfe7f8b 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 @@ -61,6 +61,8 @@ class CustomAnnotationTypeAttribute( override val key: KClass get() = CustomAnnotationTypeAttribute::class + override val keepInInferredDeclarationType: Boolean + get() = true /** * Return an instance of the attribute that is not linked to any [containerSymbols]. diff --git a/plugins/fir-plugin-prototype/src/org/jetbrains/kotlin/fir/plugin/types/ConeNumberSignAttribute.kt b/plugins/fir-plugin-prototype/src/org/jetbrains/kotlin/fir/plugin/types/ConeNumberSignAttribute.kt index a4d704d8af9..be2cd6a1d57 100644 --- a/plugins/fir-plugin-prototype/src/org/jetbrains/kotlin/fir/plugin/types/ConeNumberSignAttribute.kt +++ b/plugins/fir-plugin-prototype/src/org/jetbrains/kotlin/fir/plugin/types/ConeNumberSignAttribute.kt @@ -68,6 +68,8 @@ class ConeNumberSignAttribute private constructor(val sign: Sign) : ConeAttribut override val key: KClass get() = ConeNumberSignAttribute::class + override val keepInInferredDeclarationType: Boolean + get() = true } val ConeAttributes.numberSign: ConeNumberSignAttribute? by ConeAttributes.attributeAccessor()