FE: do not create multiple layers of enhancements for warnings
This commit is contained in:
@@ -51,6 +51,9 @@ class SimpleTypeWithEnhancement(
|
|||||||
kotlinTypeRefiner.refineType(delegate) as SimpleType,
|
kotlinTypeRefiner.refineType(delegate) as SimpleType,
|
||||||
kotlinTypeRefiner.refineType(enhancement)
|
kotlinTypeRefiner.refineType(enhancement)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
override fun toString(): String =
|
||||||
|
"[@EnhancedForWarnings($enhancement)] $origin"
|
||||||
}
|
}
|
||||||
|
|
||||||
class FlexibleTypeWithEnhancement(
|
class FlexibleTypeWithEnhancement(
|
||||||
@@ -81,6 +84,9 @@ class FlexibleTypeWithEnhancement(
|
|||||||
kotlinTypeRefiner.refineType(origin) as FlexibleType,
|
kotlinTypeRefiner.refineType(origin) as FlexibleType,
|
||||||
kotlinTypeRefiner.refineType(enhancement)
|
kotlinTypeRefiner.refineType(enhancement)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
override fun toString(): String =
|
||||||
|
"[@EnhancedForWarnings($enhancement)] $origin"
|
||||||
}
|
}
|
||||||
|
|
||||||
fun KotlinType.getEnhancement(): KotlinType? = when (this) {
|
fun KotlinType.getEnhancement(): KotlinType? = when (this) {
|
||||||
@@ -150,10 +156,12 @@ fun UnwrappedType.inheritEnhancement(origin: KotlinType, transform: (KotlinType)
|
|||||||
fun UnwrappedType.inheritEnhancement(origin: KotlinType): UnwrappedType = wrapEnhancement(origin.getEnhancement())
|
fun UnwrappedType.inheritEnhancement(origin: KotlinType): UnwrappedType = wrapEnhancement(origin.getEnhancement())
|
||||||
|
|
||||||
fun UnwrappedType.wrapEnhancement(enhancement: KotlinType?): UnwrappedType {
|
fun UnwrappedType.wrapEnhancement(enhancement: KotlinType?): UnwrappedType {
|
||||||
|
if (this is TypeWithEnhancement) {
|
||||||
|
return origin.wrapEnhancement(enhancement)
|
||||||
|
}
|
||||||
if (enhancement == null) {
|
if (enhancement == null) {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
return when (this) {
|
return when (this) {
|
||||||
is SimpleType -> SimpleTypeWithEnhancement(this, enhancement)
|
is SimpleType -> SimpleTypeWithEnhancement(this, enhancement)
|
||||||
is FlexibleType -> FlexibleTypeWithEnhancement(this, enhancement)
|
is FlexibleType -> FlexibleTypeWithEnhancement(this, enhancement)
|
||||||
|
|||||||
Reference in New Issue
Block a user