Adjust testData to CharSequence.length transformation
This commit is contained in:
committed by
Mikhail Glukhikh
parent
cb562e7ea5
commit
f0e3fd617d
@@ -1,10 +1,10 @@
|
||||
fun foo() {
|
||||
var v: String? = null
|
||||
v<!UNSAFE_CALL!>.<!>length()
|
||||
v<!UNSAFE_CALL!>.<!>length
|
||||
v = "abc"
|
||||
<!DEBUG_INFO_SMARTCAST!>v<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>v<!>.length
|
||||
v = null
|
||||
v<!UNSAFE_CALL!>.<!>length()
|
||||
v<!UNSAFE_CALL!>.<!>length
|
||||
v = "abc"
|
||||
<!DEBUG_INFO_SMARTCAST!>v<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>v<!>.length
|
||||
}
|
||||
+2
-2
@@ -3,10 +3,10 @@ fun x(): Boolean { return true }
|
||||
public fun foo(pp: String?): Int {
|
||||
var p = pp
|
||||
do {
|
||||
p!!.length()
|
||||
p!!.length
|
||||
if (p == "abc") break
|
||||
p = null
|
||||
} while (!x())
|
||||
// Smart cast is NOT possible here
|
||||
return p<!UNSAFE_CALL!>.<!>length()
|
||||
return p<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
public fun fooNotNull(s: String) {
|
||||
System.out.println("Length of $s is ${s.length()}")
|
||||
System.out.println("Length of $s is ${s.length}")
|
||||
}
|
||||
|
||||
public fun foo() {
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ fun get(): String? {
|
||||
fun foo(): Int {
|
||||
var ss:String? = get()
|
||||
|
||||
return if (ss != null && <!DEBUG_INFO_SMARTCAST!>ss<!>.length() > 0)
|
||||
return if (ss != null && <!DEBUG_INFO_SMARTCAST!>ss<!>.length > 0)
|
||||
1
|
||||
else
|
||||
0
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
public fun fooNotNull(s: String) {
|
||||
System.out.println("Length of $s is ${s.length()}")
|
||||
System.out.println("Length of $s is ${s.length}")
|
||||
}
|
||||
|
||||
public fun foo() {
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
public fun fooNotNull(s: String) {
|
||||
System.out.println("Length of $s is ${s.length()}")
|
||||
System.out.println("Length of $s is ${s.length}")
|
||||
}
|
||||
|
||||
public fun foo() {
|
||||
|
||||
@@ -2,20 +2,20 @@
|
||||
fun f() {
|
||||
var s: String?
|
||||
s = "a"
|
||||
var s1 = "" // String – ?
|
||||
var s1 = "" // String � ?
|
||||
if (<!SENSELESS_COMPARISON!>s != null<!>) { // Redundant
|
||||
s1.length()
|
||||
s1.length
|
||||
// We can do smartcast here and below
|
||||
s1 = <!DEBUG_INFO_SMARTCAST!>s<!>.toString() // return String?
|
||||
s1.length()
|
||||
s1.length
|
||||
s1 = <!DEBUG_INFO_SMARTCAST!>s<!>
|
||||
s1.length()
|
||||
s1.length
|
||||
// It's just an assignment without smartcast
|
||||
val s2 = s
|
||||
// But smartcast can be done here
|
||||
<!DEBUG_INFO_SMARTCAST!>s2<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>s2<!>.length
|
||||
// And also here
|
||||
val s3 = <!DEBUG_INFO_SMARTCAST!>s<!>.toString()
|
||||
s3.length()
|
||||
s3.length
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
fun foo() {
|
||||
var v: String? = "xyz"
|
||||
// It is possible in principle to provide smart cast here
|
||||
v<!UNSAFE_CALL!>.<!>length()
|
||||
v<!UNSAFE_CALL!>.<!>length
|
||||
v = null
|
||||
v<!UNSAFE_CALL!>.<!>length()
|
||||
v<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
@@ -5,11 +5,11 @@ public fun foo(pp: String?, rr: String?): Int {
|
||||
var r = rr
|
||||
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,17 +3,17 @@ fun x(): Boolean { return true }
|
||||
public fun foo(qq: String?): Int {
|
||||
var q = qq
|
||||
while(true) {
|
||||
q!!.length()
|
||||
q!!.length
|
||||
var r = q
|
||||
do {
|
||||
var p = r
|
||||
do {
|
||||
// p = r, r = q and q is not null
|
||||
<!DEBUG_INFO_SMARTCAST!>p<!>.length()
|
||||
<!DEBUG_INFO_SMARTCAST!>p<!>.length
|
||||
} while (!x())
|
||||
} while (<!SENSELESS_COMPARISON!>r == null<!>) // r = q and q is not null
|
||||
if (!x()) break
|
||||
}
|
||||
// Smart cast is possible
|
||||
return <!DEBUG_INFO_SMARTCAST!>q<!>.length()
|
||||
return <!DEBUG_INFO_SMARTCAST!>q<!>.length
|
||||
}
|
||||
+1
-1
@@ -13,7 +13,7 @@ class MyClass {
|
||||
m = create()
|
||||
// See KT-7428
|
||||
for ((k, v) in <!SMARTCAST_IMPOSSIBLE!>m<!>)
|
||||
res += (k.length() + v.length())
|
||||
res += (k.length + v.length)
|
||||
return res
|
||||
}
|
||||
}
|
||||
+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 s<!UNSAFE_CALL!>.<!>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(s<!UNSAFE_CALL!>.<!>length) // Here smartcast is not possible due to a closure predecessor
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -10,6 +10,6 @@ public fun foo() {
|
||||
if (s != null) {
|
||||
System.out.println(closure())
|
||||
// Smart cast is possible but closure makes it harder to understand
|
||||
System.out.println(s<!UNSAFE_CALL!>.<!>length())
|
||||
System.out.println(s<!UNSAFE_CALL!>.<!>length)
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,6 @@ fun get(): String? {
|
||||
|
||||
fun foo(): Int {
|
||||
var c: String? = get()
|
||||
c!!.length()
|
||||
return <!DEBUG_INFO_SMARTCAST!>c<!>.length() // Previous line should make !! unnecessary here.
|
||||
c!!.length
|
||||
return <!DEBUG_INFO_SMARTCAST!>c<!>.length // Previous line should make !! unnecessary here.
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fun foo(): Int {
|
||||
var s: String? = <!VARIABLE_WITH_REDUNDANT_INITIALIZER!>"abc"<!>
|
||||
s = null
|
||||
return s<!UNSAFE_CALL!>.<!>length()
|
||||
return s<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
@@ -3,11 +3,11 @@ fun x(): Boolean { return true }
|
||||
public fun foo(pp: String?): Int {
|
||||
var p = pp
|
||||
while(true) {
|
||||
p!!.length()
|
||||
p!!.length
|
||||
if (x()) break
|
||||
p = null
|
||||
}
|
||||
// Smart cast is NOT possible here
|
||||
// (we could provide it but p = null makes it much harder)
|
||||
return p<!UNSAFE_CALL!>.<!>length()
|
||||
return p<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
+2
-2
@@ -3,11 +3,11 @@ fun x(): Boolean { return true }
|
||||
public fun foo(pp: String?): Int {
|
||||
var p = pp
|
||||
while(true) {
|
||||
p!!.length()
|
||||
p!!.length
|
||||
if (x()) break
|
||||
(((p))) = null
|
||||
}
|
||||
// Smart cast is NOT possible here
|
||||
// (we could provide it but p = null makes it much harder)
|
||||
return p<!UNSAFE_CALL!>.<!>length()
|
||||
return p<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
+2
-2
@@ -3,11 +3,11 @@ fun x(): Boolean { return true }
|
||||
public fun foo(pp: String?): Int {
|
||||
var p = pp
|
||||
while(true) {
|
||||
p!!.length()
|
||||
p!!.length
|
||||
if (x()) break
|
||||
(p) = null
|
||||
}
|
||||
// Smart cast is NOT possible here
|
||||
// (we could provide it but p = null makes it much harder)
|
||||
return p<!UNSAFE_CALL!>.<!>length()
|
||||
return p<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
Reference in New Issue
Block a user