K2: introduce unwrapFlexibleAndDefinitelyNotNull

This commit is contained in:
Mikhail Glukhikh
2023-12-11 15:11:36 +01:00
committed by Space Team
parent b76452e15f
commit 37789cf7f5
3 changed files with 6 additions and 2 deletions
@@ -77,5 +77,5 @@ object FirCyclicTypeBoundsChecker : FirBasicDeclarationChecker() {
ref.unwrapBound().mapNotNull { extractTypeParamName(it.coneType) }.toSet() ref.unwrapBound().mapNotNull { extractTypeParamName(it.coneType) }.toSet()
private fun extractTypeParamName(type: ConeKotlinType): Name? = private fun extractTypeParamName(type: ConeKotlinType): Name? =
(type.lowerBoundIfFlexible().unwrapDefinitelyNotNull() as? ConeTypeParameterType)?.lookupTag?.name (type.unwrapFlexibleAndDefinitelyNotNull() as? ConeTypeParameterType)?.lookupTag?.name
} }
@@ -24,7 +24,7 @@ object FirTopLevelTypeAliasChecker : FirTypeAliasChecker() {
} }
fun containsTypeParameter(type: ConeKotlinType): Boolean { fun containsTypeParameter(type: ConeKotlinType): Boolean {
val unwrapped = type.lowerBoundIfFlexible().unwrapDefinitelyNotNull() val unwrapped = type.unwrapFlexibleAndDefinitelyNotNull()
if (unwrapped is ConeTypeParameterType) { if (unwrapped is ConeTypeParameterType) {
return true return true
@@ -118,6 +118,10 @@ fun ConeSimpleKotlinType.unwrapDefinitelyNotNull(): ConeSimpleKotlinType {
} }
} }
fun ConeKotlinType.unwrapFlexibleAndDefinitelyNotNull(): ConeKotlinType {
return lowerBoundIfFlexible().unwrapDefinitelyNotNull()
}
class ConeCapturedTypeConstructor( class ConeCapturedTypeConstructor(
val projection: ConeTypeProjection, val projection: ConeTypeProjection,
var supertypes: List<ConeKotlinType>? = null, var supertypes: List<ConeKotlinType>? = null,