From c262b9793bedf1e55c09a798a9b52a97d800faf4 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 26 Feb 2024 10:06:29 +0100 Subject: [PATCH] K1: introduce BUILDER_INFERENCE_STUB_PARAMETER_TYPE to prevent compiler crashes This diagnostic is reported in rare situations when StubTypeForBuilderInference is kept as a parameter type of for loop or lambda. Before this commit, we had in K1 "Could not load module " from IrLinker instead. Related to: KT-52757, KT-53109, KT-63841, KT-64066 #KT-53478 Fixed (cherry picked from commit 678816f9e8cc9ff09a9472142752694aa8102541) --- ...CompilerTestFE10TestdataTestGenerated.java | 28 +++++++++++++++++++ ...sticCompilerFE10TestDataTestGenerated.java | 28 +++++++++++++++++++ ...eeOldFrontendDiagnosticsTestGenerated.java | 28 +++++++++++++++++++ ...siOldFrontendDiagnosticsTestGenerated.java | 28 +++++++++++++++++++ ...LightTreeBlackBoxCodegenTestGenerated.java | 22 +++++++++++++++ .../FirPsiBlackBoxCodegenTestGenerated.java | 22 +++++++++++++++ .../jetbrains/kotlin/diagnostics/Errors.java | 1 + .../rendering/DefaultErrorMessages.java | 1 + .../resolve/PlatformConfiguratorBase.kt | 3 +- .../BuilderInferenceAssignmentChecker.kt | 23 +++++++++++---- ...ForBuilderInferenceParameterTypeChecker.kt | 26 +++++++++++++++++ .../box/builderInference/issues/kt53478.kt | 19 +++++++++++++ .../box/builderInference/issues/kt64066.kt | 13 +++++++++ .../builderInference/issues/kt53478.fir.kt | 16 +++++++++++ .../tests/builderInference/issues/kt53478.kt | 16 +++++++++++ .../builderInference/issues/kt64066.fir.kt | 9 ++++++ .../tests/builderInference/issues/kt64066.kt | 9 ++++++ .../issues/kt64066disabled.kt | 26 +++++++++++++++++ .../test/runners/DiagnosticTestGenerated.java | 28 +++++++++++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 22 +++++++++++++++ .../IrBlackBoxCodegenTestGenerated.java | 22 +++++++++++++++ ...kBoxCodegenWithIrInlinerTestGenerated.java | 22 +++++++++++++++ .../LightAnalysisModeTestGenerated.java | 23 +++++++++++++++ .../fir/FirJsCodegenBoxTestGenerated.java | 22 +++++++++++++++ .../fir/FirJsES6CodegenBoxTestGenerated.java | 22 +++++++++++++++ .../test/ir/IrJsCodegenBoxTestGenerated.java | 22 +++++++++++++++ .../ir/IrJsES6CodegenBoxTestGenerated.java | 22 +++++++++++++++ .../FirNativeCodegenBoxTestGenerated.java | 25 +++++++++++++++++ .../FirNativeCodegenBoxTestNoPLGenerated.java | 27 ++++++++++++++++++ .../NativeCodegenBoxTestGenerated.java | 24 ++++++++++++++++ .../NativeCodegenBoxTestNoPLGenerated.java | 25 +++++++++++++++++ .../test/FirWasmCodegenBoxTestGenerated.java | 22 +++++++++++++++ .../test/K1WasmCodegenBoxTestGenerated.java | 22 +++++++++++++++ 33 files changed, 661 insertions(+), 7 deletions(-) create mode 100644 compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/StubForBuilderInferenceParameterTypeChecker.kt create mode 100644 compiler/testData/codegen/box/builderInference/issues/kt53478.kt create mode 100644 compiler/testData/codegen/box/builderInference/issues/kt64066.kt create mode 100644 compiler/testData/diagnostics/tests/builderInference/issues/kt53478.fir.kt create mode 100644 compiler/testData/diagnostics/tests/builderInference/issues/kt53478.kt create mode 100644 compiler/testData/diagnostics/tests/builderInference/issues/kt64066.fir.kt create mode 100644 compiler/testData/diagnostics/tests/builderInference/issues/kt64066.kt create mode 100644 compiler/testData/diagnostics/tests/builderInference/issues/kt64066disabled.kt diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java index d384eb5a9d873..69698acd9930f 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java @@ -3316,6 +3316,34 @@ public void testAllFilesPresentInBuilderInference() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/builderInference"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform"); } + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/builderInference/issues") + @TestDataPath("$PROJECT_ROOT") + public class Issues { + @Test + public void testAllFilesPresentInIssues() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/builderInference/issues"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform"); + } + + @Test + @TestMetadata("kt53478.kt") + public void testKt53478() throws Exception { + runTest("compiler/testData/diagnostics/tests/builderInference/issues/kt53478.kt"); + } + + @Test + @TestMetadata("kt64066.kt") + public void testKt64066() throws Exception { + runTest("compiler/testData/diagnostics/tests/builderInference/issues/kt64066.kt"); + } + + @Test + @TestMetadata("kt64066disabled.kt") + public void testKt64066disabled() throws Exception { + runTest("compiler/testData/diagnostics/tests/builderInference/issues/kt64066disabled.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/tests/builderInference/oneParameter") @TestDataPath("$PROJECT_ROOT") diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java index 62280b699ec6f..867c89169e68a 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java @@ -3316,6 +3316,34 @@ public void testAllFilesPresentInBuilderInference() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/builderInference"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform"); } + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/builderInference/issues") + @TestDataPath("$PROJECT_ROOT") + public class Issues { + @Test + public void testAllFilesPresentInIssues() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/builderInference/issues"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform"); + } + + @Test + @TestMetadata("kt53478.kt") + public void testKt53478() throws Exception { + runTest("compiler/testData/diagnostics/tests/builderInference/issues/kt53478.kt"); + } + + @Test + @TestMetadata("kt64066.kt") + public void testKt64066() throws Exception { + runTest("compiler/testData/diagnostics/tests/builderInference/issues/kt64066.kt"); + } + + @Test + @TestMetadata("kt64066disabled.kt") + public void testKt64066disabled() throws Exception { + runTest("compiler/testData/diagnostics/tests/builderInference/issues/kt64066disabled.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/tests/builderInference/oneParameter") @TestDataPath("$PROJECT_ROOT") 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 db1c87fcf8921..5656a8c6cf720 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 @@ -3316,6 +3316,34 @@ public void testAllFilesPresentInBuilderInference() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/builderInference"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform"); } + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/builderInference/issues") + @TestDataPath("$PROJECT_ROOT") + public class Issues { + @Test + public void testAllFilesPresentInIssues() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/builderInference/issues"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform"); + } + + @Test + @TestMetadata("kt53478.kt") + public void testKt53478() throws Exception { + runTest("compiler/testData/diagnostics/tests/builderInference/issues/kt53478.kt"); + } + + @Test + @TestMetadata("kt64066.kt") + public void testKt64066() throws Exception { + runTest("compiler/testData/diagnostics/tests/builderInference/issues/kt64066.kt"); + } + + @Test + @TestMetadata("kt64066disabled.kt") + public void testKt64066disabled() throws Exception { + runTest("compiler/testData/diagnostics/tests/builderInference/issues/kt64066disabled.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/tests/builderInference/oneParameter") @TestDataPath("$PROJECT_ROOT") 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 25c32fc370564..029ae993db73f 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 @@ -3322,6 +3322,34 @@ public void testAllFilesPresentInBuilderInference() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/builderInference"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform"); } + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/builderInference/issues") + @TestDataPath("$PROJECT_ROOT") + public class Issues { + @Test + public void testAllFilesPresentInIssues() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/builderInference/issues"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform"); + } + + @Test + @TestMetadata("kt53478.kt") + public void testKt53478() throws Exception { + runTest("compiler/testData/diagnostics/tests/builderInference/issues/kt53478.kt"); + } + + @Test + @TestMetadata("kt64066.kt") + public void testKt64066() throws Exception { + runTest("compiler/testData/diagnostics/tests/builderInference/issues/kt64066.kt"); + } + + @Test + @TestMetadata("kt64066disabled.kt") + public void testKt64066disabled() throws Exception { + runTest("compiler/testData/diagnostics/tests/builderInference/issues/kt64066disabled.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/tests/builderInference/oneParameter") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java index e3bf8ff193f21..35b7f25b641d7 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java @@ -2719,6 +2719,28 @@ public void testAllFilesPresentInBuilderInference() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Nested + @TestMetadata("compiler/testData/codegen/box/builderInference/issues") + @TestDataPath("$PROJECT_ROOT") + public class Issues { + @Test + public void testAllFilesPresentInIssues() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference/issues"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("kt53478.kt") + public void testKt53478() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt53478.kt"); + } + + @Test + @TestMetadata("kt64066.kt") + public void testKt64066() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt64066.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/builderInference/oneParameter") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java index dc2097dfd2a9d..4e1ac98e68319 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java @@ -2719,6 +2719,28 @@ public void testAllFilesPresentInBuilderInference() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Nested + @TestMetadata("compiler/testData/codegen/box/builderInference/issues") + @TestDataPath("$PROJECT_ROOT") + public class Issues { + @Test + public void testAllFilesPresentInIssues() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference/issues"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("kt53478.kt") + public void testKt53478() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt53478.kt"); + } + + @Test + @TestMetadata("kt64066.kt") + public void testKt64066() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt64066.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/builderInference/oneParameter") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index a9032d29ea83a..4beb0bec5c611 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -952,6 +952,7 @@ enum BadNamedArgumentsTarget { DiagnosticFactory4 STUB_TYPE_IN_RECEIVER_CAUSES_AMBIGUITY = DiagnosticFactory4.create(ERROR); DiagnosticFactory2 BUILDER_INFERENCE_MULTI_LAMBDA_RESTRICTION = DiagnosticFactory2.create(ERROR); DiagnosticFactory2 BUILDER_INFERENCE_STUB_RECEIVER = DiagnosticFactory2.create(ERROR); + DiagnosticFactory1 BUILDER_INFERENCE_STUB_PARAMETER_TYPE = DiagnosticFactory1.create(ERROR); DiagnosticFactory4 UPPER_BOUND_VIOLATION_IN_CONSTRAINT = DiagnosticFactory4.create(ERROR); DiagnosticFactory1>> NONE_APPLICABLE = DiagnosticFactory1.create(ERROR); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index d91e5add7b642..cb94f75a90bfa 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -1105,6 +1105,7 @@ public static DiagnosticRenderer getRendererForDiagnostic(@NotNull UnboundDiagno MAP.put(STUB_TYPE_IN_RECEIVER_CAUSES_AMBIGUITY, "The type of a receiver hasn''t been inferred yet. To disambiguate this call, explicitly cast it to `{0}` if you want the builder''s type parameter(s) `{1}` to be inferred to `{2}`.", RENDER_TYPE, STRING, STRING, null); MAP.put(BUILDER_INFERENCE_MULTI_LAMBDA_RESTRICTION, "Unstable inference behaviour with multiple lambdas. Please either specify the type argument for generic parameter `{0}` of `{1}` explicitly", TO_STRING, TO_STRING); MAP.put(BUILDER_INFERENCE_STUB_RECEIVER, "The type of a receiver hasn''t been inferred yet. Please specify type argument for generic parameter `{0}` of `{1}` explicitly", TO_STRING, TO_STRING); + MAP.put(BUILDER_INFERENCE_STUB_PARAMETER_TYPE, "The type of parameter `{0}` cannot be inferred by builder inference", TO_STRING); MAP.put(UPPER_BOUND_VIOLATION_IN_CONSTRAINT, "Upper bound violation for generic parameter `{0}` of `{1}`: {3} is not a subtype of {2}", TO_STRING, TO_STRING, RENDER_TYPE, RENDER_TYPE); MAP.put(NONE_APPLICABLE, "None of the following functions can be called with the arguments supplied: {0}", AMBIGUOUS_CALLS); MAP.put(CANNOT_COMPLETE_RESOLVE, "Cannot choose among the following candidates without completing type inference: {0}", AMBIGUOUS_CALLS); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/PlatformConfiguratorBase.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/PlatformConfiguratorBase.kt index 2b30e69dc2cd2..3654fefa7fb49 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/PlatformConfiguratorBase.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/PlatformConfiguratorBase.kt @@ -62,6 +62,7 @@ private val DEFAULT_DECLARATION_CHECKERS = listOf( EnumEntriesRedeclarationChecker, VolatileAnnotationChecker, ActualTypealiasToSpecialAnnotationChecker, + StubForBuilderInferenceParameterTypeChecker, ) private val DEFAULT_CALL_CHECKERS = listOf( @@ -80,7 +81,7 @@ private val DEFAULT_CALL_CHECKERS = listOf( NewSchemeOfIntegerOperatorResolutionChecker, EnumEntryVsCompanionPriorityCallChecker, CompanionInParenthesesLHSCallChecker, ResolutionToPrivateConstructorOfSealedClassChecker, EqualityCallChecker, UnsupportedUntilOperatorChecker, BuilderInferenceAssignmentChecker, IncorrectCapturedApproximationCallChecker, CompanionIncorrectlyUnboundedWhenUsedAsLHSCallChecker, - CustomEnumEntriesMigrationCallChecker, EnumEntriesUnsupportedChecker + CustomEnumEntriesMigrationCallChecker, EnumEntriesUnsupportedChecker, ) private val DEFAULT_TYPE_CHECKERS = emptyList() private val DEFAULT_CLASSIFIER_USAGE_CHECKERS = listOf( diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/BuilderInferenceAssignmentChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/BuilderInferenceAssignmentChecker.kt index 49d8713e6de5e..1248ef9fe0b95 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/BuilderInferenceAssignmentChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/BuilderInferenceAssignmentChecker.kt @@ -11,8 +11,10 @@ import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.diagnostics.Errors import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.KtBinaryExpression +import org.jetbrains.kotlin.psi.KtLambdaExpression import org.jetbrains.kotlin.psi.KtNameReferenceExpression import org.jetbrains.kotlin.psi.psiUtil.getParentOfType +import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.calls.util.getType import org.jetbrains.kotlin.types.StubTypeForBuilderInference @@ -24,18 +26,27 @@ object BuilderInferenceAssignmentChecker : CallChecker { val resultingDescriptor = resolvedCall.resultingDescriptor if (resultingDescriptor !is PropertyDescriptor) return if (context.languageVersionSettings.supportsFeature(LanguageFeature.NoBuilderInferenceWithoutAnnotationRestriction)) return - if (resolvedCall.candidateDescriptor.returnType !is StubTypeForBuilderInference) return val callElement = resolvedCall.call.callElement if (callElement !is KtNameReferenceExpression) return val binaryExpression = callElement.getParentOfType(strict = true) ?: return if (binaryExpression.operationToken != KtTokens.EQ) return if (!BasicExpressionTypingVisitor.isLValue(callElement, binaryExpression)) return - - val leftType = resultingDescriptor.returnType?.takeIf { !it.isError } ?: return val right = binaryExpression.right ?: return - val rightType = right.getType(context.trace.bindingContext) ?: return - if (isAssignmentCorrectWithDataFlowInfo(leftType, right, rightType, context)) return - context.trace.report(Errors.TYPE_MISMATCH.on(right, leftType, rightType)) + if (resolvedCall.candidateDescriptor.returnType is StubTypeForBuilderInference) { + val leftType = resultingDescriptor.returnType?.takeIf { !it.isError } ?: return + val rightType = right.getType(context.trace.bindingContext) ?: return + + if (isAssignmentCorrectWithDataFlowInfo(leftType, right, rightType, context)) return + context.trace.report(Errors.TYPE_MISMATCH.on(right, leftType, rightType)) + } else if (right is KtLambdaExpression) { + val functionLiteral = right.functionLiteral + val functionDescriptor = context.trace.get(BindingContext.FUNCTION, right.functionLiteral) ?: return + for ((index, valueParameterDescriptor) in functionDescriptor.valueParameters.withIndex()) { + if (valueParameterDescriptor.type !is StubTypeForBuilderInference) continue + val target = functionLiteral.valueParameters.getOrNull(index) ?: functionLiteral + context.trace.report(Errors.BUILDER_INFERENCE_STUB_PARAMETER_TYPE.on(target, valueParameterDescriptor.name)) + } + } } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/StubForBuilderInferenceParameterTypeChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/StubForBuilderInferenceParameterTypeChecker.kt new file mode 100644 index 0000000000000..e7335c0272eed --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/StubForBuilderInferenceParameterTypeChecker.kt @@ -0,0 +1,26 @@ +/* + * Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.resolve.checkers + +import org.jetbrains.kotlin.config.LanguageFeature +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.descriptors.ValueDescriptor +import org.jetbrains.kotlin.diagnostics.Errors +import org.jetbrains.kotlin.psi.KtDeclaration +import org.jetbrains.kotlin.psi.KtParameter +import org.jetbrains.kotlin.types.StubTypeForBuilderInference + +object StubForBuilderInferenceParameterTypeChecker : DeclarationChecker { + override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) { + if (declaration !is KtParameter || + descriptor !is ValueDescriptor || + descriptor.returnType !is StubTypeForBuilderInference + ) return + if (context.languageVersionSettings.supportsFeature(LanguageFeature.NoBuilderInferenceWithoutAnnotationRestriction)) return + + context.trace.report(Errors.BUILDER_INFERENCE_STUB_PARAMETER_TYPE.on(declaration, declaration.nameAsSafeName)) + } +} diff --git a/compiler/testData/codegen/box/builderInference/issues/kt53478.kt b/compiler/testData/codegen/box/builderInference/issues/kt53478.kt new file mode 100644 index 0000000000000..5ad3deb2b6717 --- /dev/null +++ b/compiler/testData/codegen/box/builderInference/issues/kt53478.kt @@ -0,0 +1,19 @@ +// ISSUE: KT-53478 +// IGNORE_BACKEND_K1: ANY +// Reason: red code + +class UncompilingClass( + val block: (UncompilingClass.() -> Unit)? = null, +) { + + var uncompilingFun: ((T) -> Unit)? = null +} + +fun handleInt(arg: Int) = Unit + +fun box(): String { + val obj = UncompilingClass { + uncompilingFun = { handleInt(it) } + } + return "OK" +} diff --git a/compiler/testData/codegen/box/builderInference/issues/kt64066.kt b/compiler/testData/codegen/box/builderInference/issues/kt64066.kt new file mode 100644 index 0000000000000..c81d3ee5ef869 --- /dev/null +++ b/compiler/testData/codegen/box/builderInference/issues/kt64066.kt @@ -0,0 +1,13 @@ +// WITH_STDLIB +// ISSUE: KT-64066 +// IGNORE_BACKEND_K1: ANY +// Reason: red code + +fun box(): String { + val map = buildMap { + put(1, 1) + for (v in values) {} + } + if (map[1] != 1) return "FAIL" + return "OK" +} diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt53478.fir.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt53478.fir.kt new file mode 100644 index 0000000000000..04229cd743cf7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt53478.fir.kt @@ -0,0 +1,16 @@ +// ISSUE: KT-53478 + +class UncompilingClass( + val block: (UncompilingClass.() -> Unit)? = null, +) { + + var uncompilingFun: ((T) -> Unit)? = null +} + +fun handleInt(arg: Int) = Unit + +fun box() { + val obj = UncompilingClass { + uncompilingFun = { handleInt(it) } + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt53478.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt53478.kt new file mode 100644 index 0000000000000..952b0f46edcd4 --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt53478.kt @@ -0,0 +1,16 @@ +// ISSUE: KT-53478 + +class UncompilingClass( + val block: (UncompilingClass.() -> Unit)? = null, +) { + + var uncompilingFun: ((T) -> Unit)? = null +} + +fun handleInt(arg: Int) = Unit + +fun box() { + val obj = UncompilingClass { + uncompilingFun = { handleInt(it) } + } +} diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt64066.fir.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt64066.fir.kt new file mode 100644 index 0000000000000..fd03956459767 --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt64066.fir.kt @@ -0,0 +1,9 @@ +// WITH_STDLIB +// ISSUE: KT-64066 + +fun box() { + val map = buildMap { + put(1, 1) + for (v in values) {} + } +} diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt64066.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt64066.kt new file mode 100644 index 0000000000000..1c44861c87c2e --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt64066.kt @@ -0,0 +1,9 @@ +// WITH_STDLIB +// ISSUE: KT-64066 + +fun box() { + val map = buildMap { + put(1, 1) + for (v in values) {} + } +} diff --git a/compiler/testData/diagnostics/tests/builderInference/issues/kt64066disabled.kt b/compiler/testData/diagnostics/tests/builderInference/issues/kt64066disabled.kt new file mode 100644 index 0000000000000..61645dcea099d --- /dev/null +++ b/compiler/testData/diagnostics/tests/builderInference/issues/kt64066disabled.kt @@ -0,0 +1,26 @@ +// FIR_IDENTICAL +// WITH_STDLIB +// ISSUE: KT-64066, KT-53478 +// LANGUAGE: +NoBuilderInferenceWithoutAnnotationRestriction + +fun box1() { + val map = buildMap { + put(1, 1) + for (v in values) {} + } +} + +class UncompilingClass( + val block: (UncompilingClass.() -> Unit)? = null, +) { + + var uncompilingFun: ((T) -> Unit)? = null +} + +fun handleInt(arg: Int) = Unit + +fun box2() { + val obj = UncompilingClass { + uncompilingFun = { handleInt(it) } + } +} 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 28af7f79295a7..b17b8305ad5b5 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 @@ -3322,6 +3322,34 @@ public void testAllFilesPresentInBuilderInference() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/builderInference"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); } + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/builderInference/issues") + @TestDataPath("$PROJECT_ROOT") + public class Issues { + @Test + public void testAllFilesPresentInIssues() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/builderInference/issues"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); + } + + @Test + @TestMetadata("kt53478.kt") + public void testKt53478() throws Exception { + runTest("compiler/testData/diagnostics/tests/builderInference/issues/kt53478.kt"); + } + + @Test + @TestMetadata("kt64066.kt") + public void testKt64066() throws Exception { + runTest("compiler/testData/diagnostics/tests/builderInference/issues/kt64066.kt"); + } + + @Test + @TestMetadata("kt64066disabled.kt") + public void testKt64066disabled() throws Exception { + runTest("compiler/testData/diagnostics/tests/builderInference/issues/kt64066disabled.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/tests/builderInference/oneParameter") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 6b7423f4cb1c2..2c1953f73a2a8 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -2545,6 +2545,28 @@ public void testAllFilesPresentInBuilderInference() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + @Nested + @TestMetadata("compiler/testData/codegen/box/builderInference/issues") + @TestDataPath("$PROJECT_ROOT") + public class Issues { + @Test + public void testAllFilesPresentInIssues() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference/issues"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @Test + @TestMetadata("kt53478.kt") + public void testKt53478() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt53478.kt"); + } + + @Test + @TestMetadata("kt64066.kt") + public void testKt64066() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt64066.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/builderInference/oneParameter") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index b0f05963d9931..da6bbdce34ed2 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -2719,6 +2719,28 @@ public void testAllFilesPresentInBuilderInference() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Nested + @TestMetadata("compiler/testData/codegen/box/builderInference/issues") + @TestDataPath("$PROJECT_ROOT") + public class Issues { + @Test + public void testAllFilesPresentInIssues() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference/issues"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("kt53478.kt") + public void testKt53478() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt53478.kt"); + } + + @Test + @TestMetadata("kt64066.kt") + public void testKt64066() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt64066.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/builderInference/oneParameter") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java index 63aa83e55a4aa..9b3b5091ba3b4 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java @@ -2719,6 +2719,28 @@ public void testAllFilesPresentInBuilderInference() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Nested + @TestMetadata("compiler/testData/codegen/box/builderInference/issues") + @TestDataPath("$PROJECT_ROOT") + public class Issues { + @Test + public void testAllFilesPresentInIssues() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference/issues"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("kt53478.kt") + public void testKt53478() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt53478.kt"); + } + + @Test + @TestMetadata("kt64066.kt") + public void testKt64066() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt64066.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/builderInference/oneParameter") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 18a293d82195e..93809c901697c 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -2373,6 +2373,29 @@ public void testAllFilesPresentInBuilderInference() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @TestMetadata("compiler/testData/codegen/box/builderInference/issues") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Issues extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInIssues() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference/issues"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @TestMetadata("kt53478.kt") + public void testKt53478() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt53478.kt"); + } + + @TestMetadata("kt64066.kt") + public void testKt64066() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt64066.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/builderInference/oneParameter") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java index bad1666c5bb43..6f4fd4e40434b 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java @@ -1831,6 +1831,28 @@ public void testAllFilesPresentInBuilderInference() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); } + @Nested + @TestMetadata("compiler/testData/codegen/box/builderInference/issues") + @TestDataPath("$PROJECT_ROOT") + public class Issues { + @Test + public void testAllFilesPresentInIssues() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference/issues"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + + @Test + @TestMetadata("kt53478.kt") + public void testKt53478() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt53478.kt"); + } + + @Test + @TestMetadata("kt64066.kt") + public void testKt64066() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt64066.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/builderInference/oneParameter") @TestDataPath("$PROJECT_ROOT") diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenBoxTestGenerated.java index d0e3cd9ef5602..7498e599c237c 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenBoxTestGenerated.java @@ -1831,6 +1831,28 @@ public void testAllFilesPresentInBuilderInference() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); } + @Nested + @TestMetadata("compiler/testData/codegen/box/builderInference/issues") + @TestDataPath("$PROJECT_ROOT") + public class Issues { + @Test + public void testAllFilesPresentInIssues() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference/issues"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + + @Test + @TestMetadata("kt53478.kt") + public void testKt53478() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt53478.kt"); + } + + @Test + @TestMetadata("kt64066.kt") + public void testKt64066() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt64066.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/builderInference/oneParameter") @TestDataPath("$PROJECT_ROOT") diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java index fa8b80a10a3f0..8a06eca48b6d9 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java @@ -1831,6 +1831,28 @@ public void testAllFilesPresentInBuilderInference() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); } + @Nested + @TestMetadata("compiler/testData/codegen/box/builderInference/issues") + @TestDataPath("$PROJECT_ROOT") + public class Issues { + @Test + public void testAllFilesPresentInIssues() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference/issues"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + + @Test + @TestMetadata("kt53478.kt") + public void testKt53478() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt53478.kt"); + } + + @Test + @TestMetadata("kt64066.kt") + public void testKt64066() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt64066.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/builderInference/oneParameter") @TestDataPath("$PROJECT_ROOT") diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java index 14d64f344c944..811c408b3b6b7 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java @@ -1831,6 +1831,28 @@ public void testAllFilesPresentInBuilderInference() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); } + @Nested + @TestMetadata("compiler/testData/codegen/box/builderInference/issues") + @TestDataPath("$PROJECT_ROOT") + public class Issues { + @Test + public void testAllFilesPresentInIssues() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference/issues"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + + @Test + @TestMetadata("kt53478.kt") + public void testKt53478() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt53478.kt"); + } + + @Test + @TestMetadata("kt64066.kt") + public void testKt64066() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt64066.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/builderInference/oneParameter") @TestDataPath("$PROJECT_ROOT") diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestGenerated.java index b259248496248..5b34b3b9cce96 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestGenerated.java @@ -1890,6 +1890,31 @@ public void testAllFilesPresentInBuilderInference() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); } + @Nested + @TestMetadata("compiler/testData/codegen/box/builderInference/issues") + @TestDataPath("$PROJECT_ROOT") + @Tag("frontend-fir") + @FirPipeline() + @UseExtTestCaseGroupProvider() + public class Issues { + @Test + public void testAllFilesPresentInIssues() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference/issues"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("kt53478.kt") + public void testKt53478() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt53478.kt"); + } + + @Test + @TestMetadata("kt64066.kt") + public void testKt64066() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt64066.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/builderInference/oneParameter") @TestDataPath("$PROJECT_ROOT") diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestNoPLGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestNoPLGenerated.java index caec403bfb406..0958cc413bb61 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestNoPLGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestNoPLGenerated.java @@ -1936,6 +1936,33 @@ public void testAllFilesPresentInBuilderInference() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); } + @Nested + @TestMetadata("compiler/testData/codegen/box/builderInference/issues") + @TestDataPath("$PROJECT_ROOT") + @Tag("frontend-fir") + @FirPipeline() + @UseExtTestCaseGroupProvider() + @UsePartialLinkage(mode = Mode.DISABLED) + @Tag("no-partial-linkage-may-be-skipped") + public class Issues { + @Test + public void testAllFilesPresentInIssues() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference/issues"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("kt53478.kt") + public void testKt53478() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt53478.kt"); + } + + @Test + @TestMetadata("kt64066.kt") + public void testKt64066() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt64066.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/builderInference/oneParameter") @TestDataPath("$PROJECT_ROOT") diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java index 8ee3b75c9e5df..21baa2ab13f3e 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java @@ -1868,6 +1868,30 @@ public void testAllFilesPresentInBuilderInference() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); } + @Nested + @TestMetadata("compiler/testData/codegen/box/builderInference/issues") + @TestDataPath("$PROJECT_ROOT") + @UseExtTestCaseGroupProvider() + @DisabledTestsIfProperty(sourceLocations = { "compiler/testData/codegen/box/coroutines/featureIntersection/defaultExpect.kt", "compiler/testData/codegen/box/multiplatform/defaultArguments/*.kt", "compiler/testData/codegen/box/multiplatform/migratedOldTests/*.kt", "compiler/testData/codegen/boxInline/multiplatform/defaultArguments/receiversAndParametersInLambda.kt" }, property = ClassLevelProperty.TEST_MODE, propertyValue = "ONE_STAGE_MULTI_MODULE") + public class Issues { + @Test + public void testAllFilesPresentInIssues() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference/issues"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("kt53478.kt") + public void testKt53478() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt53478.kt"); + } + + @Test + @TestMetadata("kt64066.kt") + public void testKt64066() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt64066.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/builderInference/oneParameter") @TestDataPath("$PROJECT_ROOT") diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestNoPLGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestNoPLGenerated.java index 8af25312706b2..eaf75ae712097 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestNoPLGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestNoPLGenerated.java @@ -1891,6 +1891,31 @@ public void testAllFilesPresentInBuilderInference() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); } + @Nested + @TestMetadata("compiler/testData/codegen/box/builderInference/issues") + @TestDataPath("$PROJECT_ROOT") + @UseExtTestCaseGroupProvider() + @UsePartialLinkage(mode = Mode.DISABLED) + @Tag("no-partial-linkage-may-be-skipped") + public class Issues { + @Test + public void testAllFilesPresentInIssues() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference/issues"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("kt53478.kt") + public void testKt53478() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt53478.kt"); + } + + @Test + @TestMetadata("kt64066.kt") + public void testKt64066() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt64066.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/builderInference/oneParameter") @TestDataPath("$PROJECT_ROOT") diff --git a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmCodegenBoxTestGenerated.java b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmCodegenBoxTestGenerated.java index d0b5c962ff003..11adf31b46df4 100644 --- a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmCodegenBoxTestGenerated.java +++ b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmCodegenBoxTestGenerated.java @@ -1819,6 +1819,28 @@ public void testAllFilesPresentInBuilderInference() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); } + @Nested + @TestMetadata("compiler/testData/codegen/box/builderInference/issues") + @TestDataPath("$PROJECT_ROOT") + public class Issues { + @Test + public void testAllFilesPresentInIssues() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference/issues"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + + @Test + @TestMetadata("kt53478.kt") + public void testKt53478() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt53478.kt"); + } + + @Test + @TestMetadata("kt64066.kt") + public void testKt64066() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt64066.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/builderInference/oneParameter") @TestDataPath("$PROJECT_ROOT") diff --git a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/K1WasmCodegenBoxTestGenerated.java b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/K1WasmCodegenBoxTestGenerated.java index 9c88795516284..1e63515664035 100644 --- a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/K1WasmCodegenBoxTestGenerated.java +++ b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/K1WasmCodegenBoxTestGenerated.java @@ -1819,6 +1819,28 @@ public void testAllFilesPresentInBuilderInference() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); } + @Nested + @TestMetadata("compiler/testData/codegen/box/builderInference/issues") + @TestDataPath("$PROJECT_ROOT") + public class Issues { + @Test + public void testAllFilesPresentInIssues() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builderInference/issues"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + + @Test + @TestMetadata("kt53478.kt") + public void testKt53478() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt53478.kt"); + } + + @Test + @TestMetadata("kt64066.kt") + public void testKt64066() throws Exception { + runTest("compiler/testData/codegen/box/builderInference/issues/kt64066.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/builderInference/oneParameter") @TestDataPath("$PROJECT_ROOT")