KT-1875 Safe call should be binded with receiver or this object (but not with both by default)

#KT-1875 fixed
This commit is contained in:
Svetlana Isakova
2012-05-03 14:17:58 +04:00
parent 47934b1fe7
commit 8723bbcac5
12 changed files with 176 additions and 52 deletions
@@ -0,0 +1,21 @@
//KT-1875 Safe call should be binded with receiver or this object (but not with both by default)
package kt1875
fun f(a : Int?, b : Int.(Int)->Int) = a?.b(1) //unnecessary safe call warning
trait T {
val f : ((i: Int) -> Unit)?
}
fun test(t: T) {
t.<!UNSAFE_CALL!>f<!>(1) //unsafe call error
t.f?.invoke(1)
}
fun test1(t: T?) {
t<!UNSAFE_CALL!>.<!><!UNSAFE_CALL!>f<!>(1)
t?.<!UNSAFE_CALL!>f<!>(1)
t<!UNSAFE_CALL!>.<!>f?.invoke(1)
t?.f?.invoke(1)
}