Delay ForbidInferringTypeVariablesIntoEmptyIntersection to 2.*
Note: here we set sinceVersion = null for this feature. However, we plan in 1.9.* - 2.0 time frame to solve KT-56377 and to enable this feature in 2.0, the latest in 2.1.
This commit is contained in:
committed by
Space Team
parent
a3dcc2032f
commit
f7544aff62
+12
@@ -35562,6 +35562,18 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
|||||||
runTest("compiler/testData/diagnostics/tests/when/TopLevelSealed.kt");
|
runTest("compiler/testData/diagnostics/tests/when/TopLevelSealed.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("TypeParameterError.kt")
|
||||||
|
public void testTypeParameterError() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/when/TypeParameterError.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("TypeParameterWarning.kt")
|
||||||
|
public void testTypeParameterWarning() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/when/TypeParameterWarning.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("When.kt")
|
@TestMetadata("When.kt")
|
||||||
public void testWhen() throws Exception {
|
public void testWhen() throws Exception {
|
||||||
|
|||||||
+12
@@ -35562,6 +35562,18 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
|||||||
runTest("compiler/testData/diagnostics/tests/when/TopLevelSealed.kt");
|
runTest("compiler/testData/diagnostics/tests/when/TopLevelSealed.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("TypeParameterError.kt")
|
||||||
|
public void testTypeParameterError() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/when/TypeParameterError.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("TypeParameterWarning.kt")
|
||||||
|
public void testTypeParameterWarning() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/when/TypeParameterWarning.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("When.kt")
|
@TestMetadata("When.kt")
|
||||||
public void testWhen() throws Exception {
|
public void testWhen() throws Exception {
|
||||||
|
|||||||
+12
@@ -35658,6 +35658,18 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
|||||||
runTest("compiler/testData/diagnostics/tests/when/TopLevelSealed.kt");
|
runTest("compiler/testData/diagnostics/tests/when/TopLevelSealed.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("TypeParameterError.kt")
|
||||||
|
public void testTypeParameterError() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/when/TypeParameterError.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("TypeParameterWarning.kt")
|
||||||
|
public void testTypeParameterWarning() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/when/TypeParameterWarning.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("When.kt")
|
@TestMetadata("When.kt")
|
||||||
public void testWhen() throws Exception {
|
public void testWhen() throws Exception {
|
||||||
|
|||||||
+1
-1
@@ -27,7 +27,7 @@ fun test3() = <!INFERRED_TYPE_VARIABLE_INTO_POSSIBLE_EMPTY_INTERSECTION!>run<!>
|
|||||||
incompatibleI() // ? either uninferred T or error (Unit </: I)
|
incompatibleI() // ? either uninferred T or error (Unit </: I)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test4() = <!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_ERROR!>run<!> {
|
fun test4() = <!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_WARNING!>run<!> {
|
||||||
if (p) return@run
|
if (p) return@run
|
||||||
incompatibleC() // ? either uninferred T or error (Unit </: C)
|
incompatibleC() // ? either uninferred T or error (Unit </: C)
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
-1
@@ -47,7 +47,7 @@ fun test(i: Inv<Nothing>, iUnit: Inv<Unit>) {
|
|||||||
|
|
||||||
if (iUnit is <!INCOMPATIBLE_TYPES!>String<!>) {
|
if (iUnit is <!INCOMPATIBLE_TYPES!>String<!>) {
|
||||||
launch {
|
launch {
|
||||||
run(A.<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_ERROR!>flexible<!>(iUnit)) { 42 }
|
run(A.<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_WARNING!>flexible<!>(iUnit)) { 42 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ object OnlyOne {
|
|||||||
fun <T : Comparable<T>, S : T> greater(x: Bar<in S>, t: T) {}
|
fun <T : Comparable<T>, S : T> greater(x: Bar<in S>, t: T) {}
|
||||||
|
|
||||||
fun test(b: Bar<Long>) {
|
fun test(b: Bar<Long>) {
|
||||||
<!DEBUG_INFO_CALL("fqName: OnlyOne.greater; typeCall: function")!><!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_ERROR!>greater<!>(b, b)<!>
|
<!DEBUG_INFO_CALL("fqName: OnlyOne.greater; typeCall: function")!><!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_WARNING!>greater<!>(b, b)<!>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -1,3 +1,6 @@
|
|||||||
/kt45461.kt:10:19: error: type argument for a type parameter S can't be inferred because it has incompatible upper bounds: String, Int (multiple incompatible classes)
|
/kt45461.kt:5:25: warning: parameter 'foo' is never used
|
||||||
|
fun <S : T> takeFoo(foo: Foo<in S>) {}
|
||||||
|
^
|
||||||
|
/kt45461.kt:10:19: warning: type argument for a type parameter S can't be inferred because it has incompatible upper bounds: String, Int (multiple incompatible classes). This will become an error in Kotlin 2.0
|
||||||
Bar<String>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31
|
Bar<String>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31
|
||||||
^
|
^
|
||||||
|
|||||||
+1
-1
@@ -7,5 +7,5 @@ class Bar<T> {
|
|||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
val foo = Foo<Int>()
|
val foo = Foo<Int>()
|
||||||
Bar<String>().<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_ERROR!>takeFoo<!>(foo) // error in 1.3.72, no error in 1.4.31
|
Bar<String>().<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_WARNING!>takeFoo<!>(foo) // error in 1.3.72, no error in 1.4.31
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -1,4 +1,7 @@
|
|||||||
/kt45461_12.kt:12:19: error: type argument for a type parameter S can't be inferred because it has incompatible upper bounds: String, K (multiple incompatible classes: String, Number)
|
/kt45461_12.kt:5:25: warning: parameter 'foo' is never used
|
||||||
|
fun <S : T> takeFoo(foo: Foo<in S>) {}
|
||||||
|
^
|
||||||
|
/kt45461_12.kt:12:19: warning: type argument for a type parameter S can't be inferred because it has incompatible upper bounds: String, K (multiple incompatible classes: String, Number). This will become an error in Kotlin 2.0
|
||||||
Bar<String>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31
|
Bar<String>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31
|
||||||
^
|
^
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -9,5 +9,5 @@ interface A
|
|||||||
|
|
||||||
fun <K : L, L : N, N> main() where N: A, N: Number {
|
fun <K : L, L : N, N> main() where N: A, N: Number {
|
||||||
val foo = Foo<K>()
|
val foo = Foo<K>()
|
||||||
Bar<String>().<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_ERROR!>takeFoo<!>(foo) // error in 1.3.72, no error in 1.4.31
|
Bar<String>().<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_WARNING!>takeFoo<!>(foo) // error in 1.3.72, no error in 1.4.31
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-1
@@ -1,4 +1,10 @@
|
|||||||
/kt45461_2.kt:10:19: error: type argument for a type parameter S can't be inferred because it has incompatible upper bounds: String, K (multiple incompatible classes: String, Int)
|
/kt45461_2.kt:5:25: warning: parameter 'foo' is never used
|
||||||
|
fun <S : T> takeFoo(foo: Foo<in S>) {}
|
||||||
|
^
|
||||||
|
/kt45461_2.kt:8:10: warning: 'Int' is a final type, and thus a value of the type parameter is predetermined
|
||||||
|
fun <K : Int> main() {
|
||||||
|
^
|
||||||
|
/kt45461_2.kt:10:19: warning: type argument for a type parameter S can't be inferred because it has incompatible upper bounds: String, K (multiple incompatible classes: String, Int). This will become an error in Kotlin 2.0
|
||||||
Bar<String>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31
|
Bar<String>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31
|
||||||
^
|
^
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -7,5 +7,5 @@ class Bar<T> {
|
|||||||
|
|
||||||
fun <K : <!FINAL_UPPER_BOUND!>Int<!>> main() {
|
fun <K : <!FINAL_UPPER_BOUND!>Int<!>> main() {
|
||||||
val foo = Foo<K>()
|
val foo = Foo<K>()
|
||||||
Bar<String>().<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_ERROR!>takeFoo<!>(foo) // error in 1.3.72, no error in 1.4.31
|
Bar<String>().<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_WARNING!>takeFoo<!>(foo) // error in 1.3.72, no error in 1.4.31
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -1,3 +1,6 @@
|
|||||||
/kt45461_5.kt:10:19: error: type argument for a type parameter S can't be inferred because it has incompatible upper bounds: String, K (multiple incompatible classes: String, Number)
|
/kt45461_5.kt:5:25: warning: parameter 'foo' is never used
|
||||||
|
fun <S : T> takeFoo(foo: Foo<in S>) {}
|
||||||
|
^
|
||||||
|
/kt45461_5.kt:10:19: warning: type argument for a type parameter S can't be inferred because it has incompatible upper bounds: String, K (multiple incompatible classes: String, Number). This will become an error in Kotlin 2.0
|
||||||
Bar<String>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31
|
Bar<String>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31
|
||||||
^
|
^
|
||||||
|
|||||||
+1
-1
@@ -7,5 +7,5 @@ class Bar<T> {
|
|||||||
|
|
||||||
fun <K : L, L : N, N: Number> main() {
|
fun <K : L, L : N, N: Number> main() {
|
||||||
val foo = Foo<K>()
|
val foo = Foo<K>()
|
||||||
Bar<String>().<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_ERROR!>takeFoo<!>(foo) // error in 1.3.72, no error in 1.4.31
|
Bar<String>().<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_WARNING!>takeFoo<!>(foo) // error in 1.3.72, no error in 1.4.31
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-1
@@ -1,4 +1,16 @@
|
|||||||
/kt48765.kt:8:13: error: type argument for a type parameter T can't be inferred because it has incompatible upper bounds: String, Number (multiple incompatible classes)
|
/kt48765.kt:4:44: warning: parameter 'x1' is never used
|
||||||
|
fun <T1: Number, T2: A<Float, T1>> foo(x1: T2, x2: T1) {}
|
||||||
|
^
|
||||||
|
/kt48765.kt:4:52: warning: parameter 'x2' is never used
|
||||||
|
fun <T1: Number, T2: A<Float, T1>> foo(x1: T2, x2: T1) {}
|
||||||
|
^
|
||||||
|
/kt48765.kt:8:13: warning: type argument for a type parameter T can't be inferred because it has incompatible upper bounds: String, Number (multiple incompatible classes). This will become an error in Kotlin 2.0
|
||||||
B().foo(x, foo())
|
B().foo(x, foo())
|
||||||
^
|
^
|
||||||
|
/kt48765.kt:12:9: warning: 'String' is a final type, and thus a value of the type parameter is predetermined
|
||||||
|
fun <T: String> foo(): T {
|
||||||
|
^
|
||||||
|
/kt48765.kt:13:15: warning: unchecked cast: String to T
|
||||||
|
return "" as T // this cast is safe because String is final.
|
||||||
|
^
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ class B {
|
|||||||
}
|
}
|
||||||
class C<T: D, T2>(val x: T, val y: T2) {
|
class C<T: D, T2>(val x: T, val y: T2) {
|
||||||
fun test() {
|
fun test() {
|
||||||
B().<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_ERROR!>foo<!>(x, foo())
|
B().<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_WARNING!>foo<!>(x, foo())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
open class D: A<Float, Number>()
|
open class D: A<Float, Number>()
|
||||||
|
|||||||
+1
-1
@@ -7,5 +7,5 @@ fun <T, V> exampleGenericFunction(func: V) where T: Base, V: (T) -> Unit {
|
|||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
val func: (DoesNotImplementBase) -> Unit = { }
|
val func: (DoesNotImplementBase) -> Unit = { }
|
||||||
<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_ERROR!>exampleGenericFunction<!>(func) // expected this to be a compilation error as the T: Base constraint should not be satisfied
|
<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_WARNING!>exampleGenericFunction<!>(func) // expected this to be a compilation error as the T: Base constraint should not be satisfied
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -7,5 +7,5 @@ fun <T, V> exampleGenericFunction(func: V) where T: Base, V: (T) -> Unit {
|
|||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
val func: (DoesNotImplementBase) -> Unit = { }
|
val func: (DoesNotImplementBase) -> Unit = { }
|
||||||
<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_ERROR!>exampleGenericFunction<!>(func) // expected this to be a compilation error as the T: Base constraint should not be satisfied
|
<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_WARNING!>exampleGenericFunction<!>(func) // expected this to be a compilation error as the T: Base constraint should not be satisfied
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ fun box(): String {
|
|||||||
return try {
|
return try {
|
||||||
val range1 = 0..1
|
val range1 = 0..1
|
||||||
range1 <!CAST_NEVER_SUCCEEDS!>as<!> List<Double>
|
range1 <!CAST_NEVER_SUCCEEDS!>as<!> List<Double>
|
||||||
<!DEBUG_INFO_SMARTCAST!>range1<!>.<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_ERROR!>joinToString<!> { "" }
|
<!DEBUG_INFO_SMARTCAST!>range1<!>.<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_WARNING!>joinToString<!> { "" }
|
||||||
} catch (e: java.lang.ClassCastException) {
|
} catch (e: java.lang.ClassCastException) {
|
||||||
"OK"
|
"OK"
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
/kt49661.kt:10:5: error: type argument for a type parameter T can't be inferred because it has incompatible upper bounds: Foo, Int (multiple incompatible classes)
|
/kt49661.kt:10:5: warning: type argument for a type parameter T can't be inferred because it has incompatible upper bounds: Foo, Int (multiple incompatible classes). This will become an error in Kotlin 2.0
|
||||||
f<Int> { g() }
|
f<Int> { g() }
|
||||||
^
|
^
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -7,5 +7,5 @@ inline fun <R> f(block: ()->R?): R? {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_ERROR!>f<!><Int> { g() }
|
<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_WARNING!>f<!><Int> { g() }
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -12,6 +12,6 @@ fun main() {
|
|||||||
// val number: Long = 5 // works
|
// val number: Long = 5 // works
|
||||||
|
|
||||||
with (WrapperFunctions()) {
|
with (WrapperFunctions()) {
|
||||||
wrapper <!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_ERROR!>greaterEq<!> number
|
wrapper <!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_WARNING!>greaterEq<!> number
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -9,5 +9,5 @@ infix fun <T : Comparable<T>, S : T?> ExpressionWithColumnType<in S>.less(t: T)
|
|||||||
infix fun <T : Comparable<T>, S : T?> Expression<in S>.less(other: Expression<in S>) {}
|
infix fun <T : Comparable<T>, S : T?> Expression<in S>.less(other: Expression<in S>) {}
|
||||||
|
|
||||||
fun main(x: Column<Long?>, y: Double) {
|
fun main(x: Column<Long?>, y: Double) {
|
||||||
x <!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_ERROR!>less<!> y // error in 1.7.20, no error in 1.7.0
|
x <!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_WARNING!>less<!> y // error in 1.7.20, no error in 1.7.0
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
-1
@@ -3,5 +3,5 @@ fun <T : <!FINAL_UPPER_BOUND!>String<!>> g(): T? = null
|
|||||||
fun <R> f(block: () -> R?): R? = block()
|
fun <R> f(block: () -> R?): R? = block()
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_ERROR!>f<!><Int> { g() /* OK, g() is inferred into {Int & String}? */ }
|
<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_WARNING!>f<!><Int> { g() /* OK, g() is inferred into {Int & String}? */ }
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-1
@@ -1,3 +1,12 @@
|
|||||||
/selectFromCovariantAndContravariantTypes.kt:15:5: error: type argument for a type parameter V can't be inferred because it has incompatible upper bounds: A, B (multiple incompatible classes)
|
/selectFromCovariantAndContravariantTypes.kt:10:22: warning: parameter 'y' is never used
|
||||||
|
fun <K> select(x: K, y: K): K = x
|
||||||
|
^
|
||||||
|
/selectFromCovariantAndContravariantTypes.kt:11:19: warning: parameter 'x' is never used
|
||||||
|
fun <V> genericIn(x: In<V>) {}
|
||||||
|
^
|
||||||
|
/selectFromCovariantAndContravariantTypes.kt:12:20: warning: parameter 'x' is never used
|
||||||
|
fun <V> genericOut(x: Out<V>) {}
|
||||||
|
^
|
||||||
|
/selectFromCovariantAndContravariantTypes.kt:15:5: warning: type argument for a type parameter V can't be inferred because it has incompatible upper bounds: A, B (multiple incompatible classes). This will become an error in Kotlin 2.0
|
||||||
genericIn(select(a, b))
|
genericIn(select(a, b))
|
||||||
^
|
^
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ fun <V> genericIn(x: In<V>) {}
|
|||||||
fun <V> genericOut(x: Out<V>) {}
|
fun <V> genericOut(x: Out<V>) {}
|
||||||
|
|
||||||
fun test1(a: In<A>, b: In<B>) {
|
fun test1(a: In<A>, b: In<B>) {
|
||||||
<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_ERROR!>genericIn<!>(select(a, b))
|
<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_WARNING!>genericIn<!>(select(a, b))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test2(a: Out<A>, b: Out<B>) {
|
fun test2(a: Out<A>, b: Out<B>) {
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// !LANGUAGE: +ForbidInferringTypeVariablesIntoEmptyIntersection
|
||||||
|
// FILE: ObjectNode.java
|
||||||
|
|
||||||
|
public interface ObjectNode {
|
||||||
|
<T extends JsonNode> T set(String fieldName, JsonNode value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: JsonNode.java
|
||||||
|
|
||||||
|
public class JsonNode
|
||||||
|
|
||||||
|
// FILE: test.kt
|
||||||
|
|
||||||
|
interface JsonObject
|
||||||
|
class SomeJsonObject() : JsonObject
|
||||||
|
|
||||||
|
fun String.put(value: JsonObject?, node: ObjectNode) {
|
||||||
|
<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION!>when (value) {
|
||||||
|
null -> node.set(this, null)
|
||||||
|
is SomeJsonObject -> Unit
|
||||||
|
else -> TODO()
|
||||||
|
}<!>
|
||||||
|
}
|
||||||
|
|
||||||
|
fun TODO(): Nothing = null!!
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// !LANGUAGE: +ForbidInferringTypeVariablesIntoEmptyIntersection
|
||||||
|
// FILE: ObjectNode.java
|
||||||
|
|
||||||
|
public interface ObjectNode {
|
||||||
|
<T extends JsonNode> T set(String fieldName, JsonNode value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: JsonNode.java
|
||||||
|
|
||||||
|
public class JsonNode
|
||||||
|
|
||||||
|
// FILE: test.kt
|
||||||
|
|
||||||
|
interface JsonObject
|
||||||
|
class SomeJsonObject() : JsonObject
|
||||||
|
|
||||||
|
fun String.put(value: JsonObject?, node: ObjectNode) {
|
||||||
|
<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_ERROR!>when (value) {
|
||||||
|
null -> node.set(this, null)
|
||||||
|
is SomeJsonObject -> Unit
|
||||||
|
else -> TODO()
|
||||||
|
}<!>
|
||||||
|
}
|
||||||
|
|
||||||
|
fun TODO(): Nothing = null!!
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun TODO(): kotlin.Nothing
|
||||||
|
public fun kotlin.String.put(/*0*/ value: JsonObject?, /*1*/ node: ObjectNode): kotlin.Unit
|
||||||
|
|
||||||
|
public open class JsonNode {
|
||||||
|
public constructor JsonNode()
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface JsonObject {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface ObjectNode {
|
||||||
|
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 abstract operator fun </*0*/ T : JsonNode!> set(/*0*/ fieldName: kotlin.String!, /*1*/ value: JsonNode!): T!
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class SomeJsonObject : JsonObject {
|
||||||
|
public constructor SomeJsonObject()
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// !LANGUAGE: -ForbidInferringTypeVariablesIntoEmptyIntersection
|
||||||
|
// FILE: ObjectNode.java
|
||||||
|
|
||||||
|
public interface ObjectNode {
|
||||||
|
<T extends JsonNode> T set(String fieldName, JsonNode value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: JsonNode.java
|
||||||
|
|
||||||
|
public class JsonNode
|
||||||
|
|
||||||
|
// FILE: test.kt
|
||||||
|
|
||||||
|
interface JsonObject
|
||||||
|
class SomeJsonObject() : JsonObject
|
||||||
|
|
||||||
|
fun String.put(value: JsonObject?, node: ObjectNode) {
|
||||||
|
<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION!>when (value) {
|
||||||
|
null -> node.set(this, null)
|
||||||
|
is SomeJsonObject -> Unit
|
||||||
|
else -> TODO()
|
||||||
|
}<!>
|
||||||
|
}
|
||||||
|
|
||||||
|
fun TODO(): Nothing = null!!
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// !LANGUAGE: -ForbidInferringTypeVariablesIntoEmptyIntersection
|
||||||
|
// FILE: ObjectNode.java
|
||||||
|
|
||||||
|
public interface ObjectNode {
|
||||||
|
<T extends JsonNode> T set(String fieldName, JsonNode value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: JsonNode.java
|
||||||
|
|
||||||
|
public class JsonNode
|
||||||
|
|
||||||
|
// FILE: test.kt
|
||||||
|
|
||||||
|
interface JsonObject
|
||||||
|
class SomeJsonObject() : JsonObject
|
||||||
|
|
||||||
|
fun String.put(value: JsonObject?, node: ObjectNode) {
|
||||||
|
<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_WARNING!>when (value) {
|
||||||
|
null -> node.set(this, null)
|
||||||
|
is SomeJsonObject -> Unit
|
||||||
|
else -> TODO()
|
||||||
|
}<!>
|
||||||
|
}
|
||||||
|
|
||||||
|
fun TODO(): Nothing = null!!
|
||||||
@@ -7,6 +7,6 @@ fun <T : Comparable<T>, S : T?> Expression<in S>.greater(other: T): GreaterOp =
|
|||||||
|
|
||||||
fun foo(countExpr: Expression<Long>) {
|
fun foo(countExpr: Expression<Long>) {
|
||||||
countExpr.greater(0)
|
countExpr.greater(0)
|
||||||
countExpr.<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_ERROR!>greater<!>("0")
|
countExpr.<!INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION_WARNING!>greater<!>("0")
|
||||||
countExpr.greater<String, Nothing>("0")
|
countExpr.greater<String, Nothing>("0")
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+12
@@ -35658,6 +35658,18 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/when/TopLevelSealed.kt");
|
runTest("compiler/testData/diagnostics/tests/when/TopLevelSealed.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("TypeParameterError.kt")
|
||||||
|
public void testTypeParameterError() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/when/TypeParameterError.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("TypeParameterWarning.kt")
|
||||||
|
public void testTypeParameterWarning() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/when/TypeParameterWarning.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("When.kt")
|
@TestMetadata("When.kt")
|
||||||
public void testWhen() throws Exception {
|
public void testWhen() throws Exception {
|
||||||
|
|||||||
@@ -265,7 +265,6 @@ enum class LanguageFeature(
|
|||||||
StopPropagatingDeprecationThroughOverrides(KOTLIN_1_9, kind = BUG_FIX), // KT-47902
|
StopPropagatingDeprecationThroughOverrides(KOTLIN_1_9, kind = BUG_FIX), // KT-47902
|
||||||
ReportTypeVarianceConflictOnQualifierArguments(KOTLIN_1_9, kind = BUG_FIX), // KT-50947
|
ReportTypeVarianceConflictOnQualifierArguments(KOTLIN_1_9, kind = BUG_FIX), // KT-50947
|
||||||
ReportErrorsOnRecursiveTypeInsidePlusAssignment(KOTLIN_1_9, kind = BUG_FIX), // KT-48546
|
ReportErrorsOnRecursiveTypeInsidePlusAssignment(KOTLIN_1_9, kind = BUG_FIX), // KT-48546
|
||||||
ForbidInferringTypeVariablesIntoEmptyIntersection(KOTLIN_1_9, kind = BUG_FIX), // KT-51221
|
|
||||||
ForbidExtensionCallsOnInlineFunctionalParameters(KOTLIN_1_9, kind = BUG_FIX), // KT-52502
|
ForbidExtensionCallsOnInlineFunctionalParameters(KOTLIN_1_9, kind = BUG_FIX), // KT-52502
|
||||||
ForbidInferringPostponedTypeVariableIntoDeclaredUpperBound(KOTLIN_1_9, kind = BUG_FIX), // KT-47986
|
ForbidInferringPostponedTypeVariableIntoDeclaredUpperBound(KOTLIN_1_9, kind = BUG_FIX), // KT-47986
|
||||||
KeepNullabilityWhenApproximatingLocalType(KOTLIN_1_9, kind = BUG_FIX), // KT-53982
|
KeepNullabilityWhenApproximatingLocalType(KOTLIN_1_9, kind = BUG_FIX), // KT-53982
|
||||||
@@ -328,6 +327,7 @@ enum class LanguageFeature(
|
|||||||
EnableDfaWarningsInK2(sinceVersion = null, kind = OTHER), // KT-50965
|
EnableDfaWarningsInK2(sinceVersion = null, kind = OTHER), // KT-50965
|
||||||
ContractSyntaxV2(sinceVersion = null, kind = UNSTABLE_FEATURE), // KT-56127
|
ContractSyntaxV2(sinceVersion = null, kind = UNSTABLE_FEATURE), // KT-56127
|
||||||
ImplicitSignedToUnsignedIntegerConversion(sinceVersion = null), // KT-56583
|
ImplicitSignedToUnsignedIntegerConversion(sinceVersion = null), // KT-56583
|
||||||
|
ForbidInferringTypeVariablesIntoEmptyIntersection(sinceVersion = null, kind = BUG_FIX), // KT-51221
|
||||||
;
|
;
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|||||||
Reference in New Issue
Block a user