Fix KotlinType.isNullabilityFlexible for types based on type parameters
In the compiler, this function was used in psi2ir (and it affected nullability annotations in the resulting JVM class files), in "useless elvis with null on the right side" diagnostic checker, and in light classes. #KT-42650 Fixed
This commit is contained in:
@@ -26,13 +26,12 @@ import org.jetbrains.kotlin.types.checker.KotlinTypeRefiner
|
||||
import org.jetbrains.kotlin.types.refinement.TypeRefinement
|
||||
import org.jetbrains.kotlin.types.typeUtil.builtIns
|
||||
|
||||
|
||||
fun KotlinType.isFlexible(): Boolean = unwrap() is FlexibleType
|
||||
fun KotlinType.asFlexibleType(): FlexibleType = unwrap() as FlexibleType
|
||||
|
||||
fun KotlinType.isNullabilityFlexible(): Boolean {
|
||||
val flexibility = unwrap() as? FlexibleType ?: return false
|
||||
return TypeUtils.isNullableType(flexibility.lowerBound) != TypeUtils.isNullableType(flexibility.upperBound)
|
||||
return flexibility.lowerBound.isMarkedNullable != flexibility.upperBound.isMarkedNullable
|
||||
}
|
||||
|
||||
// This function is intended primarily for sets: since KotlinType.equals() represents _syntactical_ equality of types,
|
||||
|
||||
Reference in New Issue
Block a user