Nullability properties of receivers checked

This commit is contained in:
Andrey Breslav
2011-10-12 16:17:21 +04:00
parent c53754b3e8
commit 7427f3b3d6
11 changed files with 239 additions and 98 deletions
@@ -0,0 +1,44 @@
class A {
fun foo() {}
}
fun A.bar() {}
fun A?.buzz() {}
fun test(a : A?) {
a<!UNSAFE_CALL!>.<!>foo() // error
a<!UNSAFE_CALL!>.<!>bar() // error
a.buzz()
a?.foo()
a?.bar()
a<!UNNECESSARY_SAFE_CALL!>?.<!>buzz() // warning
}
fun A.test() {
foo()
bar()
buzz()
this.foo()
this.bar()
this.buzz()
this<!UNNECESSARY_SAFE_CALL!>?.<!>foo() // warning
this<!UNNECESSARY_SAFE_CALL!>?.<!>bar() // warning
this<!UNNECESSARY_SAFE_CALL!>?.<!>buzz() // warning
}
fun A?.test() {
<!UNSAFE_CALL!>foo<!>() // error
<!UNSAFE_CALL!>bar<!>() // error
buzz()
this<!UNSAFE_CALL!>.<!>foo() // error
this<!UNSAFE_CALL!>.<!>bar() // error
this.buzz()
this?.foo()
this?.bar()
this<!UNNECESSARY_SAFE_CALL!>?.<!>buzz() // warning
}