From 81c0ee471f439a3d4d0c20e33fa57a3b6a88cdec Mon Sep 17 00:00:00 2001 From: Kirill Rakhman Date: Fri, 15 Mar 2024 13:06:06 +0100 Subject: [PATCH] [Tests] Reproduce #KT-65704 --- ...cCompilerTestFirTestdataTestGenerated.java | 6 ++ ...osticCompilerFirTestDataTestGenerated.java | 6 ++ ...putTypesCapturedTypeWithRecursiveBounds.kt | 3 +- ...pturedTypeWithRecursiveBoundsAfter.fir.txt | 81 +++++++++++++++++++ ...pesCapturedTypeWithRecursiveBoundsAfter.kt | 45 +++++++++++ .../FirLightTreeDiagnosticsTestGenerated.java | 6 ++ .../FirPsiDiagnosticTestGenerated.java | 6 ++ 7 files changed, 151 insertions(+), 2 deletions(-) create mode 100644 compiler/fir/analysis-tests/testData/resolve/inference/onlyInputTypesCapturedTypeWithRecursiveBoundsAfter.fir.txt create mode 100644 compiler/fir/analysis-tests/testData/resolve/inference/onlyInputTypesCapturedTypeWithRecursiveBoundsAfter.kt diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFirTestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFirTestdataTestGenerated.java index 3d2a32decc7..a5791e6d435 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFirTestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFirTestdataTestGenerated.java @@ -3543,6 +3543,12 @@ public class DiagnosticCompilerTestFirTestdataTestGenerated extends AbstractDiag runTest("compiler/fir/analysis-tests/testData/resolve/inference/onlyInputTypesCapturedTypeWithRecursiveBounds.kt"); } + @Test + @TestMetadata("onlyInputTypesCapturedTypeWithRecursiveBoundsAfter.kt") + public void testOnlyInputTypesCapturedTypeWithRecursiveBoundsAfter() { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/onlyInputTypesCapturedTypeWithRecursiveBoundsAfter.kt"); + } + @Test @TestMetadata("overloadResolutionByLambdaArgumentType.kt") public void testOverloadResolutionByLambdaArgumentType() { diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFirTestDataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFirTestDataTestGenerated.java index 6b0db25b6c3..ca974644b0a 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFirTestDataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFirTestDataTestGenerated.java @@ -3543,6 +3543,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFirTestDataTestGenerated runTest("compiler/fir/analysis-tests/testData/resolve/inference/onlyInputTypesCapturedTypeWithRecursiveBounds.kt"); } + @Test + @TestMetadata("onlyInputTypesCapturedTypeWithRecursiveBoundsAfter.kt") + public void testOnlyInputTypesCapturedTypeWithRecursiveBoundsAfter() { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/onlyInputTypesCapturedTypeWithRecursiveBoundsAfter.kt"); + } + @Test @TestMetadata("overloadResolutionByLambdaArgumentType.kt") public void testOverloadResolutionByLambdaArgumentType() { diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/onlyInputTypesCapturedTypeWithRecursiveBounds.kt b/compiler/fir/analysis-tests/testData/resolve/inference/onlyInputTypesCapturedTypeWithRecursiveBounds.kt index 6d564123bb4..268ad0aa5da 100644 --- a/compiler/fir/analysis-tests/testData/resolve/inference/onlyInputTypesCapturedTypeWithRecursiveBounds.kt +++ b/compiler/fir/analysis-tests/testData/resolve/inference/onlyInputTypesCapturedTypeWithRecursiveBounds.kt @@ -1,5 +1,6 @@ // FULL_JDK // WITH_STDLIB +// LANGUAGE: -JavaTypeParameterDefaultRepresentationWithDNN import java.util.EnumMap interface I @@ -21,8 +22,6 @@ open class FooEnumMap

(val data: EnumMap) where P : Enum

