From 980ab41ef120ef4535739a25e3b6a8ef30fc25a5 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Tue, 14 Mar 2023 12:46:49 +0100 Subject: [PATCH] FE: split one more test "buildList type argument is inferred into upper bound" Related to KT-48445, KT-56169 --- ...CompilerTestFE10TestdataTestGenerated.java | 18 ++++-- ...eeOldFrontendDiagnosticsTestGenerated.java | 18 ++++-- ...siOldFrontendDiagnosticsTestGenerated.java | 18 ++++-- .../buildListToUpperBoundInLazy.fir.kt | 64 +++++++++++++++++++ .../buildListToUpperBoundInLazy.kt | 64 +++++++++++++++++++ ...ildListToUpperBoundInLazyForbidden.fir.kt} | 4 +- ...> buildListToUpperBoundInLazyForbidden.kt} | 4 +- .../test/runners/DiagnosticTestGenerated.java | 18 ++++-- 8 files changed, 180 insertions(+), 28 deletions(-) create mode 100644 compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazy.fir.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazy.kt rename compiler/testData/diagnostics/testsWithStdLib/builderInference/{kt48445.fir.kt => buildListToUpperBoundInLazyForbidden.fir.kt} (94%) rename compiler/testData/diagnostics/testsWithStdLib/builderInference/{kt48445.kt => buildListToUpperBoundInLazyForbidden.kt} (94%) diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java index 594241dbafd..fdbb30ca60d 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java @@ -36948,6 +36948,18 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag runTest("compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundForbidden.kt"); } + @Test + @TestMetadata("buildListToUpperBoundInLazy.kt") + public void testBuildListToUpperBoundInLazy() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazy.kt"); + } + + @Test + @TestMetadata("buildListToUpperBoundInLazyForbidden.kt") + public void testBuildListToUpperBoundInLazyForbidden() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazyForbidden.kt"); + } + @Test @TestMetadata("completeIrrelevantCalls.kt") public void testCompleteIrrelevantCalls() throws Exception { @@ -36972,12 +36984,6 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag runTest("compiler/testData/diagnostics/testsWithStdLib/builderInference/inferCoroutineTypeInOldVersion.kt"); } - @Test - @TestMetadata("kt48445.kt") - public void testKt48445() throws Exception { - runTest("compiler/testData/diagnostics/testsWithStdLib/builderInference/kt48445.kt"); - } - @Test @TestMetadata("resolveUsualCallWithBuilderInference.kt") public void testResolveUsualCallWithBuilderInference() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java index ac691d3c85e..6fbb5147ece 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java @@ -36948,6 +36948,18 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundForbidden.kt"); } + @Test + @TestMetadata("buildListToUpperBoundInLazy.kt") + public void testBuildListToUpperBoundInLazy() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazy.kt"); + } + + @Test + @TestMetadata("buildListToUpperBoundInLazyForbidden.kt") + public void testBuildListToUpperBoundInLazyForbidden() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazyForbidden.kt"); + } + @Test @TestMetadata("completeIrrelevantCalls.kt") public void testCompleteIrrelevantCalls() throws Exception { @@ -36972,12 +36984,6 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/testsWithStdLib/builderInference/inferCoroutineTypeInOldVersion.kt"); } - @Test - @TestMetadata("kt48445.kt") - public void testKt48445() throws Exception { - runTest("compiler/testData/diagnostics/testsWithStdLib/builderInference/kt48445.kt"); - } - @Test @TestMetadata("resolveUsualCallWithBuilderInference.kt") public void testResolveUsualCallWithBuilderInference() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java index 482ee574d47..302830932bf 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java @@ -37044,6 +37044,18 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundForbidden.kt"); } + @Test + @TestMetadata("buildListToUpperBoundInLazy.kt") + public void testBuildListToUpperBoundInLazy() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazy.kt"); + } + + @Test + @TestMetadata("buildListToUpperBoundInLazyForbidden.kt") + public void testBuildListToUpperBoundInLazyForbidden() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazyForbidden.kt"); + } + @Test @TestMetadata("completeIrrelevantCalls.kt") public void testCompleteIrrelevantCalls() throws Exception { @@ -37068,12 +37080,6 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/testsWithStdLib/builderInference/inferCoroutineTypeInOldVersion.kt"); } - @Test - @TestMetadata("kt48445.kt") - public void testKt48445() throws Exception { - runTest("compiler/testData/diagnostics/testsWithStdLib/builderInference/kt48445.kt"); - } - @Test @TestMetadata("resolveUsualCallWithBuilderInference.kt") public void testResolveUsualCallWithBuilderInference() throws Exception { diff --git a/compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazy.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazy.fir.kt new file mode 100644 index 00000000000..56da5a43538 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazy.fir.kt @@ -0,0 +1,64 @@ +// !LANGUAGE: +UnrestrictedBuilderInference -ForbidInferringPostponedTypeVariableIntoDeclaredUpperBound +// ISSUE: KT-48445 + +internal class TowerDataElementsForName() { + val reversedFilteredLocalScopes by lazy(LazyThreadSafetyMode.NONE) { + @OptIn(ExperimentalStdlibApi::class) + buildList { + for (i in lastIndex downTo 0) { + add("") + } + } + } +} + +internal class TowerDataElementsForName2() { + @OptIn(ExperimentalStdlibApi::class) + val reversedFilteredLocalScopes = buildList { + val reversedFilteredLocalScopes by lazy(LazyThreadSafetyMode.NONE) { + @OptIn(ExperimentalStdlibApi::class) + buildList { + for (i in lastIndex downTo 0) { + add("") + } + } + } + add(reversedFilteredLocalScopes) + } +} + +internal class TowerDataElementsForName3() { + val reversedFilteredLocalScopes by lazy(LazyThreadSafetyMode.NONE) { + @OptIn(ExperimentalStdlibApi::class) + buildList l1@ { + for (i in lastIndex downTo 0) { + val reversedFilteredLocalScopes by lazy(LazyThreadSafetyMode.NONE) { + @OptIn(ExperimentalStdlibApi::class) + buildList { + for (i in lastIndex downTo 0) { + add("") + this@l1.add("") + } + } + } + } + } + } +} + +internal class TowerDataElementsForName4() { + @OptIn(ExperimentalStdlibApi::class) + val reversedFilteredLocalScopes = buildList l1@ { + class Foo { + val reversedFilteredLocalScopes by lazy(LazyThreadSafetyMode.NONE) { + @OptIn(ExperimentalStdlibApi::class) + buildList { + for (i in lastIndex downTo 0) { + add("") + this@l1.add("") + } + } + } + } + } +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazy.kt b/compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazy.kt new file mode 100644 index 00000000000..7dbcfc2bce1 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazy.kt @@ -0,0 +1,64 @@ +// !LANGUAGE: +UnrestrictedBuilderInference -ForbidInferringPostponedTypeVariableIntoDeclaredUpperBound +// ISSUE: KT-48445 + +internal class TowerDataElementsForName() { + val reversedFilteredLocalScopes by lazy(LazyThreadSafetyMode.NONE) { + @OptIn(ExperimentalStdlibApi::class) + buildList { + for (i in lastIndex downTo 0) { + add("") + } + } + } +} + +internal class TowerDataElementsForName2() { + @OptIn(ExperimentalStdlibApi::class) + val reversedFilteredLocalScopes = buildList { + val reversedFilteredLocalScopes by lazy(LazyThreadSafetyMode.NONE) { + @OptIn(ExperimentalStdlibApi::class) + buildList { + for (i in lastIndex downTo 0) { + add("") + } + } + } + add(reversedFilteredLocalScopes) + } +} + +internal class TowerDataElementsForName3() { + val reversedFilteredLocalScopes by lazy(LazyThreadSafetyMode.NONE) { + @OptIn(ExperimentalStdlibApi::class) + buildList l1@ { + for (i in lastIndex downTo 0) { + val reversedFilteredLocalScopes by lazy(LazyThreadSafetyMode.NONE) { + @OptIn(ExperimentalStdlibApi::class) + buildList { + for (i in lastIndex downTo 0) { + add("") + this@l1.add("") + } + } + } + } + } + } +} + +internal class TowerDataElementsForName4() { + @OptIn(ExperimentalStdlibApi::class) + val reversedFilteredLocalScopes = buildList l1@ { + class Foo { + val reversedFilteredLocalScopes by lazy(LazyThreadSafetyMode.NONE) { + @OptIn(ExperimentalStdlibApi::class) + buildList { + for (i in lastIndex downTo 0) { + add("") + this@l1.add("") + } + } + } + } + } +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/builderInference/kt48445.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazyForbidden.fir.kt similarity index 94% rename from compiler/testData/diagnostics/testsWithStdLib/builderInference/kt48445.fir.kt rename to compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazyForbidden.fir.kt index 5962b46850c..5820fe62d73 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/builderInference/kt48445.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazyForbidden.fir.kt @@ -1,5 +1,5 @@ -// !LANGUAGE: +UnrestrictedBuilderInference -// SKIP_TXT +// !LANGUAGE: +UnrestrictedBuilderInference +ForbidInferringPostponedTypeVariableIntoDeclaredUpperBound +// ISSUE: KT-56169 internal class TowerDataElementsForName() { val reversedFilteredLocalScopes by lazy(LazyThreadSafetyMode.NONE) { diff --git a/compiler/testData/diagnostics/testsWithStdLib/builderInference/kt48445.kt b/compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazyForbidden.kt similarity index 94% rename from compiler/testData/diagnostics/testsWithStdLib/builderInference/kt48445.kt rename to compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazyForbidden.kt index 458b199a9b0..7c122fb426e 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/builderInference/kt48445.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazyForbidden.kt @@ -1,5 +1,5 @@ -// !LANGUAGE: +UnrestrictedBuilderInference -// SKIP_TXT +// !LANGUAGE: +UnrestrictedBuilderInference +ForbidInferringPostponedTypeVariableIntoDeclaredUpperBound +// ISSUE: KT-56169 internal class TowerDataElementsForName() { val reversedFilteredLocalScopes by lazy(LazyThreadSafetyMode.NONE) { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index e9ac1337f4d..3384555e26b 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -37044,6 +37044,18 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundForbidden.kt"); } + @Test + @TestMetadata("buildListToUpperBoundInLazy.kt") + public void testBuildListToUpperBoundInLazy() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazy.kt"); + } + + @Test + @TestMetadata("buildListToUpperBoundInLazyForbidden.kt") + public void testBuildListToUpperBoundInLazyForbidden() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazyForbidden.kt"); + } + @Test @TestMetadata("completeIrrelevantCalls.kt") public void testCompleteIrrelevantCalls() throws Exception { @@ -37068,12 +37080,6 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/testsWithStdLib/builderInference/inferCoroutineTypeInOldVersion.kt"); } - @Test - @TestMetadata("kt48445.kt") - public void testKt48445() throws Exception { - runTest("compiler/testData/diagnostics/testsWithStdLib/builderInference/kt48445.kt"); - } - @Test @TestMetadata("resolveUsualCallWithBuilderInference.kt") public void testResolveUsualCallWithBuilderInference() throws Exception {