More accurate handling of "always null" for receivers

This commit is contained in:
Mikhail Glukhikh
2015-11-25 14:14:10 +03:00
parent 89e56093a2
commit 9a6d4c32c5
12 changed files with 45 additions and 32 deletions
@@ -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