, P : I private fun test(node: FooEnumMap<*>) { node.data.get(MyEnum.EnumEntry) val map = node.data - // TODO inferred type argument is giant multi-level type KT-65704 - // R|/map|.R|kotlin/collections/get| & I), it(kotlin/Enum<*>? & I?)>> & I), it(kotlin/Enum<*>? & I?)>> & I), it(kotlin/Enum<*>? & I?)>|, R|kotlin/Any!|>(Q|MyEnum|.R|/MyEnum.EnumEntry|) map.get(MyEnum.EnumEntry) } diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/onlyInputTypesCapturedTypeWithRecursiveBoundsAfter.fir.txt b/compiler/fir/analysis-tests/testData/resolve/inference/onlyInputTypesCapturedTypeWithRecursiveBoundsAfter.fir.txt new file mode 100644 index 00000000000..91a31e758b0 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/inference/onlyInputTypesCapturedTypeWithRecursiveBoundsAfter.fir.txt @@ -0,0 +1,81 @@ +FILE: onlyInputTypesCapturedTypeWithRecursiveBoundsAfter.kt + public abstract interface I : R|kotlin/Any| { + } + public final enum class MyEnum : R|I|, R|kotlin/Enum| { + private constructor(): R|MyEnum| { + super|>() + } + + public final static enum entry EnumEntry: R|MyEnum| + public final static fun values(): R|kotlin/Array| { + } + + public final static fun valueOf(value: R|kotlin/String|): R|MyEnum| { + } + + public final static val entries: R|kotlin/enums/EnumEntries| + public get(): R|kotlin/enums/EnumEntries| + + } + public open class Foo

|, R|I|> : R|kotlin/Any| { + public constructor

|, R|I|>(data: R|kotlin/collections/Map|): R|Foo

| { + super() + } + + public final val data: R|kotlin/collections/Map| = R|/data| + public get(): R|kotlin/collections/Map| + + } + private final fun test(node: R|Foo<*>|): R|kotlin/Unit| { + R|/node|.R|SubstitutionOverride|>|.R|kotlin/collections/get| & I)|, R|kotlin/Any?|>(Q|MyEnum|.R|/MyEnum.EnumEntry|) + lval map: R|kotlin/collections/Map & I), kotlin/Any?>| = R|/node|.R|SubstitutionOverride|>| + R|/map|.R|kotlin/collections/get| & I)|, R|kotlin/Any?|>(Q|MyEnum|.R|/MyEnum.EnumEntry|) + } + public open class FooEnumMap

|, R|I|> : R|kotlin/Any| { + public constructor

|, R|I|>(data: R|java/util/EnumMap|): R|FooEnumMap

| { + super() + } + + public final val data: R|java/util/EnumMap| = R|/data| + public get(): R|java/util/EnumMap| + + } + private final fun test(node: R|FooEnumMap<*>|): R|kotlin/Unit| { + R|/node|.R|SubstitutionOverride|>|.R|kotlin/collections/get| & I), it(kotlin/Enum<*>? & I?)>|, R|kotlin/Any!|>(Q|MyEnum|.R|/MyEnum.EnumEntry|) + lval map: R|java/util/EnumMap & I), kotlin/Any?>| = R|/node|.R|SubstitutionOverride|>| + R|/map|.R|kotlin/collections/get| & I), it(kotlin/Enum<*>? & I?)>> & I), it(kotlin/Enum<*>? & I?)>> & I), it(kotlin/Enum<*>? & I?)>|, R|kotlin/Any!|>(Q|MyEnum|.R|/MyEnum.EnumEntry|) + } + public open class Foo2

: R|kotlin/Any| { + public constructor

(data: R|kotlin/collections/Map|): R|Foo2

| { + super() + } + + public final val data: R|kotlin/collections/Map| = R|/data| + public get(): R|kotlin/collections/Map| + + } + private final fun test(node: R|Foo2<*>|): R|kotlin/Unit| { + R|/node|.R|SubstitutionOverride|>|.R|kotlin/collections/get|(Q|MyEnum|.R|/MyEnum.EnumEntry|) + lval map: R|kotlin/collections/Map| = R|/node|.R|SubstitutionOverride|>| + R|/map|.R|kotlin/collections/get|(Q|MyEnum|.R|/MyEnum.EnumEntry|) + } + public abstract interface I2 : R|kotlin/Any| { + } + public final object C : R|I|, R|I2| { + private constructor(): R|C| { + super() + } + + } + public open class Foo3

