FIR: keep nullability when approximating local types
^KT-30054 Open
This commit is contained in:
+18
@@ -0,0 +1,18 @@
|
||||
// ISSUE: KT-30054
|
||||
interface I {
|
||||
fun foo(): String
|
||||
}
|
||||
|
||||
fun bar(condition: Boolean) /*: I? */ =
|
||||
if (condition)
|
||||
object : I {
|
||||
override fun foo() = "should check for null first"
|
||||
fun baz() = "invisible"
|
||||
}
|
||||
else null
|
||||
|
||||
fun main() {
|
||||
bar(false).<!UNRESOLVED_REFERENCE!>baz<!>()
|
||||
bar(false)<!UNSAFE_CALL!>.<!>foo()
|
||||
bar(false)?.foo()
|
||||
}
|
||||
compiler/testData/diagnostics/tests/inference/substitutions/hideNullableLocalTypeInPublicPosition.kt
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
// ISSUE: KT-30054
|
||||
interface I {
|
||||
fun foo(): String
|
||||
}
|
||||
|
||||
fun bar(condition: Boolean) /*: I? */ =
|
||||
if (condition)
|
||||
object : I {
|
||||
override fun foo() = "should check for null first"
|
||||
fun baz() = "invisible"
|
||||
}
|
||||
else null
|
||||
|
||||
fun main() {
|
||||
bar(false).<!UNRESOLVED_REFERENCE!>baz<!>()
|
||||
bar(false).foo()
|
||||
bar(false)<!UNNECESSARY_SAFE_CALL!>?.<!>foo()
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ condition: kotlin.Boolean): I
|
||||
public fun main(): kotlin.Unit
|
||||
|
||||
public interface I {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public abstract fun foo(): kotlin.String
|
||||
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