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 e708eb2a7ae..608ecebb9ba 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 @@ -2100,6 +2100,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/tests/annotations/nestedAliasWithNestedAnnotationInLocalClass.kt"); } + @Test + @TestMetadata("nestedAnnotationOnOuterClassDeclaration.kt") + public void testNestedAnnotationOnOuterClassDeclaration() throws Exception { + runTest("compiler/testData/diagnostics/tests/annotations/nestedAnnotationOnOuterClassDeclaration.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 0628dd5fb59..60478e1c37c 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 @@ -2100,6 +2100,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/tests/annotations/nestedAliasWithNestedAnnotationInLocalClass.kt"); } + @Test + @TestMetadata("nestedAnnotationOnOuterClassDeclaration.kt") + public void testNestedAnnotationOnOuterClassDeclaration() throws Exception { + runTest("compiler/testData/diagnostics/tests/annotations/nestedAnnotationOnOuterClassDeclaration.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 97e4a82998a..8b7bfa85797 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 @@ -2094,6 +2094,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/annotations/nestedAliasWithNestedAnnotationInLocalClass.kt"); } + @Test + @TestMetadata("nestedAnnotationOnOuterClassDeclaration.kt") + public void testNestedAnnotationOnOuterClassDeclaration() throws Exception { + runTest("compiler/testData/diagnostics/tests/annotations/nestedAnnotationOnOuterClassDeclaration.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 4c89450709c..cd0faabdc99 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 @@ -2100,6 +2100,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/annotations/nestedAliasWithNestedAnnotationInLocalClass.kt"); } + @Test + @TestMetadata("nestedAnnotationOnOuterClassDeclaration.kt") + public void testNestedAnnotationOnOuterClassDeclaration() throws Exception { + runTest("compiler/testData/diagnostics/tests/annotations/nestedAnnotationOnOuterClassDeclaration.kt"); + } + @Test @TestMetadata("nestedClassAsAnnotationParameter.kt") public void testNestedClassAsAnnotationParameter() throws Exception { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSupertypesResolution.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSupertypesResolution.kt index 4ee08ce6d38..1b29d76571a 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSupertypesResolution.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSupertypesResolution.kt @@ -721,10 +721,12 @@ open class SupertypeComputationSession { var isErrorInSupertypesFound = false val resultSupertypeRefs = mutableListOf() for (supertypeRef in supertypeRefs) { - for (annotation in supertypeRef.annotations) { - val resolvedType = annotation.resolvedType as? ConeClassLikeType ?: continue - val typeArgumentClassLikeDeclaration = resolvedType.lookupTag.toSymbol(session)?.fir - checkIsInLoop(typeArgumentClassLikeDeclaration, wasSubtypingInvolved, wereTypeArgumentsInvolved) + if (isTypeAlias) { + for (annotation in supertypeRef.annotations) { + val resolvedType = annotation.resolvedType as? ConeClassLikeType ?: continue + val typeArgumentClassLikeDeclaration = resolvedType.lookupTag.toSymbol(session)?.fir + checkIsInLoop(typeArgumentClassLikeDeclaration, wasSubtypingInvolved, wereTypeArgumentsInvolved) + } } val supertypeFir = supertypeRef.firClassLike(session) checkIsInLoop(supertypeFir, isSubtypingInvolved, wereTypeArgumentsInvolved) diff --git a/compiler/testData/diagnostics/tests/annotations/nestedAnnotationOnOuterClassDeclaration.kt b/compiler/testData/diagnostics/tests/annotations/nestedAnnotationOnOuterClassDeclaration.kt new file mode 100644 index 00000000000..551bc254e3c --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/nestedAnnotationOnOuterClassDeclaration.kt @@ -0,0 +1,10 @@ +// FIR_IDENTICAL +// ISSUE: KT-64059 + +interface OuterInterface + +class MyClass: @MyClass.NestedAnnotation OuterInterface { + + @Target(AnnotationTarget.CLASS, AnnotationTarget.TYPE) + annotation class NestedAnnotation +} 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 4b077cb6f26..2c3e73320d7 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 @@ -2100,6 +2100,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/annotations/nestedAliasWithNestedAnnotationInLocalClass.kt"); } + @Test + @TestMetadata("nestedAnnotationOnOuterClassDeclaration.kt") + public void testNestedAnnotationOnOuterClassDeclaration() throws Exception { + runTest("compiler/testData/diagnostics/tests/annotations/nestedAnnotationOnOuterClassDeclaration.kt"); + } + @Test @TestMetadata("nestedClassAsAnnotationParameter.kt") public void testNestedClassAsAnnotationParameter() throws Exception {