More precise diagnostics of smart cast impossible #KT-7240 Fixed

This commit is contained in:
Mikhail Glukhikh
2015-11-02 17:56:31 +03:00
parent 16a8e8f6f0
commit 41ebfd025e
31 changed files with 94 additions and 73 deletions
@@ -5,7 +5,7 @@ public class X {
public fun fn(): Int {
if (y != null)
// With non-default getter smartcast is not possible
return y<!UNSAFE_CALL!>.<!>length
return <!SMARTCAST_IMPOSSIBLE!>y<!>.length
else
return 0
}
@@ -13,7 +13,7 @@ class Example {
public fun foo(): String {
// Smart cast is not possible if property is delegated
return if (p != null) <!TYPE_MISMATCH!>p<!> else ""
return if (p != null) <!SMARTCAST_IMPOSSIBLE!>p<!> else ""
}
public fun bar(): String {
@@ -17,7 +17,7 @@ import a.X
public fun X.gav(): Int {
if (x != null)
// Smart cast is not possible if definition is in another module
return x<!UNSAFE_CALL!>.<!>length
return <!SMARTCAST_IMPOSSIBLE!>x<!>.length
else
return 0
}
@@ -29,7 +29,7 @@ package a
public fun X.gav(): Int {
if (x != null)
// Even if it's in the same package
return x<!UNSAFE_CALL!>.<!>length
return <!SMARTCAST_IMPOSSIBLE!>x<!>.length
else
return 0
}
@@ -4,10 +4,10 @@ public class X {
public fun fn(): Int {
if (x != null)
// Smartcast is not possible for variable properties
return x<!UNSAFE_CALL!>.<!>length
return <!SMARTCAST_IMPOSSIBLE!>x<!>.length
else if (y != null)
// Even if they are private
return y<!UNSAFE_CALL!>.<!>length
return <!SMARTCAST_IMPOSSIBLE!>y<!>.length
else
return 0
}