From b3467353b292fded9534d810d6ac2fc90e584e27 Mon Sep 17 00:00:00 2001 From: Roman Efremov Date: Fri, 13 Oct 2023 13:48:59 +0200 Subject: [PATCH] [Test] Add test for ugly K2 reporting of annotation arguments ...in `ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT` diagnostic message. ^KT-62585 --- ...DiagnosticsWithLightTreeTestGenerated.java | 6 +++++ ...endMPPDiagnosticsWithPsiTestGenerated.java | 6 +++++ .../annotationArgRendering.fir.kt | 22 +++++++++++++++++++ .../annotationArgRendering.kt | 22 +++++++++++++++++++ .../test/runners/DiagnosticTestGenerated.java | 6 +++++ 5 files changed, 62 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/multiplatform/annotationMatching/annotationArgRendering.fir.kt create mode 100644 compiler/testData/diagnostics/tests/multiplatform/annotationMatching/annotationArgRendering.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 feca175bda6..3bc45176cb7 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 @@ -770,6 +770,12 @@ public class FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated extends Abst KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/annotationMatching"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("annotationArgRendering.kt") + public void testAnnotationArgRendering() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/annotationArgRendering.kt"); + } + @Test @TestMetadata("annotationArgumentsConstExpressions.kt") public void testAnnotationArgumentsConstExpressions() 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 50aa9103d0b..10f0c748434 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 @@ -770,6 +770,12 @@ public class FirOldFrontendMPPDiagnosticsWithPsiTestGenerated extends AbstractFi KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/annotationMatching"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("annotationArgRendering.kt") + public void testAnnotationArgRendering() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/annotationArgRendering.kt"); + } + @Test @TestMetadata("annotationArgumentsConstExpressions.kt") public void testAnnotationArgumentsConstExpressions() throws Exception { diff --git a/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/annotationArgRendering.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/annotationArgRendering.fir.kt new file mode 100644 index 00000000000..c4f1eef2b56 --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/annotationArgRendering.fir.kt @@ -0,0 +1,22 @@ +// WITH_STDLIB +// MODULE: m1-common +// FILE: common.kt +@Target(AnnotationTarget.FUNCTION, AnnotationTarget.CLASS) +expect annotation class Ann + +@Target(AnnotationTarget.TYPE, AnnotationTarget.FUNCTION) +annotation class Ann2(val s: String) + +@Ann2("1" + "2") +expect fun stringConcat() + +expect fun onType(): @Ann2("") Any? + +// MODULE: m1-jvm()()(m1-common) +// FILE: jvm.kt +actual annotation class Ann + +actual fun stringConcat() {} + +// Not reported in K1, because supported starting from K2 +actual fun onType(): Any? = null diff --git a/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/annotationArgRendering.kt b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/annotationArgRendering.kt new file mode 100644 index 00000000000..899ec8d2450 --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/annotationArgRendering.kt @@ -0,0 +1,22 @@ +// WITH_STDLIB +// MODULE: m1-common +// FILE: common.kt +@Target(AnnotationTarget.FUNCTION, AnnotationTarget.CLASS) +expect annotation class Ann + +@Target(AnnotationTarget.TYPE, AnnotationTarget.FUNCTION) +annotation class Ann2(val s: String) + +@Ann2("1" + "2") +expect fun stringConcat() + +expect fun onType(): @Ann2("") Any? + +// MODULE: m1-jvm()()(m1-common) +// FILE: jvm.kt +actual annotation class Ann + +actual fun stringConcat() {} + +// Not reported in K1, because supported starting from K2 +actual fun onType(): Any? = null 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 cbe4b0ed70a..9a0789bbb8a 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 @@ -23999,6 +23999,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/annotationMatching"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); } + @Test + @TestMetadata("annotationArgRendering.kt") + public void testAnnotationArgRendering() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/annotationArgRendering.kt"); + } + @Test @TestMetadata("annotationArgumentsConstExpressions.kt") public void testAnnotationArgumentsConstExpressions() throws Exception {