FIR/FE1.0: keep flexibility when approximating local types
This commit is contained in:
compiler/testData/diagnostics/tests/inference/substitutions/hideFlexibleLocalTypeInPublicPosition.kt
Vendored
+24
@@ -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()
|
||||
}
|
||||
+21
@@ -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!
|
||||
}
|
||||
+23
@@ -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()
|
||||
}
|
||||
+23
@@ -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()
|
||||
}
|
||||
+21
@@ -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
@@ -1,4 +1,5 @@
|
||||
// ISSUE: KT-30054
|
||||
// !LANGUAGE: -KeepNullabilityWhenApproximatingLocalType
|
||||
interface I {
|
||||
fun foo(): String
|
||||
}
|
||||
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
// ISSUE: KT-30054
|
||||
// !LANGUAGE: -KeepNullabilityWhenApproximatingLocalType
|
||||
interface I {
|
||||
fun foo(): String
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user