[FE 1.0] Make type of safe call always nullable

^KT-46860 In Progress
This commit is contained in:
Dmitriy Novozhilov
2021-06-21 15:06:06 +03:00
committed by teamcityserver
parent 805fad980f
commit 26b9948e5f
10 changed files with 86 additions and 6 deletions
@@ -0,0 +1,20 @@
// 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(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(x) // should be an error
}
}