Adjust testData to CharSequence.length transformation
This commit is contained in:
committed by
Mikhail Glukhikh
parent
cb562e7ea5
commit
f0e3fd617d
+3
-3
@@ -2,10 +2,10 @@ public fun foo(x: String?, y: String?): Int {
|
||||
while (true) {
|
||||
val z = x ?: if (y == null) break else <!DEBUG_INFO_SMARTCAST!>y<!>
|
||||
// z is not null in both branches
|
||||
z.length()
|
||||
z.length
|
||||
// y is nullable if x != null
|
||||
y<!UNSAFE_CALL!>.<!>length()
|
||||
y<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
// y is null because of the break
|
||||
return y<!UNSAFE_CALL!>.<!>length()
|
||||
return y<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
+2
-2
@@ -7,11 +7,11 @@ public fun foo(x: String?): Int {
|
||||
null -> break@loop
|
||||
"abc" -> return 0
|
||||
"xyz" -> return 1
|
||||
else -> <!DEBUG_INFO_SMARTCAST!>x<!>.length()
|
||||
else -> <!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
}
|
||||
// y is always Int after when
|
||||
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>y<!>)
|
||||
}
|
||||
// x is null because of the break
|
||||
return x<!UNSAFE_CALL!>.<!>length()
|
||||
return x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
+3
-3
@@ -8,9 +8,9 @@ public fun foo(x: String?, z: String?, w: String?): Int {
|
||||
gav(w!!, if (x == null) break else <!DEBUG_INFO_SMARTCAST!>x<!>, z!!)
|
||||
} while (bar())
|
||||
// w is not null because of w!!
|
||||
<!DEBUG_INFO_SMARTCAST!>w<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>w<!>.length
|
||||
// z is nullable despite of z!!
|
||||
z<!UNSAFE_CALL!>.<!>length()
|
||||
z<!UNSAFE_CALL!>.<!>length
|
||||
// x is null because of the break
|
||||
return x<!UNSAFE_CALL!>.<!>length()
|
||||
return x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ public fun foo(x: String?, z: String?): Int {
|
||||
gav(if (x == null) break else <!DEBUG_INFO_SMARTCAST!>x<!>, z!!)
|
||||
} while (bar())
|
||||
// z is nullable despite of z!!
|
||||
z<!UNSAFE_CALL!>.<!>length()
|
||||
z<!UNSAFE_CALL!>.<!>length
|
||||
// x is null because of the break
|
||||
return x<!UNSAFE_CALL!>.<!>length()
|
||||
return x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,5 +10,5 @@ public fun foo(x: String?): Int {
|
||||
} while (bar())
|
||||
y.hashCode()
|
||||
// x is null because of the break
|
||||
return x<!UNSAFE_CALL!>.<!>length()
|
||||
return x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ public fun foo(x: String?, z: String?): Int {
|
||||
gav(z!!, if (x == null) break else <!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||
} while (bar())
|
||||
// z is not null because of z!!
|
||||
<!DEBUG_INFO_SMARTCAST!>z<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>z<!>.length
|
||||
// x is null because of the break
|
||||
return x<!UNSAFE_CALL!>.<!>length()
|
||||
return x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
+3
-3
@@ -8,9 +8,9 @@ public fun foo(x: String?, z: String?, w: String?): Int {
|
||||
gav(z!!, w!!, if (x == null) break else <!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||
} while (bar())
|
||||
// w is not null because of w!!
|
||||
<!DEBUG_INFO_SMARTCAST!>w<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>w<!>.length
|
||||
// z is not null because of z!!
|
||||
<!DEBUG_INFO_SMARTCAST!>z<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>z<!>.length
|
||||
// x is null because of the break
|
||||
return x<!UNSAFE_CALL!>.<!>length()
|
||||
return x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ fun x(): Boolean { return true }
|
||||
public fun foo(p: String?): Int {
|
||||
// See KT-6283
|
||||
do {
|
||||
p!!.length()
|
||||
p!!.length
|
||||
} while (!x())
|
||||
// Do-while loop is executed at least once, so
|
||||
// p should be not null here
|
||||
return <!DEBUG_INFO_SMARTCAST!>p<!>.length()
|
||||
return <!DEBUG_INFO_SMARTCAST!>p<!>.length
|
||||
}
|
||||
@@ -3,9 +3,9 @@ fun x(): Boolean { return true }
|
||||
public fun foo(p: String?): Int {
|
||||
// See KT-6283
|
||||
do {
|
||||
p!!.length()
|
||||
p!!.length
|
||||
if (p == "abc") break
|
||||
} while (!x())
|
||||
// p should be smart casted despite of break
|
||||
return <!DEBUG_INFO_SMARTCAST!>p<!>.length()
|
||||
return <!DEBUG_INFO_SMARTCAST!>p<!>.length
|
||||
}
|
||||
@@ -3,9 +3,9 @@ fun x(): Boolean { return true }
|
||||
public fun foo(p: String?): Int {
|
||||
// See KT-6283
|
||||
do {
|
||||
p!!.length()
|
||||
p!!.length
|
||||
if (p == "abc") continue
|
||||
} while (!x())
|
||||
// p should be smart casted despite of continue
|
||||
return <!DEBUG_INFO_SMARTCAST!>p<!>.length()
|
||||
return <!DEBUG_INFO_SMARTCAST!>p<!>.length
|
||||
}
|
||||
@@ -6,8 +6,8 @@ public fun foo(p: String?): Int {
|
||||
do {
|
||||
if (y()) break
|
||||
// We do not always reach this statement
|
||||
p!!.length()
|
||||
p!!.length
|
||||
} while (!x())
|
||||
// Here we have do while loop but p is still nullable due to break before
|
||||
return p<!UNSAFE_CALL!>.<!>length()
|
||||
return p<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
+2
-2
@@ -6,8 +6,8 @@ public fun foo(p: String?): Int {
|
||||
do {
|
||||
if (y()) continue
|
||||
// We do not always reach this statement
|
||||
p!!.length()
|
||||
p!!.length
|
||||
} while (!x())
|
||||
// Here we have do while loop but p is still nullable due to continue before
|
||||
return p<!UNSAFE_CALL!>.<!>length()
|
||||
return p<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fun foo(s: String?): Int {
|
||||
do {
|
||||
} while (s!!.length() > 0)
|
||||
return <!DEBUG_INFO_SMARTCAST!>s<!>.length()
|
||||
} while (s!!.length > 0)
|
||||
return <!DEBUG_INFO_SMARTCAST!>s<!>.length
|
||||
}
|
||||
+2
-2
@@ -3,7 +3,7 @@ fun bar(): Boolean { return true }
|
||||
fun foo(s: String?): Int {
|
||||
do {
|
||||
if (bar()) break
|
||||
} while (s!!.length() > 0)
|
||||
} while (s!!.length > 0)
|
||||
// This call is unsafe due to break
|
||||
return s<!UNSAFE_CALL!>.<!>length()
|
||||
return s<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
@@ -3,8 +3,8 @@ fun x(): Boolean { return true }
|
||||
public fun foo(p: String?): Int {
|
||||
// Exotic variant with unused literal
|
||||
do <!UNUSED_FUNCTION_LITERAL!>{ ->
|
||||
p!!.length()
|
||||
p!!.length
|
||||
}<!> while (!x())
|
||||
// Literal is not called so p.length() is unsafe
|
||||
return p<!UNSAFE_CALL!>.<!>length()
|
||||
// Literal is not called so p.length is unsafe
|
||||
return p<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
+1
-1
@@ -6,5 +6,5 @@ public fun foo(p: String?): Int {
|
||||
if (p != null) break
|
||||
} while (!x())
|
||||
// p can be null despite of the break
|
||||
return p<!UNSAFE_CALL!>.<!>length()
|
||||
return p<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fun foo(s: String?): Int {
|
||||
do {
|
||||
} while (s==null)
|
||||
return <!DEBUG_INFO_SMARTCAST!>s<!>.length()
|
||||
return <!DEBUG_INFO_SMARTCAST!>s<!>.length
|
||||
}
|
||||
+1
-1
@@ -5,5 +5,5 @@ fun foo(s: String?): Int {
|
||||
if (bar()) break
|
||||
} while (s==null)
|
||||
// This call is unsafe due to break
|
||||
return s<!UNSAFE_CALL!>.<!>length()
|
||||
return s<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
+2
-2
@@ -3,8 +3,8 @@ public fun foo(x: String?): Int {
|
||||
// After the check, smart cast should work
|
||||
x ?: break
|
||||
// x is not null in both branches
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
} while (true)
|
||||
// x is null because of the break
|
||||
return x<!UNSAFE_CALL!>.<!>length()
|
||||
return x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
+2
-2
@@ -2,8 +2,8 @@ public fun foo(x: String?, y: String?): Int {
|
||||
while (true) {
|
||||
x ?: if (y == null) break
|
||||
// y is nullable if x != null
|
||||
y<!UNSAFE_CALL!>.<!>length()
|
||||
y<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
// y is null because of the break
|
||||
return y<!UNSAFE_CALL!>.<!>length()
|
||||
return y<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
public fun foo(x: String?): Int {
|
||||
do {
|
||||
// After the check, smart cast should work
|
||||
x ?: x!!.length()
|
||||
x ?: x!!.length
|
||||
// x is not null in both branches
|
||||
if (<!DEBUG_INFO_SMARTCAST!>x<!>.length() == 0) break
|
||||
if (<!DEBUG_INFO_SMARTCAST!>x<!>.length == 0) break
|
||||
} while (true)
|
||||
return <!DEBUG_INFO_SMARTCAST!>x<!>.length()
|
||||
return <!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
}
|
||||
+2
-2
@@ -2,8 +2,8 @@ public fun foo(x: String?, y: String?): Int {
|
||||
while (true) {
|
||||
(if (x != null) break else y) ?: y!!
|
||||
// y is not null in both branches but it's hard to determine
|
||||
y<!UNSAFE_CALL!>.<!>length()
|
||||
y<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
// y can be null because of the break
|
||||
return y<!UNSAFE_CALL!>.<!>length()
|
||||
return y<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
+3
-3
@@ -5,8 +5,8 @@ public fun foo(p: String?, y: String?): Int {
|
||||
"null".toString()
|
||||
break
|
||||
}
|
||||
<!DEBUG_INFO_SMARTCAST!>y<!>.length()
|
||||
p!!.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>y<!>.length
|
||||
p!!.length
|
||||
} while (true)
|
||||
return y?.length() ?: -1
|
||||
return y?.length ?: -1
|
||||
}
|
||||
+1
-1
@@ -10,5 +10,5 @@ public fun foo(x: String?): Int {
|
||||
} while (bar())
|
||||
y.hashCode()
|
||||
// x is null because of the break
|
||||
return x<!UNSAFE_CALL!>.<!>length()
|
||||
return x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,5 +6,5 @@ public fun foo(x: String?): Int {
|
||||
// In future we can infer this initialization
|
||||
<!UNINITIALIZED_VARIABLE!>y<!>.hashCode()
|
||||
// x is null because of the break
|
||||
return x<!UNSAFE_CALL!>.<!>length()
|
||||
return x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@ public fun foo(x: String?): Int {
|
||||
// After the check, smart cast should work
|
||||
val y = if (x == null) break else <!DEBUG_INFO_SMARTCAST!>x<!>
|
||||
// y is not null in both branches
|
||||
y.length()
|
||||
y.length
|
||||
}
|
||||
// x is null because of the break
|
||||
return x<!UNSAFE_CALL!>.<!>length()
|
||||
return x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
+4
-4
@@ -3,13 +3,13 @@ public fun foo(x: String?, y: String?): Int {
|
||||
// After the check, smart cast should work
|
||||
if (x != null) {
|
||||
if (x == "abc") break
|
||||
y!!.length()
|
||||
y!!.length
|
||||
} else {
|
||||
y!!.length()
|
||||
y!!.length
|
||||
}
|
||||
// y!! in both branches
|
||||
<!DEBUG_INFO_SMARTCAST!>y<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>y<!>.length
|
||||
} while (true)
|
||||
// break is possible before so !! is necessary
|
||||
return y!!.length()
|
||||
return y!!.length
|
||||
}
|
||||
@@ -2,8 +2,8 @@ public fun foo(p: String?, y: String?): Int {
|
||||
do {
|
||||
// After the check, smart cast should work
|
||||
if (y == null) break
|
||||
<!DEBUG_INFO_SMARTCAST!>y<!>.length()
|
||||
p!!.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>y<!>.length
|
||||
p!!.length
|
||||
} while (true)
|
||||
return y?.length() ?: -1
|
||||
return y?.length ?: -1
|
||||
}
|
||||
+3
-3
@@ -2,10 +2,10 @@ public fun foo(x: String?, y: String?): Int {
|
||||
while (true) {
|
||||
val z = (if (y == null) break else x) ?: <!DEBUG_INFO_SMARTCAST!>y<!>
|
||||
// z is not null in both branches
|
||||
z.length()
|
||||
z.length
|
||||
// y is not null in both branches
|
||||
<!DEBUG_INFO_SMARTCAST!>y<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>y<!>.length
|
||||
}
|
||||
// y is null because of the break
|
||||
return y<!UNSAFE_CALL!>.<!>length()
|
||||
return y<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
@@ -3,11 +3,11 @@ fun x(): Boolean { return true }
|
||||
public fun foo(p: String?, r: String?): Int {
|
||||
do {
|
||||
do {
|
||||
p!!.length()
|
||||
p!!.length
|
||||
} while (r == null)
|
||||
} while (!x())
|
||||
// Auto cast possible
|
||||
<!DEBUG_INFO_SMARTCAST!>r<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>r<!>.length
|
||||
// Auto cast possible
|
||||
return <!DEBUG_INFO_SMARTCAST!>p<!>.length()
|
||||
return <!DEBUG_INFO_SMARTCAST!>p<!>.length
|
||||
}
|
||||
+3
-3
@@ -3,12 +3,12 @@ fun x(): Boolean { return true }
|
||||
public fun foo(p: String?, r: String?): Int {
|
||||
outer@ do {
|
||||
do {
|
||||
p!!.length()
|
||||
p!!.length
|
||||
if (!x()) continue@outer
|
||||
} while (r == null)
|
||||
} while (!x())
|
||||
// Auto cast NOT possible due to long continue
|
||||
r<!UNSAFE_CALL!>.<!>length()
|
||||
r<!UNSAFE_CALL!>.<!>length
|
||||
// Auto cast possible
|
||||
return <!DEBUG_INFO_SMARTCAST!>p<!>.length()
|
||||
return <!DEBUG_INFO_SMARTCAST!>p<!>.length
|
||||
}
|
||||
@@ -2,16 +2,16 @@ fun x(): Boolean { return true }
|
||||
|
||||
public fun foo(p: String?, r: String?, q: String?): Int {
|
||||
while(true) {
|
||||
q!!.length()
|
||||
q!!.length
|
||||
do {
|
||||
do {
|
||||
p!!.length()
|
||||
p!!.length
|
||||
} while (!x())
|
||||
} while (r == null)
|
||||
if (!x()) break
|
||||
}
|
||||
// Smart cast is possible everywhere
|
||||
<!DEBUG_INFO_SMARTCAST!>r<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>q<!>.length()
|
||||
return <!DEBUG_INFO_SMARTCAST!>p<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>r<!>.length
|
||||
<!DEBUG_INFO_SMARTCAST!>q<!>.length
|
||||
return <!DEBUG_INFO_SMARTCAST!>p<!>.length
|
||||
}
|
||||
@@ -2,14 +2,14 @@ fun x(): Boolean { return true }
|
||||
|
||||
public fun foo(p: String?, r: String?, q: String?): Int {
|
||||
while(true) {
|
||||
q!!.length()
|
||||
q!!.length
|
||||
do {
|
||||
p!!.length()
|
||||
p!!.length
|
||||
} while (r == null)
|
||||
if (!x()) break
|
||||
}
|
||||
// Smart cast is possible everywhere
|
||||
<!DEBUG_INFO_SMARTCAST!>r<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>q<!>.length()
|
||||
return <!DEBUG_INFO_SMARTCAST!>p<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>r<!>.length
|
||||
<!DEBUG_INFO_SMARTCAST!>q<!>.length
|
||||
return <!DEBUG_INFO_SMARTCAST!>p<!>.length
|
||||
}
|
||||
+5
-5
@@ -2,17 +2,17 @@ fun x(): Boolean { return true }
|
||||
|
||||
public fun foo(p: String?, r: String?, q: String?): Int {
|
||||
while(true) {
|
||||
q!!.length()
|
||||
q!!.length
|
||||
do {
|
||||
while(true) {
|
||||
p!!.length()
|
||||
p!!.length
|
||||
if (x()) break
|
||||
}
|
||||
} while (r == null)
|
||||
if (!x()) break
|
||||
}
|
||||
// Smart cast is possible everywhere
|
||||
<!DEBUG_INFO_SMARTCAST!>r<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>q<!>.length()
|
||||
return <!DEBUG_INFO_SMARTCAST!>p<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>r<!>.length
|
||||
<!DEBUG_INFO_SMARTCAST!>q<!>.length
|
||||
return <!DEBUG_INFO_SMARTCAST!>p<!>.length
|
||||
}
|
||||
+5
-5
@@ -2,10 +2,10 @@ fun x(p: String): Boolean { return p == "abc" }
|
||||
|
||||
public fun foo(p: String?, r: String?, q: String?): Int {
|
||||
while(true) {
|
||||
q!!.length()
|
||||
q!!.length
|
||||
loop@ do {
|
||||
while(true) {
|
||||
p!!.length()
|
||||
p!!.length
|
||||
if (x(<!DEBUG_INFO_SMARTCAST!>p<!>)) break@loop
|
||||
if (x(<!DEBUG_INFO_SMARTCAST!>q<!>)) break
|
||||
}
|
||||
@@ -13,8 +13,8 @@ public fun foo(p: String?, r: String?, q: String?): Int {
|
||||
if (!x(<!DEBUG_INFO_SMARTCAST!>p<!>)) break
|
||||
}
|
||||
// Long break allows r == null
|
||||
r<!UNSAFE_CALL!>.<!>length()
|
||||
r<!UNSAFE_CALL!>.<!>length
|
||||
// Smart cast is possible
|
||||
<!DEBUG_INFO_SMARTCAST!>q<!>.length()
|
||||
return <!DEBUG_INFO_SMARTCAST!>p<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>q<!>.length
|
||||
return <!DEBUG_INFO_SMARTCAST!>p<!>.length
|
||||
}
|
||||
+5
-5
@@ -2,18 +2,18 @@ fun x(): Boolean { return true }
|
||||
|
||||
public fun foo(p: String?, r: String?, q: String?): Int {
|
||||
outer@ while(true) {
|
||||
q!!.length()
|
||||
q!!.length
|
||||
do {
|
||||
if (x()) continue@outer
|
||||
do {
|
||||
p!!.length()
|
||||
p!!.length
|
||||
} while (!x())
|
||||
} while (r == null)
|
||||
if (!x()) break
|
||||
}
|
||||
// Smart cast is possible only for q
|
||||
<!DEBUG_INFO_SMARTCAST!>q<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>q<!>.length
|
||||
// But not possible for the others
|
||||
r<!UNSAFE_CALL!>.<!>length()
|
||||
return p<!UNSAFE_CALL!>.<!>length()
|
||||
r<!UNSAFE_CALL!>.<!>length
|
||||
return p<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
+2
-2
@@ -10,7 +10,7 @@ public fun foo(x: String?): Int {
|
||||
null -> break@loop
|
||||
"abc" -> return 0
|
||||
"xyz" -> return 1
|
||||
else -> <!DEBUG_INFO_SMARTCAST!>x<!>.length()
|
||||
else -> <!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
}
|
||||
// y is always Int after when
|
||||
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>y<!>)
|
||||
@@ -18,5 +18,5 @@ public fun foo(x: String?): Int {
|
||||
// y is always Int even here
|
||||
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>y<!>)
|
||||
// x is null because of the break
|
||||
return x<!UNSAFE_CALL!>.<!>length()
|
||||
return x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
+5
-5
@@ -3,12 +3,12 @@ fun foo(x: String): String? = x
|
||||
fun calc(x: String?, y: String?): Int {
|
||||
do {
|
||||
// Smart cast because of x!! in receiver
|
||||
foo(x!!)?.subSequence(0, if (<!DEBUG_INFO_SMARTCAST!>x<!>.length() > 0) 5 else break)
|
||||
y!!.length()
|
||||
foo(x!!)?.subSequence(0, if (<!DEBUG_INFO_SMARTCAST!>x<!>.length > 0) 5 else break)
|
||||
y!!.length
|
||||
// x is not null in condition but we do not see it yet
|
||||
} while (x<!UNSAFE_CALL!>.<!>length() > 0)
|
||||
} while (x<!UNSAFE_CALL!>.<!>length > 0)
|
||||
// y is nullable because of break
|
||||
y<!UNSAFE_CALL!>.<!>length()
|
||||
y<!UNSAFE_CALL!>.<!>length
|
||||
// x is not null, at least in theory
|
||||
return <!DEBUG_INFO_SMARTCAST!>x<!>.length()
|
||||
return <!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
}
|
||||
|
||||
+3
-3
@@ -3,10 +3,10 @@ fun foo(x: String): String? = x
|
||||
fun calc(x: String?): Int {
|
||||
do {
|
||||
// Smart cast because of x!! in receiver
|
||||
foo(x!!)?.subSequence(0, <!DEBUG_INFO_SMARTCAST!>x<!>.length())
|
||||
foo(x!!)?.subSequence(0, <!DEBUG_INFO_SMARTCAST!>x<!>.length)
|
||||
// Smart cast because of x!! in receiver
|
||||
if (<!DEBUG_INFO_SMARTCAST!>x<!>.length() == 0) break
|
||||
if (<!DEBUG_INFO_SMARTCAST!>x<!>.length == 0) break
|
||||
} while (true)
|
||||
// Here x is also not null
|
||||
return <!DEBUG_INFO_SMARTCAST!>x<!>.length()
|
||||
return <!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
public fun foo(p: String?, y: String?): Int {
|
||||
do {
|
||||
// After this !!, y. should be smartcasted in loop as well as outside
|
||||
y!!.length()
|
||||
y!!.length
|
||||
if (p == null) break
|
||||
<!DEBUG_INFO_SMARTCAST!>y<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>y<!>.length
|
||||
} while (true)
|
||||
return <!DEBUG_INFO_SMARTCAST!>y<!>.length()
|
||||
return <!DEBUG_INFO_SMARTCAST!>y<!>.length
|
||||
}
|
||||
+2
-2
@@ -4,9 +4,9 @@ public fun foo(x: String?): Int {
|
||||
null -> break@loop
|
||||
"abc" -> return 0
|
||||
"xyz" -> return 1
|
||||
else -> <!DEBUG_INFO_SMARTCAST!>x<!>.length()
|
||||
else -> <!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
}
|
||||
}
|
||||
// x is null because of the break
|
||||
return x<!UNSAFE_CALL!>.<!>length()
|
||||
return x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,5 +9,5 @@ public fun foo(x: String?): Int {
|
||||
}
|
||||
// x is not null because of the break
|
||||
// but we are not able to detect it
|
||||
return x<!UNSAFE_CALL!>.<!>length()
|
||||
return x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
fun foo(s: String?): Int {
|
||||
while (s!!.length() > 0) {
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!>.length()
|
||||
while (s!!.length > 0) {
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!>.length
|
||||
}
|
||||
return <!DEBUG_INFO_SMARTCAST!>s<!>.length()
|
||||
return <!DEBUG_INFO_SMARTCAST!>s<!>.length
|
||||
}
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
fun bar(): Boolean { return true }
|
||||
|
||||
fun foo(s: String?): Int {
|
||||
while (s!!.length() > 0) {
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!>.length()
|
||||
while (s!!.length > 0) {
|
||||
<!DEBUG_INFO_SMARTCAST!>s<!>.length
|
||||
if (bar()) break
|
||||
}
|
||||
return <!DEBUG_INFO_SMARTCAST!>s<!>.length()
|
||||
return <!DEBUG_INFO_SMARTCAST!>s<!>.length
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fun foo(s: String?): Int {
|
||||
while (s==null) {
|
||||
}
|
||||
return <!DEBUG_INFO_SMARTCAST!>s<!>.length()
|
||||
return <!DEBUG_INFO_SMARTCAST!>s<!>.length
|
||||
}
|
||||
@@ -5,5 +5,5 @@ fun foo(s: String?): Int {
|
||||
if (bar()) break
|
||||
}
|
||||
// Call is unsafe due to break
|
||||
return s<!UNSAFE_CALL!>.<!>length()
|
||||
return s<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
@@ -2,9 +2,9 @@ fun x(): Boolean { return true }
|
||||
|
||||
public fun foo(p: String?): Int {
|
||||
while(x()) {
|
||||
p!!.length()
|
||||
p!!.length
|
||||
if (x()) break
|
||||
}
|
||||
// p is nullable because it's possible loop body is not executed at all
|
||||
return p<!UNSAFE_CALL!>.<!>length()
|
||||
return p<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
@@ -3,9 +3,9 @@ fun x(): Boolean { return true }
|
||||
public fun foo(p: String?): Int {
|
||||
// Like whileTrue but 2 == 2 is in use
|
||||
while(2 == 2) {
|
||||
p!!.length()
|
||||
p!!.length
|
||||
if (x()) break
|
||||
}
|
||||
// Smart cast should not work in this case, see KT-6284
|
||||
return p<!UNSAFE_CALL!>.<!>length()
|
||||
return p<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
@@ -3,10 +3,10 @@ fun x(): Boolean { return true }
|
||||
public fun foo(p: String?): Int {
|
||||
// KT-6284
|
||||
while(true) {
|
||||
p!!.length()
|
||||
p!!.length
|
||||
if (x()) break
|
||||
}
|
||||
// while (true) loop body is executed at least once
|
||||
// so p is not null here
|
||||
return <!DEBUG_INFO_SMARTCAST!>p<!>.length()
|
||||
return <!DEBUG_INFO_SMARTCAST!>p<!>.length
|
||||
}
|
||||
+2
-2
@@ -5,8 +5,8 @@ public fun foo(p: String?): Int {
|
||||
if (x()) break
|
||||
if (p==null) return -1
|
||||
// p is not null
|
||||
<!DEBUG_INFO_SMARTCAST!>p<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>p<!>.length
|
||||
}
|
||||
// p can be null because break is earlier than return
|
||||
return p<!UNSAFE_CALL!>.<!>length()
|
||||
return p<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
+2
-2
@@ -4,8 +4,8 @@ public fun foo(p: String?): Int {
|
||||
while(true) {
|
||||
if (x()) break
|
||||
// We do not always reach this statement
|
||||
p!!.length()
|
||||
p!!.length
|
||||
}
|
||||
// Here we have while (true) loop but p is nullable due to break before
|
||||
return p<!UNSAFE_CALL!>.<!>length()
|
||||
return p<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
@@ -5,9 +5,9 @@ public fun foo(p: String?): Int {
|
||||
if (p==null) return -1
|
||||
if (x()) break
|
||||
// p is not null
|
||||
<!DEBUG_INFO_SMARTCAST!>p<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>p<!>.length
|
||||
}
|
||||
// while (true) loop body with return is executed at least once
|
||||
// so p is not null here
|
||||
return <!DEBUG_INFO_SMARTCAST!>p<!>.length()
|
||||
return <!DEBUG_INFO_SMARTCAST!>p<!>.length
|
||||
}
|
||||
Reference in New Issue
Block a user