Files
Dmitriy Novozhilov 09994ee8ea [FIR] Make type of safe call always nullable
^KT-46860 In Progress
2021-06-25 16:37:32 +03:00

21 lines
526 B
Kotlin
Vendored

// LANGUAGE: +SafeCallsAreAlwaysNullable
// ISSUE: KT-46860
interface A {
fun foo(): Int
}
fun takeInt(x: Int) {}
fun test_1(a: A) {
val x = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?")!>a<!UNNECESSARY_SAFE_CALL!>?.<!>foo()<!>
takeInt(<!ARGUMENT_TYPE_MISMATCH!>x<!>) // should be an error
}
fun test_2(a: A?) {
if (a != null) {
val x = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?")!>a<!UNNECESSARY_SAFE_CALL!>?.<!>foo()<!>
takeInt(<!ARGUMENT_TYPE_MISMATCH!>x<!>) // should be an error
}
}