From 5ed3f308fad9ecc018e4438f983914547c089b0e Mon Sep 17 00:00:00 2001 From: Roman Efremov Date: Tue, 1 Aug 2023 12:59:45 +0200 Subject: [PATCH] Add tests for repeatable annotations on expect-actual declarations Add tests showing current behavior. ^KT-60670 --- ...DiagnosticsWithLightTreeTestGenerated.java | 12 ++++++ ...endMPPDiagnosticsWithPsiTestGenerated.java | 12 ++++++ .../annotationMatching/repeatableNoArg.kt | 23 +++++++++++ .../repeatableWithArg.fir.kt | 40 +++++++++++++++++++ .../annotationMatching/repeatableWithArg.kt | 40 +++++++++++++++++++ .../test/runners/DiagnosticTestGenerated.java | 12 ++++++ 6 files changed, 139 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/multiplatform/annotationMatching/repeatableNoArg.kt create mode 100644 compiler/testData/diagnostics/tests/multiplatform/annotationMatching/repeatableWithArg.fir.kt create mode 100644 compiler/testData/diagnostics/tests/multiplatform/annotationMatching/repeatableWithArg.kt diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated.java index bea2ece4bee..2a5d6cd78ad 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated.java @@ -292,6 +292,18 @@ public class FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated extends Abst runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/kotlinAnaloguesForJavaAnnotations.kt"); } + @Test + @TestMetadata("repeatableNoArg.kt") + public void testRepeatableNoArg() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/repeatableNoArg.kt"); + } + + @Test + @TestMetadata("repeatableWithArg.kt") + public void testRepeatableWithArg() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/repeatableWithArg.kt"); + } + @Test @TestMetadata("skippedAnnotations.kt") public void testSkippedAnnotations() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithPsiTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithPsiTestGenerated.java index b39f65fa1cd..f5ea04fbf14 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithPsiTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithPsiTestGenerated.java @@ -292,6 +292,18 @@ public class FirOldFrontendMPPDiagnosticsWithPsiTestGenerated extends AbstractFi runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/kotlinAnaloguesForJavaAnnotations.kt"); } + @Test + @TestMetadata("repeatableNoArg.kt") + public void testRepeatableNoArg() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/repeatableNoArg.kt"); + } + + @Test + @TestMetadata("repeatableWithArg.kt") + public void testRepeatableWithArg() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/repeatableWithArg.kt"); + } + @Test @TestMetadata("skippedAnnotations.kt") public void testSkippedAnnotations() throws Exception { diff --git a/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/repeatableNoArg.kt b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/repeatableNoArg.kt new file mode 100644 index 00000000000..4cec261099b --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/repeatableNoArg.kt @@ -0,0 +1,23 @@ +// FIR_IDENTICAL +// WITH_STDLIB +// MODULE: m1-common +// FILE: common.kt +@Repeatable +annotation class AnnNoArg + +@AnnNoArg +@AnnNoArg +expect fun oneMoreOnExpect() + +@AnnNoArg +expect fun oneMoreOnActual() + +// MODULE: m1-jvm()()(m1-common) +// FILE: jvm.kt + +@AnnNoArg +actual fun oneMoreOnExpect() {} + +@AnnNoArg +@AnnNoArg +actual fun oneMoreOnActual() {} diff --git a/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/repeatableWithArg.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/repeatableWithArg.fir.kt new file mode 100644 index 00000000000..5f385812990 --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/repeatableWithArg.fir.kt @@ -0,0 +1,40 @@ +// WITH_STDLIB +// MODULE: m1-common +// FILE: common.kt +@Repeatable +annotation class AnnWithArg(val s: String) + +@AnnWithArg(s = "1") +@AnnWithArg(s = "2") +expect fun diffentOrder() + +@AnnWithArg(s = "1") +@AnnWithArg(s = "2") +@AnnWithArg(s = "3") +expect fun withDifferentArgLessOnActual() + +@AnnWithArg(s = "1") +@AnnWithArg(s = "3") +expect fun withDifferentArgLessOnExpect() + +@AnnWithArg(s = "1") +@AnnWithArg(s = "1") +expect fun withSameArgLessOnActual() + +// MODULE: m1-jvm()()(m1-common) +// FILE: jvm.kt +@AnnWithArg(s = "1") +@AnnWithArg(s = "2") +actual fun diffentOrder() {} + +@AnnWithArg(s = "1") +@AnnWithArg(s = "3") +actual fun withDifferentArgLessOnActual() {} + +@AnnWithArg(s = "1") +@AnnWithArg(s = "2") +@AnnWithArg(s = "3") +actual fun withDifferentArgLessOnExpect() {} + +@AnnWithArg(s = "1") +actual fun withSameArgLessOnActual() {} diff --git a/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/repeatableWithArg.kt b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/repeatableWithArg.kt new file mode 100644 index 00000000000..9110ac2dcdb --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/repeatableWithArg.kt @@ -0,0 +1,40 @@ +// WITH_STDLIB +// MODULE: m1-common +// FILE: common.kt +@Repeatable +annotation class AnnWithArg(val s: String) + +@AnnWithArg(s = "1") +@AnnWithArg(s = "2") +expect fun diffentOrder() + +@AnnWithArg(s = "1") +@AnnWithArg(s = "2") +@AnnWithArg(s = "3") +expect fun withDifferentArgLessOnActual() + +@AnnWithArg(s = "1") +@AnnWithArg(s = "3") +expect fun withDifferentArgLessOnExpect() + +@AnnWithArg(s = "1") +@AnnWithArg(s = "1") +expect fun withSameArgLessOnActual() + +// MODULE: m1-jvm()()(m1-common) +// FILE: jvm.kt +@AnnWithArg(s = "1") +@AnnWithArg(s = "2") +actual fun diffentOrder() {} + +@AnnWithArg(s = "1") +@AnnWithArg(s = "3") +actual fun withDifferentArgLessOnActual() {} + +@AnnWithArg(s = "1") +@AnnWithArg(s = "2") +@AnnWithArg(s = "3") +actual fun withDifferentArgLessOnExpect() {} + +@AnnWithArg(s = "1") +actual fun withSameArgLessOnActual() {} 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 a6961496a71..8942f94d626 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 @@ -22935,6 +22935,18 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/kotlinAnaloguesForJavaAnnotations.kt"); } + @Test + @TestMetadata("repeatableNoArg.kt") + public void testRepeatableNoArg() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/repeatableNoArg.kt"); + } + + @Test + @TestMetadata("repeatableWithArg.kt") + public void testRepeatableWithArg() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/repeatableWithArg.kt"); + } + @Test @TestMetadata("skippedAnnotations.kt") public void testSkippedAnnotations() throws Exception {