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 415240ec363..c32de2f7ddf 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 @@ -12518,6 +12518,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/exceptions"), Pattern.compile("^(.+)\\.(kt|kts)$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); } + @Test + @TestMetadata("annotationWithWrongArgInDanglingModifierList.kt") + public void testAnnotationWithWrongArgInDanglingModifierList() throws Exception { + runTest("compiler/testData/diagnostics/tests/exceptions/annotationWithWrongArgInDanglingModifierList.kt"); + } + @Test @TestMetadata("expectedSomeTypesOnBranchForWhenExpressionOfErroneousType.kt") public void testExpectedSomeTypesOnBranchForWhenExpressionOfErroneousType() throws Exception { 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 9df531b9f0e..acfc5efe2a6 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 @@ -12518,6 +12518,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/exceptions"), Pattern.compile("^(.+)\\.(kt|kts)$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); } + @Test + @TestMetadata("annotationWithWrongArgInDanglingModifierList.kt") + public void testAnnotationWithWrongArgInDanglingModifierList() throws Exception { + runTest("compiler/testData/diagnostics/tests/exceptions/annotationWithWrongArgInDanglingModifierList.kt"); + } + @Test @TestMetadata("expectedSomeTypesOnBranchForWhenExpressionOfErroneousType.kt") public void testExpectedSomeTypesOnBranchForWhenExpressionOfErroneousType() 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 1940ec1cb2f..c6841b7bcd8 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 @@ -12512,6 +12512,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/exceptions"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform"); } + @Test + @TestMetadata("annotationWithWrongArgInDanglingModifierList.kt") + public void testAnnotationWithWrongArgInDanglingModifierList() throws Exception { + runTest("compiler/testData/diagnostics/tests/exceptions/annotationWithWrongArgInDanglingModifierList.kt"); + } + @Test @TestMetadata("expectedSomeTypesOnBranchForWhenExpressionOfErroneousType.kt") public void testExpectedSomeTypesOnBranchForWhenExpressionOfErroneousType() 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 66c594f8993..ce549907dfc 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 @@ -12518,6 +12518,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/exceptions"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform"); } + @Test + @TestMetadata("annotationWithWrongArgInDanglingModifierList.kt") + public void testAnnotationWithWrongArgInDanglingModifierList() throws Exception { + runTest("compiler/testData/diagnostics/tests/exceptions/annotationWithWrongArgInDanglingModifierList.kt"); + } + @Test @TestMetadata("expectedSomeTypesOnBranchForWhenExpressionOfErroneousType.kt") public void testExpectedSomeTypesOnBranchForWhenExpressionOfErroneousType() throws Exception { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirImplicitBodyResolve.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirImplicitBodyResolve.kt index 34bdac92691..2cfdc9c16c2 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirImplicitBodyResolve.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirImplicitBodyResolve.kt @@ -138,6 +138,17 @@ open class FirImplicitAwareBodyResolveTransformer( super.transformDeclarationContent(declaration, data) } + override fun transformDanglingModifierList( + danglingModifierList: FirDanglingModifierList, + data: ResolutionMode + ): FirDanglingModifierList { + return if (implicitTypeOnly) { + danglingModifierList + } else { + transformElement(danglingModifierList, data) + } + } + override fun transformSimpleFunction( simpleFunction: FirSimpleFunction, data: ResolutionMode diff --git a/compiler/testData/diagnostics/tests/exceptions/annotationWithWrongArgInDanglingModifierList.fir.kt b/compiler/testData/diagnostics/tests/exceptions/annotationWithWrongArgInDanglingModifierList.fir.kt new file mode 100644 index 00000000000..c6cbcb764a7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/exceptions/annotationWithWrongArgInDanglingModifierList.fir.kt @@ -0,0 +1,11 @@ +// ISSUE: KT-63508 + +annotation class Ann(val x: String) + +fun foo() { + class Local { + @Ann(fun f(): String { return 42 }) + } +} + +@Ann(fun g(): String { return 42 }) diff --git a/compiler/testData/diagnostics/tests/exceptions/annotationWithWrongArgInDanglingModifierList.kt b/compiler/testData/diagnostics/tests/exceptions/annotationWithWrongArgInDanglingModifierList.kt new file mode 100644 index 00000000000..a64b696d7b3 --- /dev/null +++ b/compiler/testData/diagnostics/tests/exceptions/annotationWithWrongArgInDanglingModifierList.kt @@ -0,0 +1,11 @@ +// ISSUE: KT-63508 + +annotation class Ann(val x: String) + +fun foo() { + class Local { + @Ann(fun f(): String { return 42 }) + } +} + +@Ann(fun g(): String { return 42 }) 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 0cbd3ba5891..74754150b88 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 @@ -12518,6 +12518,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/exceptions"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); } + @Test + @TestMetadata("annotationWithWrongArgInDanglingModifierList.kt") + public void testAnnotationWithWrongArgInDanglingModifierList() throws Exception { + runTest("compiler/testData/diagnostics/tests/exceptions/annotationWithWrongArgInDanglingModifierList.kt"); + } + @Test @TestMetadata("expectedSomeTypesOnBranchForWhenExpressionOfErroneousType.kt") public void testExpectedSomeTypesOnBranchForWhenExpressionOfErroneousType() throws Exception {