K2: introduce val ConeAttribute.keepInInferredDeclarationType
This commit is contained in:
committed by
Space Team
parent
f2bb988e68
commit
90eaf5f70f
+4
@@ -143,6 +143,8 @@ private class OriginalProjectionTypeAttribute(val data: ConeTypeProjection) : Co
|
||||
|
||||
override val key: KClass<out OriginalProjectionTypeAttribute>
|
||||
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<out SourceAttribute>
|
||||
get() = SourceAttribute::class
|
||||
override val keepInInferredDeclarationType: Boolean
|
||||
get() = false
|
||||
}
|
||||
|
||||
private val ConeAttributes.sourceAttribute: SourceAttribute? by ConeAttributes.attributeAccessor()
|
||||
|
||||
@@ -18,6 +18,8 @@ class AbbreviatedTypeAttribute(
|
||||
|
||||
override val key: KClass<out AbbreviatedTypeAttribute>
|
||||
get() = AbbreviatedTypeAttribute::class
|
||||
override val keepInInferredDeclarationType: Boolean
|
||||
get() = true
|
||||
}
|
||||
|
||||
val ConeAttributes.abbreviatedType: AbbreviatedTypeAttribute? by ConeAttributes.attributeAccessor<AbbreviatedTypeAttribute>()
|
||||
|
||||
@@ -23,6 +23,7 @@ object CompilerConeAttributes {
|
||||
override fun isSubtypeOf(other: Exact?): Boolean = true
|
||||
|
||||
override val key: KClass<out Exact> = 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<out NoInfer> = 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<out EnhancedNullability> = 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<out ExtensionFunctionType> = 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<out RawType> = 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<out ContextFunctionTypeParams> = 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<out UnsafeVariance> = UnsafeVariance::class
|
||||
override val keepInInferredDeclarationType: Boolean get() = false
|
||||
|
||||
override fun toString(): String = "@UnsafeVariance"
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ abstract class ConeAttribute<out T : ConeAttribute<T>> : 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<out T : ConeAttribute<T>> : AnnotationMarker {
|
||||
open fun renderForReadability(): String = toString()
|
||||
|
||||
abstract val key: KClass<out T>
|
||||
|
||||
/**
|
||||
* This property indicates whether this attribute should be kept when inferring declaration return type.
|
||||
*/
|
||||
abstract val keepInInferredDeclarationType: Boolean
|
||||
}
|
||||
|
||||
typealias ConeAttributeKey = KClass<out ConeAttribute<*>>
|
||||
|
||||
@@ -61,6 +61,8 @@ class CustomAnnotationTypeAttribute(
|
||||
|
||||
override val key: KClass<out CustomAnnotationTypeAttribute>
|
||||
get() = CustomAnnotationTypeAttribute::class
|
||||
override val keepInInferredDeclarationType: Boolean
|
||||
get() = true
|
||||
|
||||
/**
|
||||
* Return an instance of the attribute that is not linked to any [containerSymbols].
|
||||
|
||||
+2
@@ -68,6 +68,8 @@ class ConeNumberSignAttribute private constructor(val sign: Sign) : ConeAttribut
|
||||
|
||||
override val key: KClass<out ConeNumberSignAttribute>
|
||||
get() = ConeNumberSignAttribute::class
|
||||
override val keepInInferredDeclarationType: Boolean
|
||||
get() = true
|
||||
}
|
||||
|
||||
val ConeAttributes.numberSign: ConeNumberSignAttribute? by ConeAttributes.attributeAccessor<ConeNumberSignAttribute>()
|
||||
|
||||
Reference in New Issue
Block a user