From 2a1a5c6936650b25b856ba0d289cc535e128dbb9 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 24 Nov 2022 18:07:40 +0100 Subject: [PATCH] EmptyIntersectionTypeChecker: drop questionable check of arguments The situations with conflicting type arguments normally don't provoke any runtime problems. Also, conflicts like A VS A aren't valid at all. Here we decided to remove them to avoid strange and non-actionable warnings in user code. #KT-54411 Fixed --- .../generic/explicitTypeArguments.fir.kt | 2 +- .../generic/explicitTypeArguments.kt | 2 +- .../postponedArgumentsAnalysis/basic.fir.kt | 2 +- .../postponedArgumentsAnalysis/basic.kt | 2 +- .../kt45461_10.diag.txt | 7 -- .../emptyIntersectionTypes/kt45461_10.kt | 3 +- .../kt45461_13.diag.txt | 7 -- .../emptyIntersectionTypes/kt45461_13.kt | 3 +- .../kt45461_15.diag.txt | 6 -- .../emptyIntersectionTypes/kt45461_15.fir.kt | 15 --- .../emptyIntersectionTypes/kt45461_15.kt | 4 +- .../kt45461_16.diag.txt | 15 --- .../emptyIntersectionTypes/kt45461_16.kt | 2 +- .../kt45461_19.diag.txt | 6 -- .../emptyIntersectionTypes/kt45461_19.fir.kt | 14 --- .../emptyIntersectionTypes/kt45461_19.kt | 4 +- .../kt45461_21.diag.txt | 6 -- .../emptyIntersectionTypes/kt45461_21.fir.kt | 14 --- .../emptyIntersectionTypes/kt45461_21.kt | 4 +- .../kt45461_24.diag.txt | 9 -- .../emptyIntersectionTypes/kt45461_24.fir.kt | 13 --- .../emptyIntersectionTypes/kt45461_24.kt | 4 +- .../kt45461_26.diag.txt | 4 - .../emptyIntersectionTypes/kt45461_26.fir.kt | 2 +- .../emptyIntersectionTypes/kt45461_26.kt | 2 +- .../emptyIntersectionTypes/kt45461_28.fir.kt | 12 --- .../emptyIntersectionTypes/kt45461_28.kt | 3 +- .../emptyIntersectionTypes/kt45461_29.fir.kt | 15 --- .../emptyIntersectionTypes/kt45461_29.kt | 3 +- .../emptyIntersectionTypes/kt45461_30.fir.kt | 15 --- .../emptyIntersectionTypes/kt45461_30.kt | 3 +- .../emptyIntersectionTypes/kt45461_31.fir.kt | 15 --- .../emptyIntersectionTypes/kt45461_31.kt | 3 +- .../emptyIntersectionTypes/kt45461_32.fir.kt | 16 --- .../emptyIntersectionTypes/kt45461_32.kt | 3 +- .../emptyIntersectionTypes/kt45461_33.fir.kt | 16 --- .../emptyIntersectionTypes/kt45461_33.kt | 3 +- .../emptyIntersectionTypes/kt45461_34.fir.kt | 15 --- .../emptyIntersectionTypes/kt45461_34.kt | 3 +- .../emptyIntersectionTypes/kt45461_35.fir.kt | 16 --- .../emptyIntersectionTypes/kt45461_35.kt | 3 +- .../kt45461_35_Enabled.kt | 2 +- .../emptyIntersectionTypes/kt45461_8.diag.txt | 9 -- .../emptyIntersectionTypes/kt45461_8.fir.kt | 13 --- .../emptyIntersectionTypes/kt45461_8.kt | 4 +- .../emptyIntersectionTypes/kt45461_9.diag.txt | 7 -- .../emptyIntersectionTypes/kt45461_9.fir.kt | 13 --- .../emptyIntersectionTypes/kt45461_9.kt | 4 +- .../emptyIntersectionTypes/kt54411.diag.txt | 9 -- .../emptyIntersectionTypes/kt54411.kt | 3 +- .../checkers/EmptyIntersectionTypeChecker.kt | 102 +----------------- 51 files changed, 42 insertions(+), 420 deletions(-) delete mode 100644 compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_10.diag.txt delete mode 100644 compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_13.diag.txt delete mode 100644 compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_15.diag.txt delete mode 100644 compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_15.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_16.diag.txt delete mode 100644 compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_19.diag.txt delete mode 100644 compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_19.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_21.diag.txt delete mode 100644 compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_21.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_24.diag.txt delete mode 100644 compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_24.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_28.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_29.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_30.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_31.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_32.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_33.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_34.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_35.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_8.diag.txt delete mode 100644 compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_8.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_9.diag.txt delete mode 100644 compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_9.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt54411.diag.txt diff --git a/compiler/testData/diagnostics/tests/callableReference/generic/explicitTypeArguments.fir.kt b/compiler/testData/diagnostics/tests/callableReference/generic/explicitTypeArguments.fir.kt index 746705ae582..efa93ce7aec 100644 --- a/compiler/testData/diagnostics/tests/callableReference/generic/explicitTypeArguments.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/generic/explicitTypeArguments.fir.kt @@ -18,7 +18,7 @@ fun test() { callFun>(::createWrapper) callFun>(::createWrapper) callFun>(::createWrapper) - callFun>(::createWrapper) + callFun>(::createWrapper) callFun>(::createWrapper).baz(::foo) } diff --git a/compiler/testData/diagnostics/tests/callableReference/generic/explicitTypeArguments.kt b/compiler/testData/diagnostics/tests/callableReference/generic/explicitTypeArguments.kt index 593f17ef28d..fe61c362c4c 100644 --- a/compiler/testData/diagnostics/tests/callableReference/generic/explicitTypeArguments.kt +++ b/compiler/testData/diagnostics/tests/callableReference/generic/explicitTypeArguments.kt @@ -18,7 +18,7 @@ fun test() { callFun>(::createWrapper) callFun>(::createWrapper) callFun>(::createWrapper) - callFun>(::createWrapper) + callFun>(::createWrapper) callFun>(::createWrapper).baz(::foo) } diff --git a/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.fir.kt b/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.fir.kt index d2bdb11904a..095c5577e58 100644 --- a/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.fir.kt @@ -70,7 +70,7 @@ fun main() { select(id1 { it.inv() }, id1 { x: Number -> TODO() }, id1(id2 { x: Int -> x })) select(id1 { it.inv() }, id1 { x: Number -> TODO() }, id1(id2(::takeInt))) select(id1 { x: Inv -> TODO() }, id1 { ")!>it.x.inv() }, id1 { x: Inv -> TODO() }) - select(id1 { & Inv")!>it }, id1 { x: Inv -> TODO() }, id1 { x: Inv -> TODO() }) + select(id1 { & Inv")!>it }, id1 { x: Inv -> TODO() }, id1 { x: Inv -> TODO() }) select(id(id2 { it.inv() }), id(id { x: Int -> x })) // Disambiguating callable references by other callable references without overloads diff --git a/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.kt b/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.kt index 3741b612314..28752aca64f 100644 --- a/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.kt +++ b/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.kt @@ -70,7 +70,7 @@ fun main() { select(id1 { it.inv() }, id1 { x: Number -> TODO() }, id1(id2 { x: Int -> x })) select(id1 { it.inv() }, id1 { x: Number -> TODO() }, id1(id2(::takeInt))) select(id1 { x: Inv -> TODO() }, id1 { ")!>it.x.inv() }, id1 { x: Inv -> TODO() }) - select(id1 { & Inv}")!>it }, id1 { x: Inv -> TODO() }, id1 { x: Inv -> TODO() }) + select(id1 { & Inv}")!>it }, id1 { x: Inv -> TODO() }, id1 { x: Inv -> TODO() }) select(id(id2 { it.inv() }), id(id { x: Int -> x })) // Disambiguating callable references by other callable references without overloads diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_10.diag.txt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_10.diag.txt deleted file mode 100644 index fcf5f0a0bb0..00000000000 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_10.diag.txt +++ /dev/null @@ -1,7 +0,0 @@ -/kt45461_10.kt:7:25: warning: parameter 'foo' is never used - fun takeFoo(foo: Foo) {} - ^ -/kt45461_10.kt:16:21: warning: type argument for a type parameter S has possible incompatible upper bounds: Out, K (final class and interface: Int, A) - Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 - ^ - diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_10.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_10.kt index fece20e88a7..42fe65daad7 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_10.kt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_10.kt @@ -1,5 +1,4 @@ // FIR_IDENTICAL -// RENDER_DIAGNOSTICS_FULL_TEXT class Foo @@ -13,5 +12,5 @@ interface A fun , L : N, N: A> main() { val foo = Foo() - Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 + Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 } diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_13.diag.txt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_13.diag.txt deleted file mode 100644 index 5fadb0bc7dd..00000000000 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_13.diag.txt +++ /dev/null @@ -1,7 +0,0 @@ -/kt45461_13.kt:7:25: warning: parameter 'foo' is never used - fun takeFoo(foo: Foo) {} - ^ -/kt45461_13.kt:16:24: warning: type argument for a type parameter S has possible incompatible upper bounds: Out, K (final class and interface: String, A) - Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 - ^ - diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_13.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_13.kt index 8e42949579a..f3c20fff579 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_13.kt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_13.kt @@ -1,5 +1,4 @@ // FIR_IDENTICAL -// RENDER_DIAGNOSTICS_FULL_TEXT class Foo @@ -13,5 +12,5 @@ class Out fun main() where N: Out { val foo = Foo() - Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 + Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 } diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_15.diag.txt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_15.diag.txt deleted file mode 100644 index 6d17cb635bc..00000000000 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_15.diag.txt +++ /dev/null @@ -1,6 +0,0 @@ -/kt45461_15.kt:5:25: warning: parameter 'foo' is never used - fun takeFoo(foo: Foo) {} - ^ -/kt45461_15.kt:14:21: warning: type argument for a type parameter S can't be inferred because it has incompatible upper bounds: Inv, K (incompatible type arguments: Int, {A & Number}). This will become an error in Kotlin 1.9 - Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 - ^ diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_15.fir.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_15.fir.kt deleted file mode 100644 index 624b1dbe7dd..00000000000 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_15.fir.kt +++ /dev/null @@ -1,15 +0,0 @@ -// RENDER_DIAGNOSTICS_FULL_TEXT -class Foo - -class Bar { - fun takeFoo(foo: Foo) {} -} - -class Inv

