Cast never succeeds: special 'Nothing' / 'Nothing?' case

(cherry picked from commit 63435b4)
This commit is contained in:
Mikhail Glukhikh
2016-07-26 15:50:03 +03:00
committed by Mikhail Glukhikh
parent bf4231d65a
commit b56e84d47f
5 changed files with 29 additions and 2 deletions
@@ -38,6 +38,8 @@ object CastDiagnosticsUtil {
rhsType: KotlinType,
platformToKotlinClassMap: PlatformToKotlinClassMap): Boolean {
if (KotlinBuiltIns.isNullableNothing(lhsType) && !TypeUtils.isNullableType(rhsType)) return false
if (KotlinBuiltIns.isNothing(rhsType)) return false
if (KotlinBuiltIns.isNullableNothing(rhsType)) return TypeUtils.isNullableType(lhsType)
if (lhsType.isError) return true
if (isRelated(lhsType, rhsType, platformToKotlinClassMap)) return true
// This is an oversimplification (which does not render the method incomplete):