More precise diagnostics of smart cast impossible #KT-7240 Fixed
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
fun indexOfMax(a: IntArray): Int? {
|
||||
var maxI: Int? = null
|
||||
a.forEachIndexed { i, value ->
|
||||
if (maxI == null || value >= a[<!TYPE_MISMATCH!>maxI<!>]) {
|
||||
if (maxI == null || value >= a[<!SMARTCAST_IMPOSSIBLE!>maxI<!>]) {
|
||||
maxI = i
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,6 +4,6 @@ fun foo(y: String?) {
|
||||
var x: String? = ""
|
||||
if (x != null) {
|
||||
y?.let { x = null }
|
||||
x<!UNSAFE_CALL!>.<!>length // Smart cast is not possible
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length // Smart cast is not possible
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,6 +6,6 @@ fun foo(y: String?) {
|
||||
var x: String? = ""
|
||||
if (x != null) {
|
||||
bar(y?.let { x = null; it })<!UNSAFE_CALL!>.<!>length
|
||||
x<!UNSAFE_CALL!>.<!>length // Smart cast is not possible
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length // Smart cast is not possible
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,6 +4,6 @@ fun foo(y: String?) {
|
||||
var x: String? = null
|
||||
if (x != null) {
|
||||
y?.let { x = it }
|
||||
x<!UNSAFE_CALL!>.<!>length // not-null or not-null
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length // not-null or not-null
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@ fun foo(y: String?) {
|
||||
if (x != null) {
|
||||
with(y?.let { x = null; it }) {
|
||||
this<!UNSAFE_CALL!>.<!>length
|
||||
x<!UNSAFE_CALL!>.<!>length
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
x<!UNSAFE_CALL!>.<!>length
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user