ConeFlexibleType: statically require to have simple bounds
This commit is contained in:
@@ -128,16 +128,10 @@ abstract class ConeClassLikeType : ConeLookupTagBasedType() {
|
||||
}
|
||||
|
||||
open class ConeFlexibleType(
|
||||
val lowerBound: ConeKotlinType,
|
||||
val upperBound: ConeKotlinType
|
||||
val lowerBound: ConeSimpleKotlinType,
|
||||
val upperBound: ConeSimpleKotlinType
|
||||
) : ConeKotlinType(), FlexibleTypeMarker {
|
||||
|
||||
init {
|
||||
val message = { "Bounds violation: $lowerBound, $upperBound" }
|
||||
require(lowerBound is SimpleTypeMarker, message)
|
||||
require(upperBound is SimpleTypeMarker, message)
|
||||
}
|
||||
|
||||
override val typeArguments: Array<out ConeTypeProjection>
|
||||
get() = lowerBound.typeArguments
|
||||
|
||||
@@ -167,8 +161,19 @@ open class ConeFlexibleType(
|
||||
|
||||
}
|
||||
|
||||
fun ConeKotlinType.upperBoundIfFlexible() = (this as? ConeFlexibleType)?.upperBound ?: this
|
||||
fun ConeKotlinType.lowerBoundIfFlexible() = (this as? ConeFlexibleType)?.lowerBound ?: this
|
||||
fun ConeKotlinType.upperBoundIfFlexible(): ConeSimpleKotlinType {
|
||||
return when (this) {
|
||||
is ConeSimpleKotlinType -> this
|
||||
is ConeFlexibleType -> upperBound
|
||||
}
|
||||
}
|
||||
|
||||
fun ConeKotlinType.lowerBoundIfFlexible(): ConeSimpleKotlinType {
|
||||
return when (this) {
|
||||
is ConeSimpleKotlinType -> this
|
||||
is ConeFlexibleType -> lowerBound
|
||||
}
|
||||
}
|
||||
|
||||
class ConeCapturedTypeConstructor(
|
||||
val projection: ConeTypeProjection,
|
||||
@@ -264,7 +269,10 @@ data class ConeDefinitelyNotNullType(val original: ConeKotlinType) : ConeSimpleK
|
||||
companion object
|
||||
}
|
||||
|
||||
class ConeRawType(lowerBound: ConeKotlinType, upperBound: ConeKotlinType) : ConeFlexibleType(lowerBound, upperBound), RawTypeMarker
|
||||
class ConeRawType(
|
||||
lowerBound: ConeSimpleKotlinType,
|
||||
upperBound: ConeSimpleKotlinType
|
||||
) : ConeFlexibleType(lowerBound, upperBound), RawTypeMarker
|
||||
|
||||
/*
|
||||
* Contract of the intersection type: it is flat. It means that
|
||||
|
||||
Reference in New Issue
Block a user