Minor fix of around flexible and not-null FIR types (by semoro)
This commit is contained in:
@@ -107,7 +107,7 @@ abstract class ConeTypeParameterType : ConeLookupTagBasedType() {
|
||||
|
||||
|
||||
|
||||
class ConeFlexibleType(val lowerBound: ConeLookupTagBasedType, val upperBound: ConeLookupTagBasedType) : ConeKotlinType(),
|
||||
class ConeFlexibleType(val lowerBound: ConeKotlinType, val upperBound: ConeKotlinType) : ConeKotlinType(),
|
||||
FlexibleTypeMarker {
|
||||
override val typeArguments: Array<out ConeKotlinTypeProjection>
|
||||
get() = emptyArray()
|
||||
@@ -116,6 +116,9 @@ class ConeFlexibleType(val lowerBound: ConeLookupTagBasedType, val upperBound: C
|
||||
get() = lowerBound.nullability.takeIf { it == upperBound.nullability } ?: ConeNullability.UNKNOWN
|
||||
}
|
||||
|
||||
fun ConeKotlinType.upperBoundIfFlexible() = (this as? ConeFlexibleType)?.upperBound ?: this
|
||||
fun ConeKotlinType.lowerBoundIfFlexible() = (this as? ConeFlexibleType)?.lowerBound ?: this
|
||||
|
||||
class ConeCapturedTypeConstructor(val projection: ConeKotlinTypeProjection, var supertypes: List<ConeKotlinType>? = null) :
|
||||
TypeConstructorMarker {
|
||||
|
||||
|
||||
+7
-4
@@ -57,7 +57,7 @@ abstract class AbstractConeSubstitutor : ConeSubstitutor {
|
||||
|
||||
override fun substituteOrNull(type: ConeKotlinType): ConeKotlinType? {
|
||||
val newType = substituteType(type)
|
||||
return (newType ?: type).substituteRecursive() ?: newType
|
||||
return (newType ?: type.substituteRecursive()) ?: newType
|
||||
}
|
||||
|
||||
private fun ConeKotlinType.substituteRecursive(): ConeKotlinType? {
|
||||
@@ -78,10 +78,13 @@ abstract class AbstractConeSubstitutor : ConeSubstitutor {
|
||||
}
|
||||
|
||||
private fun ConeFlexibleType.substituteBounds(): ConeFlexibleType? {
|
||||
val newLowerBound = substituteOrNull(lowerBound) as ConeLookupTagBasedType?
|
||||
val newUpperBound = substituteOrNull(upperBound) as ConeLookupTagBasedType?
|
||||
val newLowerBound = substituteOrNull(lowerBound)
|
||||
val newUpperBound = substituteOrNull(upperBound)
|
||||
if (newLowerBound != null || newUpperBound != null) {
|
||||
return ConeFlexibleType(newLowerBound ?: lowerBound, newUpperBound ?: upperBound)
|
||||
return ConeFlexibleType(
|
||||
newLowerBound?.lowerBoundIfFlexible() ?: lowerBound,
|
||||
newUpperBound?.upperBoundIfFlexible() ?: upperBound
|
||||
)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -86,12 +86,12 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext {
|
||||
|
||||
override fun FlexibleTypeMarker.upperBound(): SimpleTypeMarker {
|
||||
require(this is ConeFlexibleType)
|
||||
return this.upperBound
|
||||
return this.upperBound as SimpleTypeMarker
|
||||
}
|
||||
|
||||
override fun FlexibleTypeMarker.lowerBound(): SimpleTypeMarker {
|
||||
require(this is ConeFlexibleType)
|
||||
return this.lowerBound
|
||||
return this.lowerBound as SimpleTypeMarker
|
||||
}
|
||||
|
||||
override fun SimpleTypeMarker.asCapturedType(): CapturedTypeMarker? {
|
||||
|
||||
Reference in New Issue
Block a user