More accurate handling of "always null" for receivers
This commit is contained in:
@@ -8,7 +8,7 @@ fun f(): Unit {
|
||||
<!DEBUG_INFO_CONSTANT!>x<!> <!UNSAFE_INFIX_CALL!>+<!> 1
|
||||
<!DEBUG_INFO_CONSTANT!>x<!> <!UNSAFE_INFIX_CALL, INFIX_MODIFIER_REQUIRED!>plus<!> 1
|
||||
<!DEBUG_INFO_CONSTANT!>x<!> <!UNSAFE_INFIX_CALL!><<!> 1
|
||||
x <!UNSAFE_INFIX_CALL!>+=<!> 1
|
||||
<!DEBUG_INFO_CONSTANT!>x<!> <!UNSAFE_INFIX_CALL!>+=<!> 1
|
||||
|
||||
<!DEBUG_INFO_CONSTANT!>x<!> == 1
|
||||
<!DEBUG_INFO_CONSTANT!>x<!> != 1
|
||||
|
||||
+1
-1
@@ -146,7 +146,7 @@ fun test() {
|
||||
|
||||
while (out2 == null) {
|
||||
<!DEBUG_INFO_CONSTANT!>out2<!>?.println();
|
||||
<!ALWAYS_NULL!>out2<!><!UNSAFE_CALL!>.<!>println();
|
||||
<!DEBUG_INFO_CONSTANT!>out2<!><!UNSAFE_CALL!>.<!>println();
|
||||
}
|
||||
<!DEBUG_INFO_SMARTCAST!>out2<!>.println()
|
||||
|
||||
|
||||
@@ -2,12 +2,12 @@ fun foo(): String {
|
||||
var s: String?
|
||||
s = null
|
||||
<!DEBUG_INFO_CONSTANT!>s<!>?.length
|
||||
<!ALWAYS_NULL!>s<!><!UNSAFE_CALL!>.<!>length
|
||||
<!DEBUG_INFO_CONSTANT!>s<!><!UNSAFE_CALL!>.<!>length
|
||||
if (<!SENSELESS_COMPARISON!><!DEBUG_INFO_CONSTANT!>s<!> == null<!>) return <!ALWAYS_NULL!>s<!>!!
|
||||
var t: String? = "y"
|
||||
if (t == null) t = "x"
|
||||
var x: Int? = null
|
||||
if (x == null) <!TYPE_MISMATCH!>x += null<!>
|
||||
if (x == null) <!TYPE_MISMATCH!><!DEBUG_INFO_CONSTANT!>x<!> += null<!>
|
||||
return <!DEBUG_INFO_SMARTCAST!>t<!> + s
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@ fun String?.gav() {}
|
||||
|
||||
fun bar(s: String?) {
|
||||
if (s != null) return
|
||||
// Ideally we should have DEBUG_INFO_CONSTANT instead
|
||||
<!ALWAYS_NULL!>s<!>.gav()
|
||||
<!DEBUG_INFO_CONSTANT!>s<!>.gav()
|
||||
<!DEBUG_INFO_CONSTANT!>s<!> as? String
|
||||
<!DEBUG_INFO_CONSTANT!>s<!> <!USELESS_CAST!>as String?<!>
|
||||
<!ALWAYS_NULL!>s<!> as String
|
||||
|
||||
@@ -10,7 +10,7 @@ public class My {
|
||||
fun test() {
|
||||
val my = My.create()
|
||||
if (my == null) {
|
||||
<!ALWAYS_NULL!>my<!>.foo()
|
||||
<!DEBUG_INFO_CONSTANT!>my<!><!UNSAFE_CALL!>.<!>foo()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,12 +15,12 @@ fun foo(x : String?, y : String?) {
|
||||
else {
|
||||
// y == null but x != y
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
<!ALWAYS_NULL!>y<!><!UNSAFE_CALL!>.<!>length
|
||||
<!DEBUG_INFO_CONSTANT!>y<!><!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
if (y == null && x != <!DEBUG_INFO_CONSTANT!>y<!>) {
|
||||
// y == null but x != y
|
||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||
<!ALWAYS_NULL!>y<!><!UNSAFE_CALL!>.<!>length
|
||||
<!DEBUG_INFO_CONSTANT!>y<!><!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
else {
|
||||
x<!UNSAFE_CALL!>.<!>length
|
||||
|
||||
@@ -6,7 +6,7 @@ fun foo(x: String?, y: String?, z: String?, w: String?) {
|
||||
if (x != null || y != null || (<!DEBUG_INFO_CONSTANT!>x<!> != z && <!DEBUG_INFO_CONSTANT!>y<!> != z))
|
||||
z<!UNSAFE_CALL!>.<!>length
|
||||
else
|
||||
<!ALWAYS_NULL!>z<!><!UNSAFE_CALL!>.<!>length
|
||||
<!DEBUG_INFO_CONSTANT!>z<!><!UNSAFE_CALL!>.<!>length
|
||||
if (x == null || y == null || (x != z && y != z))
|
||||
z<!UNSAFE_CALL!>.<!>length
|
||||
else
|
||||
|
||||
@@ -4,7 +4,7 @@ fun foo() {
|
||||
v = "abc"
|
||||
<!DEBUG_INFO_SMARTCAST!>v<!>.length
|
||||
v = null
|
||||
<!ALWAYS_NULL!>v<!><!UNSAFE_CALL!>.<!>length
|
||||
<!DEBUG_INFO_CONSTANT!>v<!><!UNSAFE_CALL!>.<!>length
|
||||
v = "abc"
|
||||
<!DEBUG_INFO_SMARTCAST!>v<!>.length
|
||||
}
|
||||
+1
-1
@@ -3,5 +3,5 @@ fun foo() {
|
||||
// It is possible in principle to provide smart cast here
|
||||
v<!UNSAFE_CALL!>.<!>length
|
||||
v = null
|
||||
<!ALWAYS_NULL!>v<!><!UNSAFE_CALL!>.<!>length
|
||||
<!DEBUG_INFO_CONSTANT!>v<!><!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fun foo(): Int {
|
||||
var s: String? = <!VARIABLE_WITH_REDUNDANT_INITIALIZER!>"abc"<!>
|
||||
s = null
|
||||
return <!ALWAYS_NULL!>s<!><!UNSAFE_CALL!>.<!>length
|
||||
return <!DEBUG_INFO_CONSTANT!>s<!><!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
@@ -9,5 +9,5 @@ fun test() {
|
||||
|
||||
fun <T> dynamic(body: dynamic.() -> T): T {
|
||||
val topLevel = null
|
||||
return <!ALWAYS_NULL!>topLevel<!>.body()
|
||||
return topLevel.body()
|
||||
}
|
||||
Reference in New Issue
Block a user