Fix CAST_NEVER_SUCCEEDS when casting Nothing to some type

This commit is contained in:
Dmitry Savvinov
2017-10-17 13:45:22 +03:00
parent bd2fd1758f
commit a1778a7da8
5 changed files with 81 additions and 0 deletions
@@ -44,6 +44,7 @@ object CastDiagnosticsUtil {
): Boolean {
val rhsNullable = TypeUtils.isNullableType(rhsType)
val lhsNullable = TypeUtils.isNullableType(lhsType)
if (KotlinBuiltIns.isNothing(lhsType)) return true
if (KotlinBuiltIns.isNullableNothing(lhsType) && !rhsNullable) return false
if (KotlinBuiltIns.isNothing(rhsType)) return false
if (KotlinBuiltIns.isNullableNothing(rhsType)) return lhsNullable