Files
kotlin-fork/compiler/testData/diagnostics/tests/extensions/kt1875.kt
T
Dmitriy Novozhilov e6b5cb5216 [TD] Update diagnostics test data due to new test runners
Update includes:
- Changing syntax of `OI/`NI` tags from `<!NI;TAG!>` to `<!TAG{NI}!>`
- Fix some incorrect directives
- Change order of diagnostics in some places
- Remove ignored diagnostics from FIR test data (previously `DIAGNOSTICS` didn't work)
- Update FIR dumps in some places and add `FIR_IDENTICAL` if needed
- Replace all JAVAC_SKIP with SKIP_JAVAC directive
2020-12-16 19:52:25 +03:00

22 lines
575 B
Kotlin
Vendored

//KT-1875 Safe call should be binded with receiver or this object (but not with both by default)
package kt1875
fun foo(a : Int?, b : Int.(Int)->Int) = a?.b(1) //unnecessary safe call warning
interface T {
val f : ((i: Int) -> Unit)?
}
fun test(t: T) {
t.<!UNSAFE_IMPLICIT_INVOKE_CALL!>f<!>(1) //unsafe call error
t.f?.invoke(1)
}
fun test1(t: T?) {
t<!UNSAFE_CALL!>.<!><!FUNCTION_EXPECTED!>f<!>(1) // todo resolve f as value and report UNSAFE_CALL
t?.<!UNSAFE_IMPLICIT_INVOKE_CALL!>f<!>(1)
t<!UNSAFE_CALL!>.<!>f?.invoke(1)
t?.f?.invoke(1)
}