: R|kotlin/Any| { + public constructor

(data: R|kotlin/collections/Map|): R|Foo3

| { + super() + } + + public final val data: R|kotlin/collections/Map| = R|/data| + public get(): R|kotlin/collections/Map| + + } + public final fun test3(node: R|Foo3<*>|): R|kotlin/Unit| { + R|/node|.R|SubstitutionOverride|>|.R|kotlin/collections/get|(Q|C|) + } diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/onlyInputTypesCapturedTypeWithRecursiveBoundsAfter.kt b/compiler/fir/analysis-tests/testData/resolve/inference/onlyInputTypesCapturedTypeWithRecursiveBoundsAfter.kt new file mode 100644 index 00000000000..c99fb5da100 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/inference/onlyInputTypesCapturedTypeWithRecursiveBoundsAfter.kt @@ -0,0 +1,45 @@ +// FULL_JDK +// WITH_STDLIB +// LANGUAGE: +JavaTypeParameterDefaultRepresentationWithDNN +import java.util.EnumMap + +interface I + +enum class MyEnum : I { + EnumEntry +} + +open class Foo

(val data: Map) where P : Enum

, P : I + +private fun test(node: Foo<*>) { + node.data.get(MyEnum.EnumEntry) + val map = node.data + map.get(MyEnum.EnumEntry) +} + +open class FooEnumMap

(val data: EnumMap) where P : Enum

, P : I + +private fun test(node: FooEnumMap<*>) { + node.data.get(MyEnum.EnumEntry) + val map = node.data + map.get(MyEnum.EnumEntry) +} + +open class Foo2

(val data: Map) + +private fun test(node: Foo2<*>) { + node.data.get(MyEnum.EnumEntry) + val map = node.data + map.get(MyEnum.EnumEntry) +} + +interface I2 + +object C: I, I2 + +open class Foo3

(val data: Map) where P : I, P : I2 + +fun test3(node: Foo3<*>) { + node.data.get(C) +} + diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeDiagnosticsTestGenerated.java index eb8599145d9..f7acbe5329e 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeDiagnosticsTestGenerated.java @@ -3543,6 +3543,12 @@ public class FirLightTreeDiagnosticsTestGenerated extends AbstractFirLightTreeDi runTest("compiler/fir/analysis-tests/testData/resolve/inference/onlyInputTypesCapturedTypeWithRecursiveBounds.kt"); } + @Test + @TestMetadata("onlyInputTypesCapturedTypeWithRecursiveBoundsAfter.kt") + public void testOnlyInputTypesCapturedTypeWithRecursiveBoundsAfter() { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/onlyInputTypesCapturedTypeWithRecursiveBoundsAfter.kt"); + } + @Test @TestMetadata("overloadResolutionByLambdaArgumentType.kt") public void testOverloadResolutionByLambdaArgumentType() { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiDiagnosticTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiDiagnosticTestGenerated.java index bc91c1017a8..9e4fd82ef1f 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiDiagnosticTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiDiagnosticTestGenerated.java @@ -3543,6 +3543,12 @@ public class FirPsiDiagnosticTestGenerated extends AbstractFirPsiDiagnosticTest runTest("compiler/fir/analysis-tests/testData/resolve/inference/onlyInputTypesCapturedTypeWithRecursiveBounds.kt"); } + @Test + @TestMetadata("onlyInputTypesCapturedTypeWithRecursiveBoundsAfter.kt") + public void testOnlyInputTypesCapturedTypeWithRecursiveBoundsAfter() { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/onlyInputTypesCapturedTypeWithRecursiveBoundsAfter.kt"); + } + @Test @TestMetadata("overloadResolutionByLambdaArgumentType.kt") public void testOverloadResolutionByLambdaArgumentType() {