More precise diagnostics of smart cast impossible #KT-7240 Fixed
This commit is contained in:
+2
-2
@@ -7,11 +7,11 @@ public fun foo() {
|
||||
} else if (s == null) {
|
||||
return -2
|
||||
} else {
|
||||
return s<!UNSAFE_CALL!>.<!>length // Here smartcast is possible, at least in principle
|
||||
return <!SMARTCAST_IMPOSSIBLE!>s<!>.length // Here smartcast is possible, at least in principle
|
||||
}
|
||||
}
|
||||
if (s != null) {
|
||||
System.out.println(closure())
|
||||
System.out.println(s<!UNSAFE_CALL!>.<!>length) // Here smartcast is not possible due to a closure predecessor
|
||||
System.out.println(<!SMARTCAST_IMPOSSIBLE!>s<!>.length) // Here smartcast is not possible due to a closure predecessor
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -8,7 +8,7 @@ fun IntArray.forEachIndexed( op: (i: Int, value: Int) -> Unit) {
|
||||
fun max(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
|
||||
}
|
||||
return maxI
|
||||
|
||||
Reference in New Issue
Block a user