CAST_NEVER_SUCCEEDS: do not report when casting nullable to nullable #KT-260 Fixed
This commit is contained in:
@@ -37,9 +37,12 @@ object CastDiagnosticsUtil {
|
||||
lhsType: KotlinType,
|
||||
rhsType: KotlinType,
|
||||
platformToKotlinClassMap: PlatformToKotlinClassMap): Boolean {
|
||||
if (KotlinBuiltIns.isNullableNothing(lhsType) && !TypeUtils.isNullableType(rhsType)) return false
|
||||
val rhsNullable = TypeUtils.isNullableType(rhsType)
|
||||
val lhsNullable = TypeUtils.isNullableType(lhsType)
|
||||
if (KotlinBuiltIns.isNullableNothing(lhsType) && !rhsNullable) return false
|
||||
if (KotlinBuiltIns.isNothing(rhsType)) return false
|
||||
if (KotlinBuiltIns.isNullableNothing(rhsType)) return TypeUtils.isNullableType(lhsType)
|
||||
if (KotlinBuiltIns.isNullableNothing(rhsType)) return lhsNullable
|
||||
if (lhsNullable && rhsNullable) return true
|
||||
if (lhsType.isError) return true
|
||||
if (isRelated(lhsType, rhsType, platformToKotlinClassMap)) return true
|
||||
// This is an oversimplification (which does not render the method incomplete):
|
||||
|
||||
Reference in New Issue
Block a user