FIR2IR: add implicit NOT_NULL cast for @FlexibleNullability type

This commit is contained in:
Jinseong Jeon
2020-11-12 21:54:05 -08:00
committed by teamcityserver
parent b658e99f91
commit 4cb32cd38a
24 changed files with 81 additions and 48 deletions
@@ -138,3 +138,20 @@ private fun ConeTypeParameterType.hasNotNullUpperBound(): Boolean {
}
}
}
val FirTypeRef.canBeNull: Boolean
get() = coneType.canBeNull
val ConeKotlinType.canBeNull: Boolean
get() {
if (isMarkedNullable) {
return true
}
return when (this) {
is ConeFlexibleType -> upperBound.canBeNull
is ConeDefinitelyNotNullType -> false
is ConeTypeParameterType -> this.lookupTag.typeParameterSymbol.fir.bounds.any { it.canBeNull }
is ConeIntersectionType -> intersectedTypes.any { it.canBeNull }
else -> isNullable
}
}