[FE 1.0] Make type of safe call always nullable
^KT-46860 In Progress
This commit is contained in:
committed by
teamcityserver
parent
805fad980f
commit
26b9948e5f
+20
@@ -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
|
||||
}
|
||||
}
|
||||
+20
@@ -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(<!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(<!TYPE_MISMATCH!>x<!>) // should be an error
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package
|
||||
|
||||
public fun takeInt(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
public fun test_1(/*0*/ a: A): kotlin.Unit
|
||||
public fun test_2(/*0*/ a: A?): kotlin.Unit
|
||||
|
||||
public interface A {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public abstract fun foo(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Reference in New Issue
Block a user