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 386e9007bc8..7817540ce21 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 @@ -25784,6 +25784,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag runTest("compiler/testData/diagnostics/tests/resolve/underscoreInCatchBlockWithEnabledFeature.kt"); } + @Test + @TestMetadata("varInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda.kt") + public void testVarInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda() throws Exception { + runTest("compiler/testData/diagnostics/tests/resolve/varInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda.kt"); + } + @Test @TestMetadata("wrongNumberOfTypeArguments.kt") public void testWrongNumberOfTypeArguments() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index 7456fd5a5c0..d9ef2099ff9 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -25784,6 +25784,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/resolve/underscoreInCatchBlockWithEnabledFeature.kt"); } + @Test + @TestMetadata("varInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda.kt") + public void testVarInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda() throws Exception { + runTest("compiler/testData/diagnostics/tests/resolve/varInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda.kt"); + } + @Test @TestMetadata("wrongNumberOfTypeArguments.kt") public void testWrongNumberOfTypeArguments() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java index bd0c5d2f130..25399c662e6 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java @@ -25784,6 +25784,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac runTest("compiler/testData/diagnostics/tests/resolve/underscoreInCatchBlockWithEnabledFeature.kt"); } + @Test + @TestMetadata("varInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda.kt") + public void testVarInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda() throws Exception { + runTest("compiler/testData/diagnostics/tests/resolve/varInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda.kt"); + } + @Test @TestMetadata("wrongNumberOfTypeArguments.kt") public void testWrongNumberOfTypeArguments() throws Exception { diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrorsDefaultMessages.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrorsDefaultMessages.kt index 62762991be9..98ec358ef34 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrorsDefaultMessages.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrorsDefaultMessages.kt @@ -650,7 +650,10 @@ object FirErrorsDefaultMessages : BaseDiagnosticRendererFactory() { map.put(SUPER_IS_NOT_AN_EXPRESSION, "Super cannot be a callee") map.put(SUPER_NOT_AVAILABLE, "No supertypes are accessible in this context") map.put(ABSTRACT_SUPER_CALL, "Abstract member cannot be accessed directly") - map.put(ABSTRACT_SUPER_CALL_WARNING, "Abstract fake override member access is deprecated. See https://youtrack.jetbrains.com/issue/KT-49017") + map.put( + ABSTRACT_SUPER_CALL_WARNING, + "Abstract fake override member access is deprecated. See https://youtrack.jetbrains.com/issue/KT-49017" + ) map.put( INSTANCE_ACCESS_BEFORE_SUPER_CALL, "Cannot access ''{0}'' before superclass constructor has been called", diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index e6756ce444e..4dab6b62d97 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -131,6 +131,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/annotations/constValInAnnotation.kt"); } + @Test + @TestMetadata("correctTypeForClassReferenceExpressionInAnnotation.kt") + public void testCorrectTypeForClassReferenceExpressionInAnnotation() throws Exception { + runTest("compiler/testData/codegen/box/annotations/correctTypeForClassReferenceExpressionInAnnotation.kt"); + } + @Test @TestMetadata("defaultParameterValues.kt") public void testDefaultParameterValues() throws Exception { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt index 7d35195a990..cdca2e6f40a 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt @@ -354,7 +354,9 @@ private inline fun BodyResolveComponents.transformExpression val originalType = expression.resultType.coneType val allTypes = typesFromSmartCast.also { - it += originalType + if (originalType !is ConeStubType) { + it += originalType + } } val intersectedType = ConeTypeIntersector.intersectTypes(session.typeContext, allTypes) if (intersectedType == originalType) return null diff --git a/compiler/testData/codegen/box/annotations/correctTypeForClassReferenceExpressionInAnnotation.kt b/compiler/testData/codegen/box/annotations/correctTypeForClassReferenceExpressionInAnnotation.kt new file mode 100644 index 00000000000..b0da60a2db9 --- /dev/null +++ b/compiler/testData/codegen/box/annotations/correctTypeForClassReferenceExpressionInAnnotation.kt @@ -0,0 +1,13 @@ +// TARGET_BACKEND: JVM +// WITH_STDLIB +// ISSUE: KT-52190 + +fun box(): String { + buildMap { + val replaced = put("key", "value") + if (replaced != null) { + return "Error: $replaced" + } + } + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/builderInference/stubTypes/memberScope.fir.kt b/compiler/testData/diagnostics/tests/inference/builderInference/stubTypes/memberScope.fir.kt index 8f2b1277df9..7e781212d4c 100644 --- a/compiler/testData/diagnostics/tests/inference/builderInference/stubTypes/memberScope.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/builderInference/stubTypes/memberScope.fir.kt @@ -57,13 +57,13 @@ fun test() { if (get() === null) {} if (x != null) { - x?.hashCode() - x?.equals(1) + x?.hashCode() + x?.equals(1) x.equals("") x.hashCode() x.toString() x.test() - x?.test2() + x?.test2() x.test2() } @@ -94,7 +94,7 @@ fun test() { emit(null) val x = get() if (x == null) { - x.toString("") + x.toString("") } "" @@ -104,7 +104,7 @@ fun test() { emit(null) val x = get() if (x == null) { - x.test() + x.test() } "" @@ -134,7 +134,7 @@ fun test() { emit(null) val x = get() if (x === null) { - x.toString("") + x.toString("") } "" @@ -144,7 +144,7 @@ fun test() { emit(null) val x = get() if (x === null) { - x.test() + x.test() } "" @@ -239,7 +239,7 @@ fun test() { emit(null) val x = get() if (x == null) { - x.test() + x.test() } "" } @@ -276,7 +276,7 @@ fun test() { emit(null) val x = get() if (x === null) { - x.test() + x.test() } "" } diff --git a/compiler/testData/diagnostics/tests/resolve/varInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda.fir.kt b/compiler/testData/diagnostics/tests/resolve/varInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda.fir.kt new file mode 100644 index 00000000000..61acbba6fd9 --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/varInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda.fir.kt @@ -0,0 +1,17 @@ +// WITH_STDLIB +// ISSUE: KT-52197 + +fun helper(builderAction: MutableMap.() -> Unit) { + builderAction(mutableMapOf()) +} + +fun test(){ + helper { + val x = put("key", "value") + if (x != null) { + "Error: $x" + x.length + } + x.length + } +} diff --git a/compiler/testData/diagnostics/tests/resolve/varInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda.kt b/compiler/testData/diagnostics/tests/resolve/varInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda.kt new file mode 100644 index 00000000000..87d90c814d9 --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/varInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda.kt @@ -0,0 +1,17 @@ +// WITH_STDLIB +// ISSUE: KT-52197 + +fun helper(builderAction: MutableMap.() -> Unit) { + builderAction(mutableMapOf()) +} + +fun test(){ + helper { + val x = put("key", "value") + if (x != null) { + "Error: $x" + x.length + } + x.length + } +} diff --git a/compiler/testData/diagnostics/tests/resolve/varInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda.txt b/compiler/testData/diagnostics/tests/resolve/varInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda.txt new file mode 100644 index 00000000000..d1f87d6d1e3 --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/varInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda.txt @@ -0,0 +1,4 @@ +package + +public fun helper(/*0*/ builderAction: kotlin.collections.MutableMap.() -> kotlin.Unit): kotlin.Unit +public fun test(): kotlin.Unit 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 bc7ffcb2741..d3a416cd8f6 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 @@ -25796,6 +25796,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/resolve/underscoreInCatchBlockWithEnabledFeature.kt"); } + @Test + @TestMetadata("varInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda.kt") + public void testVarInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda() throws Exception { + runTest("compiler/testData/diagnostics/tests/resolve/varInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda.kt"); + } + @Test @TestMetadata("wrongNumberOfTypeArguments.kt") public void testWrongNumberOfTypeArguments() throws Exception { 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 a1bb748986f..c9d38d1d068 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 @@ -119,6 +119,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/annotations/constValInAnnotation.kt"); } + @Test + @TestMetadata("correctTypeForClassReferenceExpressionInAnnotation.kt") + public void testCorrectTypeForClassReferenceExpressionInAnnotation() throws Exception { + runTest("compiler/testData/codegen/box/annotations/correctTypeForClassReferenceExpressionInAnnotation.kt"); + } + @Test @TestMetadata("defaultParameterValues.kt") public void testDefaultParameterValues() throws Exception { 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 e0abb36f2b8..86c63c1131c 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 @@ -131,6 +131,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/annotations/constValInAnnotation.kt"); } + @Test + @TestMetadata("correctTypeForClassReferenceExpressionInAnnotation.kt") + public void testCorrectTypeForClassReferenceExpressionInAnnotation() throws Exception { + runTest("compiler/testData/codegen/box/annotations/correctTypeForClassReferenceExpressionInAnnotation.kt"); + } + @Test @TestMetadata("defaultParameterValues.kt") public void testDefaultParameterValues() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 6e539d49cfc..020aaca6afd 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -113,6 +113,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/annotations/constValInAnnotation.kt"); } + @TestMetadata("correctTypeForClassReferenceExpressionInAnnotation.kt") + public void testCorrectTypeForClassReferenceExpressionInAnnotation() throws Exception { + runTest("compiler/testData/codegen/box/annotations/correctTypeForClassReferenceExpressionInAnnotation.kt"); + } + @TestMetadata("defaultParameterValues.kt") public void testDefaultParameterValues() throws Exception { runTest("compiler/testData/codegen/box/annotations/defaultParameterValues.kt");