- -interface A - -fun , T> main() where T: A, T: Number { - val foo = Foo() - Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_15.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_15.kt index b079206960c..044120d69dc 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_15.kt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_15.kt @@ -1,4 +1,4 @@ -// RENDER_DIAGNOSTICS_FULL_TEXT +// FIR_IDENTICAL class Foo class Bar { @@ -11,5 +11,5 @@ interface A fun , T> main() where T: A, T: Number { val foo = Foo() - Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 + Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 } diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_16.diag.txt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_16.diag.txt deleted file mode 100644 index bef61b6b39f..00000000000 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_16.diag.txt +++ /dev/null @@ -1,15 +0,0 @@ -// FIR_IDENTICAL -class Foo - -class Bar { - fun takeFoo(foo: Foo) {} -} - -class Inv

- -interface A - -fun , T> main() where T: A, T: Number { - val foo = Foo() - Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 -} diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_16.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_16.kt index bef61b6b39f..977ce4ae8d5 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_16.kt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_16.kt @@ -11,5 +11,5 @@ interface A fun , T> main() where T: A, T: Number { val foo = Foo() - Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 + Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 } diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_19.diag.txt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_19.diag.txt deleted file mode 100644 index c668c3981d0..00000000000 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_19.diag.txt +++ /dev/null @@ -1,6 +0,0 @@ -/kt45461_19.kt:5:25: warning: parameter 'foo' is never used - fun takeFoo(foo: Foo) {} - ^ -/kt45461_19.kt:13:26: warning: type argument for a type parameter S can't be inferred because it has incompatible upper bounds: Out>, K (incompatible type arguments: Int, Number). This will become an error in Kotlin 1.9 - Bar>>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 - ^ diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_19.fir.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_19.fir.kt deleted file mode 100644 index 5c83a411f5e..00000000000 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_19.fir.kt +++ /dev/null @@ -1,14 +0,0 @@ -// RENDER_DIAGNOSTICS_FULL_TEXT -class Foo - -class Bar { - fun takeFoo(foo: Foo) {} -} - -class Out -class Inv - -fun , L : N, N: Inv> main() { - val foo = Foo() - Bar>>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 -} diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_19.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_19.kt index 81eedce1c54..0fdf87b1dc6 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_19.kt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_19.kt @@ -1,4 +1,4 @@ -// RENDER_DIAGNOSTICS_FULL_TEXT +// FIR_IDENTICAL class Foo class Bar { @@ -10,5 +10,5 @@ class Inv fun , L : N, N: Inv> main() { val foo = Foo() - Bar>>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 + Bar>>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 } diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_21.diag.txt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_21.diag.txt deleted file mode 100644 index 46c72d19b8b..00000000000 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_21.diag.txt +++ /dev/null @@ -1,6 +0,0 @@ -/kt45461_21.kt:5:25: warning: parameter 'foo' is never used - fun takeFoo(foo: Foo) {} - ^ -/kt45461_21.kt:13:25: warning: type argument for a type parameter S can't be inferred because it has incompatible upper bounds: In>, K (incompatible type arguments: Int, Number). This will become an error in Kotlin 1.9 - Bar>>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 - ^ diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_21.fir.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_21.fir.kt deleted file mode 100644 index e61baf024db..00000000000 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_21.fir.kt +++ /dev/null @@ -1,14 +0,0 @@ -// RENDER_DIAGNOSTICS_FULL_TEXT -class Foo - -class Bar { - fun takeFoo(foo: Foo) {} -} - -class In -class Inv - -fun >> main() { - val foo = Foo() - Bar>>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 -} diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_21.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_21.kt index 218de01bd68..0c7e6d90a26 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_21.kt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_21.kt @@ -1,4 +1,4 @@ -// RENDER_DIAGNOSTICS_FULL_TEXT +// FIR_IDENTICAL class Foo class Bar { @@ -10,5 +10,5 @@ class Inv fun >> main() { val foo = Foo() - Bar>>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 + Bar>>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 } diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_24.diag.txt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_24.diag.txt deleted file mode 100644 index 61cf7586f58..00000000000 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_24.diag.txt +++ /dev/null @@ -1,9 +0,0 @@ -/kt45461_24.kt:5:25: warning: parameter 'foo' is never used - fun takeFoo(foo: Foo) {} - ^ -/kt45461_24.kt:10:10: warning: 'Inv>' is a final type, and thus a value of the type parameter is predetermined -fun >> main() { - ^ -/kt45461_24.kt:12:35: warning: type argument for a type parameter S can't be inferred because it has incompatible upper bounds: Inv>, K (incompatible type arguments: Number, Int). This will become an error in Kotlin 1.9 - Bar>>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 - ^ diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_24.fir.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_24.fir.kt deleted file mode 100644 index 3c93ffe315f..00000000000 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_24.fir.kt +++ /dev/null @@ -1,13 +0,0 @@ -// RENDER_DIAGNOSTICS_FULL_TEXT -class Foo - -class Bar { - fun takeFoo(foo: Foo) {} -} - -class Inv - -fun Inv>> main() { - val foo = Foo() - Bar>>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 -} diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_24.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_24.kt index 95444ee4403..8846f45322a 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_24.kt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_24.kt @@ -1,4 +1,4 @@ -// RENDER_DIAGNOSTICS_FULL_TEXT +// FIR_IDENTICAL class Foo class Bar { @@ -9,5 +9,5 @@ class Inv fun Inv>> main() { val foo = Foo() - Bar>>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 + Bar>>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 } diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_26.diag.txt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_26.diag.txt index 6179b9bc695..9c51e4ca1b6 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_26.diag.txt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_26.diag.txt @@ -1,10 +1,6 @@ /kt45461_26.kt:13:25: error: type mismatch: inferred type is {K & Out} but Out was expected val x: Out = Bar>().takeFoo(foo) ^ -/kt45461_26.kt:13:44: error: type argument for a type parameter S can't be inferred because it has incompatible upper bounds: Out, K (multiple incompatible classes: String, Int) - val x: Out = Bar>().takeFoo(foo) - ^ /kt45461_26.kt:13:44: error: type mismatch: inferred type is {K & Out} but Out was expected val x: Out = Bar>().takeFoo(foo) ^ - diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_26.fir.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_26.fir.kt index ddbdb55da4e..55c0401a65b 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_26.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_26.fir.kt @@ -10,5 +10,5 @@ class Out fun Out> main() { val foo = Foo() - val x: Out = Bar>()., K; multiple incompatible classes; : kotlin/String, kotlin/Int")!>takeFoo(foo) + val x: Out = Bar>().takeFoo(foo) } diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_26.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_26.kt index 5e7b3bfab00..02a97fc0eb4 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_26.kt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_26.kt @@ -10,5 +10,5 @@ class Out fun Out> main() { val foo = Foo() - val x: Out = Bar>()., K; multiple incompatible classes; : String, Int"), TYPE_MISMATCH!>takeFoo(foo) + val x: Out = Bar>().takeFoo(foo) } diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_28.fir.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_28.fir.kt deleted file mode 100644 index 82632a9383a..00000000000 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_28.fir.kt +++ /dev/null @@ -1,12 +0,0 @@ -class Foo - -class Bar { - fun takeFoo(foo: Foo) {} -} - -class Inv - -fun >> main() { - val foo = Foo() - Bar>>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 -} diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_28.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_28.kt index 91ec17ab6d1..ee48aa9061a 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_28.kt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_28.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL class Foo class Bar { @@ -8,5 +9,5 @@ class Inv fun >> main() { val foo = Foo() - Bar>>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 + Bar>>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 } diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_29.fir.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_29.fir.kt deleted file mode 100644 index 8d926c469b2..00000000000 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_29.fir.kt +++ /dev/null @@ -1,15 +0,0 @@ -class Foo - -class Bar { - fun takeFoo(foo: Foo) {} -} - -class Inv

- -interface A -interface B - -fun > main() { - val foo = Foo() - Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 -} diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_29.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_29.kt index 98674519815..cffadbd02ce 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_29.kt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_29.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL class Foo class Bar { @@ -11,5 +12,5 @@ interface B fun > main() { val foo = Foo() - Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 + Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 } diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_30.fir.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_30.fir.kt deleted file mode 100644 index a1d0271aec5..00000000000 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_30.fir.kt +++ /dev/null @@ -1,15 +0,0 @@ -class Foo - -class Bar { - fun takeFoo(foo: Foo) {} -} - -class Out - -interface A -interface B : A - -fun >> main() { - val foo = Foo() - Bar>>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 -} diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_30.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_30.kt index 7437993de9d..7abff833ba9 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_30.kt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_30.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL class Foo class Bar { @@ -11,5 +12,5 @@ interface B : A fun >> main() { val foo = Foo() - Bar>>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 + Bar>>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 } diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_31.fir.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_31.fir.kt deleted file mode 100644 index bdcc7a79f22..00000000000 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_31.fir.kt +++ /dev/null @@ -1,15 +0,0 @@ -class Foo - -class Bar { - fun takeFoo(foo: Foo) {} -} - -class Out - -interface A -interface B : A - -fun >> main() { - val foo = Foo() - Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 -} diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_31.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_31.kt index 6052625fe1a..03e8a97ac1b 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_31.kt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_31.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL class Foo class Bar { @@ -11,5 +12,5 @@ interface B : A fun >> main() { val foo = Foo() - Bar>()., K; incompatible supertypes; : A, A")!>takeFoo(foo) // error in 1.3.72, no error in 1.4.31 + Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 } diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_32.fir.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_32.fir.kt deleted file mode 100644 index 4e365b5cae3..00000000000 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_32.fir.kt +++ /dev/null @@ -1,16 +0,0 @@ -class Foo - -class Bar { - fun takeFoo(foo: Foo) {} -} - -class Out - -interface A -interface B : A -interface C : A - -fun > main() { - val foo = Foo() - Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 -} diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_32.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_32.kt index a1c46761b80..e8c5c5164c5 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_32.kt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_32.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL class Foo class Bar { @@ -12,5 +13,5 @@ interface C : A fun > main() { val foo = Foo() - Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 + Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 } diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_33.fir.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_33.fir.kt deleted file mode 100644 index d91aceb2e39..00000000000 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_33.fir.kt +++ /dev/null @@ -1,16 +0,0 @@ -class Foo - -class Bar { - fun takeFoo(foo: Foo) {} -} - -class Out - -interface A -class B : A -class C : A - -fun Out> main() { - val foo = Foo() - Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 -} diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_33.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_33.kt index 0af0f745e3f..403ff9e5575 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_33.kt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_33.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL class Foo class Bar { @@ -12,5 +13,5 @@ class C : A fun Out> main() { val foo = Foo() - Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 + Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 } diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_34.fir.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_34.fir.kt deleted file mode 100644 index ff2edc4c2f5..00000000000 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_34.fir.kt +++ /dev/null @@ -1,15 +0,0 @@ -class Foo - -class Bar { - fun takeFoo(foo: Foo) {} -} - -class Out - -interface A -class B : A - -fun >> main() { - val foo = Foo() - Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 -} diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_34.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_34.kt index d4a1f9c7dcf..ece74042478 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_34.kt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_34.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL class Foo class Bar { @@ -11,5 +12,5 @@ class B : A fun >> main() { val foo = Foo() - Bar>()., K; incompatible supertypes; : A, A")!>takeFoo(foo) // error in 1.3.72, no error in 1.4.31 + Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 } diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_35.fir.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_35.fir.kt deleted file mode 100644 index 009ce7477cf..00000000000 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_35.fir.kt +++ /dev/null @@ -1,16 +0,0 @@ -// WITH_STDLIB - -class Foo - -class Bar - -fun Bar.takeFoo(foo: Foo): Int = 1 - -class Inv - -fun Inv>> main() { - fun Bar.takeFoo(foo: Foo): String = "" - - val foo = Foo() - Bar>>().takeFoo(foo) -} diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_35.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_35.kt index 0b8ffdaf7d3..0c43b879f9c 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_35.kt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_35.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // WITH_STDLIB class Foo @@ -12,5 +13,5 @@ fun Inv>> main() { fun Bar.takeFoo(foo: Foo): String = "" val foo = Foo() - Bar>>().takeFoo(foo) + Bar>>().takeFoo(foo) } diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_35_Enabled.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_35_Enabled.kt index 41f8f2a5522..6f2e9fd8432 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_35_Enabled.kt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_35_Enabled.kt @@ -14,5 +14,5 @@ fun Inv>> main() { fun Bar.takeFoo(foo: Foo): String = "" val foo = Foo() - Bar>>().takeFoo(foo) + Bar>>().takeFoo(foo) } diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_8.diag.txt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_8.diag.txt deleted file mode 100644 index 106f9f552b7..00000000000 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_8.diag.txt +++ /dev/null @@ -1,9 +0,0 @@ -/kt45461_8.kt:5:25: warning: parameter 'foo' is never used - fun takeFoo(foo: Foo) {} - ^ -/kt45461_8.kt:10:28: warning: 'Int' is a final type, and thus a value of the type parameter is predetermined -fun , L : N, N: Int> main() { - ^ -/kt45461_8.kt:12:24: warning: type argument for a type parameter S can't be inferred because it has incompatible upper bounds: Inv, K (incompatible type arguments: Number, Int). This will become an error in Kotlin 1.9 - Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 - ^ diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_8.fir.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_8.fir.kt deleted file mode 100644 index ccba1a5610d..00000000000 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_8.fir.kt +++ /dev/null @@ -1,13 +0,0 @@ -// RENDER_DIAGNOSTICS_FULL_TEXT -class Foo - -class Bar { - fun takeFoo(foo: Foo) {} -} - -class Inv

- -fun , L : N, N: Int> main() { - val foo = Foo() - Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_8.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_8.kt index 81534b2a38a..2fbe30da4ed 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_8.kt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_8.kt @@ -1,4 +1,4 @@ -// RENDER_DIAGNOSTICS_FULL_TEXT +// FIR_IDENTICAL class Foo class Bar { @@ -9,5 +9,5 @@ class Inv

fun , L : N, N: Int> main() { val foo = Foo() - Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 + Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 } diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_9.diag.txt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_9.diag.txt deleted file mode 100644 index e0660259e84..00000000000 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_9.diag.txt +++ /dev/null @@ -1,7 +0,0 @@ -/kt45461_9.kt:5:25: warning: parameter 'foo' is never used - fun takeFoo(foo: Foo) {} - ^ -/kt45461_9.kt:12:21: warning: type argument for a type parameter S can't be inferred because it has incompatible upper bounds: Inv, Inv (incompatible type arguments: Int, Number). This will become an error in Kotlin 1.9 - Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 - ^ - diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_9.fir.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_9.fir.kt deleted file mode 100644 index cf30ece6fa7..00000000000 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_9.fir.kt +++ /dev/null @@ -1,13 +0,0 @@ -// RENDER_DIAGNOSTICS_FULL_TEXT -class Foo - -class Bar { - fun takeFoo(foo: Foo) {} -} - -class Inv

- -fun , L : N, N: Number> main() { - val foo = Foo>() - Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 -} diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_9.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_9.kt index a6d1e9c3e2b..c87da3a21fb 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_9.kt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_9.kt @@ -1,4 +1,4 @@ -// RENDER_DIAGNOSTICS_FULL_TEXT +// FIR_IDENTICAL class Foo class Bar { @@ -9,5 +9,5 @@ class Inv

fun , L : N, N: Number> main() { val foo = Foo>() - Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 + Bar>().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 } diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt54411.diag.txt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt54411.diag.txt deleted file mode 100644 index a1494b08584..00000000000 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt54411.diag.txt +++ /dev/null @@ -1,9 +0,0 @@ -/kt54411.kt:5:68: warning: parameter 'createNewSegment' is never used -inline fun > AtomicRef.findSegmentAndMoveForward(createNewSegment: (prev: F?) -> F) = null - ^ -/kt54411.kt:14:14: warning: type argument for a type parameter F has possible incompatible upper bounds: Segment>, OneElementSegment? (final class and non-final class: Segment>, OneElementSegment) - tail.findSegmentAndMoveForward(::createSegment) - ^ -/kt54411.kt:18:31: warning: parameter 'prev' is never used -private fun createSegment(prev: OneElementSegment?) = OneElementSegment() - ^ diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt54411.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt54411.kt index 1ffeb7ebe99..ee081f69a64 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt54411.kt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt54411.kt @@ -1,5 +1,4 @@ // FIR_IDENTICAL -// !RENDER_DIAGNOSTICS_FULL_TEXT class AtomicRef(val value: T) inline fun > AtomicRef.findSegmentAndMoveForward(createNewSegment: (prev: F?) -> F) = null @@ -11,7 +10,7 @@ interface Queue { // F <: Segment from upper bound // F <: OneElementSegment>? from ::createSegment argument. ? is questionable here // (F?) -> F <: (OneElementSegment?) -> OneElementSegment - tail.findSegmentAndMoveForward(::createSegment) + tail.findSegmentAndMoveForward(::createSegment) } } diff --git a/core/compiler.common/src/org/jetbrains/kotlin/resolve/checkers/EmptyIntersectionTypeChecker.kt b/core/compiler.common/src/org/jetbrains/kotlin/resolve/checkers/EmptyIntersectionTypeChecker.kt index 2aaf1bb2b56..1768d943a70 100644 --- a/core/compiler.common/src/org/jetbrains/kotlin/resolve/checkers/EmptyIntersectionTypeChecker.kt +++ b/core/compiler.common/src/org/jetbrains/kotlin/resolve/checkers/EmptyIntersectionTypeChecker.kt @@ -107,18 +107,10 @@ internal object EmptyIntersectionTypeChecker { ).singleOrNull() when { - firstSuperTypeWithSecondConstructor != null && secondSuperTypeByFirstConstructor != null -> { - val argumentsIntersectionKind = computeByCheckingTypeArguments( - firstSuperTypeWithSecondConstructor, secondSuperTypeByFirstConstructor - ) ?: continue - - if (argumentsIntersectionKind.kind.isDefinitelyEmpty()) - return argumentsIntersectionKind - - if (possibleEmptyIntersectionKind == null && argumentsIntersectionKind.kind.isPossiblyEmpty()) - possibleEmptyIntersectionKind = argumentsIntersectionKind + firstSuperTypeWithSecondConstructor != null || secondSuperTypeByFirstConstructor != null -> { + continue } - firstSuperTypeWithSecondConstructor == null && secondSuperTypeByFirstConstructor == null && !atLeastOneInterface -> { + !atLeastOneInterface -> { // Two classes can't have a common subtype if neither is a subtype of another return EmptyIntersectionTypeInfo(EmptyIntersectionTypeKind.MULTIPLE_CLASSES, firstType, secondType) } @@ -140,70 +132,6 @@ internal object EmptyIntersectionTypeChecker { return possibleEmptyIntersectionKind } - private fun TypeSystemInferenceExtensionContext.computeByCheckingTypeArguments( - firstType: KotlinTypeMarker, - secondType: KotlinTypeMarker, - ): EmptyIntersectionTypeInfo? { - require(firstType.typeConstructor() == secondType.typeConstructor()) { - "Type constructors of the passed types should be the same to compare their arguments" - } - - fun isSubtypeOf(firstType: KotlinTypeMarker, secondType: KotlinTypeMarker) = - AbstractTypeChecker.isSubtypeOf(this, firstType, secondType) - - fun areEqualTypes(firstType: KotlinTypeMarker, secondType: KotlinTypeMarker) = - AbstractTypeChecker.equalTypes(this, firstType, secondType) - - fun Boolean.toEmptyIntersectionKind(vararg types: KotlinTypeMarker) = - if (this) null else EmptyIntersectionTypeInfo(EmptyIntersectionTypeKind.INCOMPATIBLE_TYPE_ARGUMENTS, *types) - - var possibleEmptyIntersectionTypeInfo: EmptyIntersectionTypeInfo? = null - - for ((i, argumentOfFirst) in firstType.getArguments().withIndex()) { - @Suppress("NAME_SHADOWING") - val argumentOfFirst = uncaptureIfNeeded(argumentOfFirst) - val argumentOfSecond = uncaptureIfNeeded(secondType.getArgument(i)) - - if (argumentOfFirst == argumentOfSecond || argumentOfFirst.isStarProjection() || argumentOfSecond.isStarProjection()) - continue - - val argumentTypeOfFirst = argumentOfFirst.getType() - val argumentTypeOfSecond = argumentOfSecond.getType() - val intersectionKindOfArguments = when { - areArgumentsOfSpecifiedVariances(firstType, secondType, i, TypeVariance.INV, TypeVariance.INV) -> - areEqualTypes(argumentTypeOfFirst, argumentTypeOfSecond) - .toEmptyIntersectionKind(argumentTypeOfFirst, argumentTypeOfSecond) - areArgumentsOfSpecifiedVariances(firstType, secondType, i, TypeVariance.INV, TypeVariance.OUT) -> - isSubtypeOf(argumentTypeOfFirst, argumentTypeOfSecond) - .toEmptyIntersectionKind(argumentTypeOfFirst, argumentTypeOfSecond) - areArgumentsOfSpecifiedVariances(firstType, secondType, i, TypeVariance.INV, TypeVariance.IN) -> - isSubtypeOf(argumentTypeOfSecond, argumentTypeOfFirst) - .toEmptyIntersectionKind(argumentTypeOfFirst, argumentTypeOfSecond) - areArgumentsOfSpecifiedVariances(firstType, secondType, i, TypeVariance.IN, TypeVariance.OUT) -> { - if (argumentTypeOfFirst.argumentsCount() == 0 && argumentTypeOfSecond.argumentsCount() == 0) { - isSubtypeOf(argumentTypeOfFirst, argumentTypeOfSecond) - .toEmptyIntersectionKind(argumentTypeOfFirst, argumentTypeOfSecond) - } else { - computeByHavingCommonSubtype(argumentTypeOfFirst, argumentTypeOfSecond) - } - } - areArgumentsOfSpecifiedVariances(firstType, secondType, i, TypeVariance.OUT, TypeVariance.OUT) - || areArgumentsOfSpecifiedVariances(firstType, secondType, i, TypeVariance.IN, TypeVariance.IN) -> { - computeByHavingCommonSubtype(argumentTypeOfFirst, argumentTypeOfSecond) - } - else -> true.toEmptyIntersectionKind(argumentTypeOfFirst, argumentTypeOfSecond) - } ?: continue - - if (intersectionKindOfArguments.kind.isDefinitelyEmpty()) - return intersectionKindOfArguments - - if (possibleEmptyIntersectionTypeInfo == null && intersectionKindOfArguments.kind.isPossiblyEmpty()) - possibleEmptyIntersectionTypeInfo = intersectionKindOfArguments - } - - return possibleEmptyIntersectionTypeInfo - } - private fun TypeSystemInferenceExtensionContext.getIncompatibleSuperTypes( firstType: KotlinTypeMarker, secondType: KotlinTypeMarker ): Array? { @@ -268,30 +196,6 @@ internal object EmptyIntersectionTypeChecker { return !typeConstructor.isAnyConstructor() && !typeConstructor.isNothingConstructor() } - private fun TypeSystemInferenceExtensionContext.areArgumentsOfSpecifiedVariances( - firstType: KotlinTypeMarker, - secondType: KotlinTypeMarker, - argumentIndex: Int, - variance1: TypeVariance, - variance2: TypeVariance, - ): Boolean { - fun getEffectiveVariance(type: KotlinTypeMarker): TypeVariance? { - val argument = uncaptureIfNeeded(type.getArgument(argumentIndex)) - val parameter = type.typeConstructor().getParameter(argumentIndex) - return AbstractTypeChecker.effectiveVariance(parameter.getVariance(), argument.getVariance()) - } - - val effectiveVariance1 = getEffectiveVariance(firstType) - val effectiveVariance2 = getEffectiveVariance(secondType) - - return (effectiveVariance1 == variance1 && effectiveVariance2 == variance2) - || (effectiveVariance1 == variance2 && effectiveVariance2 == variance1) - } - - private fun TypeSystemInferenceExtensionContext.uncaptureIfNeeded(argument: TypeArgumentMarker): TypeArgumentMarker { - val type = argument.getType() - return if (type is CapturedTypeMarker) type.typeConstructorProjection() else argument - } } class EmptyIntersectionTypeInfo(val kind: EmptyIntersectionTypeKind, vararg val casingTypes: KotlinTypeMarker) \ No newline at end of file