More precise diagnostics of smart cast impossible #KT-7240 Fixed
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user