FIR/FE1.0: keep flexibility when approximating local types

This commit is contained in:
pyos
2022-09-12 18:08:35 +02:00
committed by teamcity
parent adcbc5ec99
commit be5c4a91a4
14 changed files with 222 additions and 28 deletions
@@ -0,0 +1,24 @@
// FIR_IDENTICAL
// ISSUE: KT-30054
// !LANGUAGE: +KeepNullabilityWhenApproximatingLocalType
// FILE: J.java
public class J {
public static <T> T flexibleId(T x) { return x; }
}
// FILE: main.kt
interface I {
fun foo(): String
}
fun bar(condition: Boolean) /*: I! */ =
J.flexibleId(object : I {
override fun foo() = "may or may not check for null first"
fun baz() = "invisible"
})
fun main() {
bar(false).<!UNRESOLVED_REFERENCE!>baz<!>()
bar(false).foo()
bar(false)?.foo()
}
@@ -0,0 +1,21 @@
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
}
public open class J {
public constructor J()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public open fun </*0*/ T : kotlin.Any!> flexibleId(/*0*/ x: T!): T!
}
@@ -0,0 +1,23 @@
// ISSUE: KT-30054
// !LANGUAGE: -KeepNullabilityWhenApproximatingLocalType
// FILE: J.java
public class J {
public static <T> T flexibleId(T x) { return x; }
}
// FILE: main.kt
interface I {
fun foo(): String
}
fun bar(condition: Boolean) /*: I! */ =
J.flexibleId(object : I {
override fun foo() = "may or may not check for null first"
fun baz() = "invisible"
})
fun main() {
bar(false).<!UNRESOLVED_REFERENCE!>baz<!>()
bar(false).foo()
bar(false)?.foo()
}
@@ -0,0 +1,23 @@
// ISSUE: KT-30054
// !LANGUAGE: -KeepNullabilityWhenApproximatingLocalType
// FILE: J.java
public class J {
public static <T> T flexibleId(T x) { return x; }
}
// FILE: main.kt
interface I {
fun foo(): String
}
<!APPROXIMATED_LOCAL_TYPE_WILL_BECOME_FLEXIBLE!>fun bar(condition: Boolean)<!> /*: I! */ =
J.flexibleId(object : I {
override fun foo() = "may or may not check for null first"
fun baz() = "invisible"
})
fun main() {
bar(false).<!UNRESOLVED_REFERENCE!>baz<!>()
bar(false).foo()
bar(false)<!UNNECESSARY_SAFE_CALL!>?.<!>foo()
}
@@ -0,0 +1,21 @@
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
}
public open class J {
public constructor J()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public open fun </*0*/ T : kotlin.Any!> flexibleId(/*0*/ x: T!): T!
}
@@ -1,4 +1,5 @@
// ISSUE: KT-30054
// !LANGUAGE: -KeepNullabilityWhenApproximatingLocalType
interface I {
fun foo(): String
}
@@ -1,4 +1,5 @@
// ISSUE: KT-30054
// !LANGUAGE: -KeepNullabilityWhenApproximatingLocalType
interface I {
fun foo(): String
}