From aaaf35fcb8cef6c5500be3636f79bef56c80fea2 Mon Sep 17 00:00:00 2001 From: Dmitrii Gridin Date: Mon, 27 Nov 2023 14:52:04 +0100 Subject: [PATCH] [FIR] add missed tests for declaration annotations ^KT-63832 --- ...cCompilerTestFE10TestdataTestGenerated.java | 18 ++++++++++++++++++ ...osticCompilerFE10TestDataTestGenerated.java | 18 ++++++++++++++++++ ...reeOldFrontendDiagnosticsTestGenerated.java | 18 ++++++++++++++++++ ...PsiOldFrontendDiagnosticsTestGenerated.java | 18 ++++++++++++++++++ .../annotations/danglingAnnotation.fir.kt | 9 +++++++++ .../tests/annotations/danglingAnnotation.kt | 9 +++++++++ .../initializerWithNestedAnnotation.fir.kt | 11 +++++++++++ .../initializerWithNestedAnnotation.kt | 11 +++++++++++ .../nestedAliasWithNestedAnnotation.fir.kt | 11 +++++++++++ .../nestedAliasWithNestedAnnotation.kt | 11 +++++++++++ .../typeParameterAnnotations.fir.kt | 2 +- .../annotations/typeParameterAnnotations.kt | 2 +- .../test/runners/DiagnosticTestGenerated.java | 18 ++++++++++++++++++ 13 files changed, 154 insertions(+), 2 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/annotations/danglingAnnotation.fir.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/danglingAnnotation.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/initializerWithNestedAnnotation.fir.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/initializerWithNestedAnnotation.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/nestedAliasWithNestedAnnotation.fir.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/nestedAliasWithNestedAnnotation.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 0e9bee11853..7184f80ce79 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 @@ -1872,6 +1872,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/tests/annotations/cycleInParameters_before.kt"); } + @Test + @TestMetadata("danglingAnnotation.kt") + public void testDanglingAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/tests/annotations/danglingAnnotation.kt"); + } + @Test @TestMetadata("DanglingInScript.kts") public void testDanglingInScript() throws Exception { @@ -1962,6 +1968,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/tests/annotations/InheritingAnnotationClass.kt"); } + @Test + @TestMetadata("initializerWithNestedAnnotation.kt") + public void testInitializerWithNestedAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/tests/annotations/initializerWithNestedAnnotation.kt"); + } + @Test @TestMetadata("invalidTypesInAnnotationConstructor.kt") public void testInvalidTypesInAnnotationConstructor() throws Exception { @@ -2034,6 +2046,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/tests/annotations/MutuallyRecursivelyAnnotatedGlobalFunction.kt"); } + @Test + @TestMetadata("nestedAliasWithNestedAnnotation.kt") + public void testNestedAliasWithNestedAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/tests/annotations/nestedAliasWithNestedAnnotation.kt"); + } + @Test @TestMetadata("nestedClassAsAnnotationParameter.kt") public void testNestedClassAsAnnotationParameter() 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 28c0cad718e..2eea0557616 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 @@ -1872,6 +1872,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/tests/annotations/cycleInParameters_before.kt"); } + @Test + @TestMetadata("danglingAnnotation.kt") + public void testDanglingAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/tests/annotations/danglingAnnotation.kt"); + } + @Test @TestMetadata("DanglingInScript.kts") public void testDanglingInScript() throws Exception { @@ -1962,6 +1968,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/tests/annotations/InheritingAnnotationClass.kt"); } + @Test + @TestMetadata("initializerWithNestedAnnotation.kt") + public void testInitializerWithNestedAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/tests/annotations/initializerWithNestedAnnotation.kt"); + } + @Test @TestMetadata("invalidTypesInAnnotationConstructor.kt") public void testInvalidTypesInAnnotationConstructor() throws Exception { @@ -2034,6 +2046,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/tests/annotations/MutuallyRecursivelyAnnotatedGlobalFunction.kt"); } + @Test + @TestMetadata("nestedAliasWithNestedAnnotation.kt") + public void testNestedAliasWithNestedAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/tests/annotations/nestedAliasWithNestedAnnotation.kt"); + } + @Test @TestMetadata("nestedClassAsAnnotationParameter.kt") public void testNestedClassAsAnnotationParameter() 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 995e81f92c5..88ebead6fb7 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 @@ -1872,6 +1872,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/annotations/cycleInParameters_before.kt"); } + @Test + @TestMetadata("danglingAnnotation.kt") + public void testDanglingAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/tests/annotations/danglingAnnotation.kt"); + } + @Test @TestMetadata("DanglingMixed.kt") public void testDanglingMixed() throws Exception { @@ -1956,6 +1962,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/annotations/InheritingAnnotationClass.kt"); } + @Test + @TestMetadata("initializerWithNestedAnnotation.kt") + public void testInitializerWithNestedAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/tests/annotations/initializerWithNestedAnnotation.kt"); + } + @Test @TestMetadata("invalidTypesInAnnotationConstructor.kt") public void testInvalidTypesInAnnotationConstructor() throws Exception { @@ -2028,6 +2040,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/annotations/MutuallyRecursivelyAnnotatedGlobalFunction.kt"); } + @Test + @TestMetadata("nestedAliasWithNestedAnnotation.kt") + public void testNestedAliasWithNestedAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/tests/annotations/nestedAliasWithNestedAnnotation.kt"); + } + @Test @TestMetadata("nestedClassAsAnnotationParameter.kt") public void testNestedClassAsAnnotationParameter() 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 1bb84d8a0f0..ac95c1de93e 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 @@ -1872,6 +1872,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/annotations/cycleInParameters_before.kt"); } + @Test + @TestMetadata("danglingAnnotation.kt") + public void testDanglingAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/tests/annotations/danglingAnnotation.kt"); + } + @Test @TestMetadata("DanglingInScript.kts") public void testDanglingInScript() throws Exception { @@ -1962,6 +1968,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/annotations/InheritingAnnotationClass.kt"); } + @Test + @TestMetadata("initializerWithNestedAnnotation.kt") + public void testInitializerWithNestedAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/tests/annotations/initializerWithNestedAnnotation.kt"); + } + @Test @TestMetadata("invalidTypesInAnnotationConstructor.kt") public void testInvalidTypesInAnnotationConstructor() throws Exception { @@ -2034,6 +2046,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/annotations/MutuallyRecursivelyAnnotatedGlobalFunction.kt"); } + @Test + @TestMetadata("nestedAliasWithNestedAnnotation.kt") + public void testNestedAliasWithNestedAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/tests/annotations/nestedAliasWithNestedAnnotation.kt"); + } + @Test @TestMetadata("nestedClassAsAnnotationParameter.kt") public void testNestedClassAsAnnotationParameter() throws Exception { diff --git a/compiler/testData/diagnostics/tests/annotations/danglingAnnotation.fir.kt b/compiler/testData/diagnostics/tests/annotations/danglingAnnotation.fir.kt new file mode 100644 index 00000000000..e9e3a1bb330 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/danglingAnnotation.fir.kt @@ -0,0 +1,9 @@ +annotation class Anno(val position: String) + +interface OriginalInterface { + companion object { + private const val prop = 0 + } + + @Anno("dangling $prop") +} diff --git a/compiler/testData/diagnostics/tests/annotations/danglingAnnotation.kt b/compiler/testData/diagnostics/tests/annotations/danglingAnnotation.kt new file mode 100644 index 00000000000..f146923dacc --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/danglingAnnotation.kt @@ -0,0 +1,9 @@ +annotation class Anno(val position: String) + +interface OriginalInterface { + companion object { + private const val prop = 0 + } + + @Anno("dangling $prop") +} diff --git a/compiler/testData/diagnostics/tests/annotations/initializerWithNestedAnnotation.fir.kt b/compiler/testData/diagnostics/tests/annotations/initializerWithNestedAnnotation.fir.kt new file mode 100644 index 00000000000..fd15fd9b311 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/initializerWithNestedAnnotation.fir.kt @@ -0,0 +1,11 @@ +annotation class Anno(val position: String) + +class MyClass { + @Anno("init $prop") init { + + } + + companion object { + private const val prop = 0 + } +} diff --git a/compiler/testData/diagnostics/tests/annotations/initializerWithNestedAnnotation.kt b/compiler/testData/diagnostics/tests/annotations/initializerWithNestedAnnotation.kt new file mode 100644 index 00000000000..00493f58911 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/initializerWithNestedAnnotation.kt @@ -0,0 +1,11 @@ +annotation class Anno(val position: String) + +class MyClass { + @Anno("init $prop") init { + + } + + companion object { + private const val prop = 0 + } +} diff --git a/compiler/testData/diagnostics/tests/annotations/nestedAliasWithNestedAnnotation.fir.kt b/compiler/testData/diagnostics/tests/annotations/nestedAliasWithNestedAnnotation.fir.kt new file mode 100644 index 00000000000..43f4d511b9f --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/nestedAliasWithNestedAnnotation.fir.kt @@ -0,0 +1,11 @@ +@Target(AnnotationTarget.TYPE, AnnotationTarget.TYPEALIAS, AnnotationTarget.TYPE_PARAMETER) +annotation class Anno(val position: String) + +interface OriginalInterface { + @Anno("alias $prop") + typealias NestedTypeAlias <@Anno("type param $prop") A : @Anno("bound $prop") Number> = @Anno("type $prop") OriginalInterface + + companion object { + private const val prop = 0 + } +} diff --git a/compiler/testData/diagnostics/tests/annotations/nestedAliasWithNestedAnnotation.kt b/compiler/testData/diagnostics/tests/annotations/nestedAliasWithNestedAnnotation.kt new file mode 100644 index 00000000000..b36aff99fc5 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/nestedAliasWithNestedAnnotation.kt @@ -0,0 +1,11 @@ +@Target(AnnotationTarget.TYPE, AnnotationTarget.TYPEALIAS, AnnotationTarget.TYPE_PARAMETER) +annotation class Anno(val position: String) + +interface OriginalInterface { + @Anno("alias $prop") + typealias NestedTypeAlias <@Anno("type param $prop") A : @Anno("bound $prop") Number> = @Anno("type $prop") OriginalInterface + + companion object { + private const val prop = 0 + } +} diff --git a/compiler/testData/diagnostics/tests/annotations/typeParameterAnnotations.fir.kt b/compiler/testData/diagnostics/tests/annotations/typeParameterAnnotations.fir.kt index 3d15e2e8bbf..be9b358b3e7 100644 --- a/compiler/testData/diagnostics/tests/annotations/typeParameterAnnotations.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/typeParameterAnnotations.fir.kt @@ -7,7 +7,7 @@ annotation class Anno(val position: String) interface OriginalInterface { @Anno("explicitType $prop") fun <@Anno("type param $prop") F : @Anno("bound $prop") List<@Anno("nested bound $prop") List<@Anno("nested nested bound $prop") String>>> @receiver:Anno("receiver annotation: $prop") @Anno("receiver type $prop") Collection<@Anno("nested receiver type $prop") List<@Anno("nested nested receiver type $prop")String>>.explicitType(@Anno("parameter annotation $prop") param: @Anno("parameter type $prop") ListIterator<@Anno("nested parameter type $prop") List<@Anno("nested nested parameter type $prop")String>>): @Anno("explicitType return type $prop") List<@Anno("explicitType nested return type $prop") List<@Anno("explicitType nested nested return type $prop") Int>> = emptyList() - val <@Anno("type param $prop") F : @Anno("bound $prop") Number> F.explicitType: @Anno("bound $prop") Int get() = 1 + val <@Anno("type param $prop") F : @Anno("bound $prop") Number> @receiver:Anno("receiver annotation: $prop") @Anno("receiver type $prop") F.explicitType: @Anno("bound $prop") Int get() = 1 companion object { private const val prop = 0 diff --git a/compiler/testData/diagnostics/tests/annotations/typeParameterAnnotations.kt b/compiler/testData/diagnostics/tests/annotations/typeParameterAnnotations.kt index 52000449a82..dd5aed7a643 100644 --- a/compiler/testData/diagnostics/tests/annotations/typeParameterAnnotations.kt +++ b/compiler/testData/diagnostics/tests/annotations/typeParameterAnnotations.kt @@ -7,7 +7,7 @@ annotation class Anno(val position: String) interface OriginalInterface { @Anno("explicitType $prop") fun <@Anno("type param $prop") F : @Anno("bound $prop") List<@Anno("nested bound $prop") List<@Anno("nested nested bound $prop") String>>> @receiver:Anno("receiver annotation: $prop") @Anno("receiver type $prop") Collection<@Anno("nested receiver type $prop") List<@Anno("nested nested receiver type $prop")String>>.explicitType(@Anno("parameter annotation $prop") param: @Anno("parameter type $prop") ListIterator<@Anno("nested parameter type $prop") List<@Anno("nested nested parameter type $prop")String>>): @Anno("explicitType return type $prop") List<@Anno("explicitType nested return type $prop") List<@Anno("explicitType nested nested return type $prop") Int>> = emptyList() - val <@Anno("type param $prop") F : @Anno("bound $prop") Number> F.explicitType: @Anno("bound $prop") Int get() = 1 + val <@Anno("type param $prop") F : @Anno("bound $prop") Number> @receiver:Anno("receiver annotation: $prop") @Anno("receiver type $prop") F.explicitType: @Anno("bound $prop") Int get() = 1 companion object { private const val prop = 0 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 b02237343d7..072a113d638 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 @@ -1872,6 +1872,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/annotations/cycleInParameters_before.kt"); } + @Test + @TestMetadata("danglingAnnotation.kt") + public void testDanglingAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/tests/annotations/danglingAnnotation.kt"); + } + @Test @TestMetadata("DanglingInScript.kts") public void testDanglingInScript() throws Exception { @@ -1962,6 +1968,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/annotations/InheritingAnnotationClass.kt"); } + @Test + @TestMetadata("initializerWithNestedAnnotation.kt") + public void testInitializerWithNestedAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/tests/annotations/initializerWithNestedAnnotation.kt"); + } + @Test @TestMetadata("invalidTypesInAnnotationConstructor.kt") public void testInvalidTypesInAnnotationConstructor() throws Exception { @@ -2034,6 +2046,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/annotations/MutuallyRecursivelyAnnotatedGlobalFunction.kt"); } + @Test + @TestMetadata("nestedAliasWithNestedAnnotation.kt") + public void testNestedAliasWithNestedAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/tests/annotations/nestedAliasWithNestedAnnotation.kt"); + } + @Test @TestMetadata("nestedClassAsAnnotationParameter.kt") public void testNestedClassAsAnnotationParameter() throws Exception {