FIR: keep nullability when approximating local types

^KT-30054 Open
This commit is contained in:
pyos
2022-09-12 12:28:12 +02:00
committed by teamcity
parent e4556ecc0d
commit 062308c7c1
7 changed files with 69 additions and 8 deletions
@@ -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()
}
@@ -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()
}
@@ -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
}