From 4c75fb108f20fab02d4f4417d65abfb40c96e220 Mon Sep 17 00:00:00 2001 From: Roman Efremov Date: Thu, 5 Oct 2023 14:32:40 +0200 Subject: [PATCH] [Test] Add test for `ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT` diagnostic ...when annotations arguments are lazily resolved. MR: KT-MR-12245 ^KT-60671 --- ...CompilerTestFE10TestdataTestGenerated.java | 6 +++ ...sticCompilerFE10TestDataTestGenerated.java | 6 +++ ...eeOldFrontendDiagnosticsTestGenerated.java | 6 +++ ...siOldFrontendDiagnosticsTestGenerated.java | 6 +++ ...ectActualAnnotationsWithLazyResolve.fir.kt | 35 +++++++++++++++++ .../expectActualAnnotationsWithLazyResolve.kt | 35 +++++++++++++++++ ...pectActualAnnotationsWithLazyResolve.ll.kt | 39 +++++++++++++++++++ .../test/runners/DiagnosticTestGenerated.java | 6 +++ 8 files changed, 139 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/multimodule/expectActualAnnotationsWithLazyResolve.fir.kt create mode 100644 compiler/testData/diagnostics/tests/multimodule/expectActualAnnotationsWithLazyResolve.kt create mode 100644 compiler/testData/diagnostics/tests/multimodule/expectActualAnnotationsWithLazyResolve.ll.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 1743701e718..7b18c0faa69 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 @@ -22814,6 +22814,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/tests/multimodule/dependsOnModule.kt"); } + @Test + @TestMetadata("expectActualAnnotationsWithLazyResolve.kt") + public void testExpectActualAnnotationsWithLazyResolve() throws Exception { + runTest("compiler/testData/diagnostics/tests/multimodule/expectActualAnnotationsWithLazyResolve.kt"); + } + @Test @TestMetadata("friendModule.kt") public void testFriendModule() 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 eba212a0e02..401bc95bd13 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 @@ -22814,6 +22814,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/tests/multimodule/dependsOnModule.kt"); } + @Test + @TestMetadata("expectActualAnnotationsWithLazyResolve.kt") + public void testExpectActualAnnotationsWithLazyResolve() throws Exception { + runTest("compiler/testData/diagnostics/tests/multimodule/expectActualAnnotationsWithLazyResolve.kt"); + } + @Test @TestMetadata("friendModule.kt") public void testFriendModule() 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 182b6517d66..93e4b4eddaf 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 @@ -22814,6 +22814,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/multimodule/dependsOnModule.kt"); } + @Test + @TestMetadata("expectActualAnnotationsWithLazyResolve.kt") + public void testExpectActualAnnotationsWithLazyResolve() throws Exception { + runTest("compiler/testData/diagnostics/tests/multimodule/expectActualAnnotationsWithLazyResolve.kt"); + } + @Test @TestMetadata("friendModule.kt") public void testFriendModule() 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 3ddea72ab88..861ec623b6a 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 @@ -22820,6 +22820,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/multimodule/dependsOnModule.kt"); } + @Test + @TestMetadata("expectActualAnnotationsWithLazyResolve.kt") + public void testExpectActualAnnotationsWithLazyResolve() throws Exception { + runTest("compiler/testData/diagnostics/tests/multimodule/expectActualAnnotationsWithLazyResolve.kt"); + } + @Test @TestMetadata("friendModule.kt") public void testFriendModule() throws Exception { diff --git a/compiler/testData/diagnostics/tests/multimodule/expectActualAnnotationsWithLazyResolve.fir.kt b/compiler/testData/diagnostics/tests/multimodule/expectActualAnnotationsWithLazyResolve.fir.kt new file mode 100644 index 00000000000..ba982f0e81d --- /dev/null +++ b/compiler/testData/diagnostics/tests/multimodule/expectActualAnnotationsWithLazyResolve.fir.kt @@ -0,0 +1,35 @@ +// Test for ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT diagnostic when annotations arguments are lazily resolved. + +// LANGUAGE: +MultiPlatformProjects +// MODULE: common +// TARGET_PLATFORM: Common +@Target(AnnotationTarget.TYPE, AnnotationTarget.FUNCTION) +annotation class Ann(val s: String = "default") + +expect fun onType_negative(): @Ann("") Any +expect fun onType_positive(): @Ann("") Any + +@Ann("") +expect fun onFunction_negative() +@Ann("") +expect fun onFunction_positive() + +@Ann +expect fun withEmptyArguments_negative() +@Ann +expect fun withEmptyArguments_positive() + +// MODULE: main()()(common) +// TARGET_PLATFORM: JVM +actual fun onType_negative(): @Ann("") Any = Any() +actual fun onType_positive(): @Ann("incorrect") Any = Any() + +@Ann("") +actual fun onFunction_negative() {} +@Ann("incorrect") +actual fun onFunction_positive() {} + +@Ann +actual fun withEmptyArguments_negative() {} +@Ann("incorrect") +actual fun withEmptyArguments_positive() {} diff --git a/compiler/testData/diagnostics/tests/multimodule/expectActualAnnotationsWithLazyResolve.kt b/compiler/testData/diagnostics/tests/multimodule/expectActualAnnotationsWithLazyResolve.kt new file mode 100644 index 00000000000..9da54c40a15 --- /dev/null +++ b/compiler/testData/diagnostics/tests/multimodule/expectActualAnnotationsWithLazyResolve.kt @@ -0,0 +1,35 @@ +// Test for ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT diagnostic when annotations arguments are lazily resolved. + +// LANGUAGE: +MultiPlatformProjects +// MODULE: common +// TARGET_PLATFORM: Common +@Target(AnnotationTarget.TYPE, AnnotationTarget.FUNCTION) +annotation class Ann(val s: String = "default") + +expect fun onType_negative(): @Ann("") Any +expect fun onType_positive(): @Ann("") Any + +@Ann("") +expect fun onFunction_negative() +@Ann("") +expect fun onFunction_positive() + +@Ann +expect fun withEmptyArguments_negative() +@Ann +expect fun withEmptyArguments_positive() + +// MODULE: main()()(common) +// TARGET_PLATFORM: JVM +actual fun onType_negative(): @Ann("") Any = Any() +actual fun onType_positive(): @Ann("incorrect") Any = Any() + +@Ann("") +actual fun onFunction_negative() {} +@Ann("incorrect") +actual fun onFunction_positive() {} + +@Ann +actual fun withEmptyArguments_negative() {} +@Ann("incorrect") +actual fun withEmptyArguments_positive() {} diff --git a/compiler/testData/diagnostics/tests/multimodule/expectActualAnnotationsWithLazyResolve.ll.kt b/compiler/testData/diagnostics/tests/multimodule/expectActualAnnotationsWithLazyResolve.ll.kt new file mode 100644 index 00000000000..45498814753 --- /dev/null +++ b/compiler/testData/diagnostics/tests/multimodule/expectActualAnnotationsWithLazyResolve.ll.kt @@ -0,0 +1,39 @@ +// LL_FIR_DIVERGENCE +// The reason is bug, which will be fixed in next commit +// LL_FIR_DIVERGENCE + +// Test for ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT diagnostic when annotations arguments are lazily resolved. + +// LANGUAGE: +MultiPlatformProjects +// MODULE: common +// TARGET_PLATFORM: Common +@Target(AnnotationTarget.TYPE, AnnotationTarget.FUNCTION) +annotation class Ann(val s: String = "default") + +expect fun onType_negative(): @Ann("") Any +expect fun onType_positive(): @Ann("") Any + +@Ann("") +expect fun onFunction_negative() +@Ann("") +expect fun onFunction_positive() + +@Ann +expect fun withEmptyArguments_negative() +@Ann +expect fun withEmptyArguments_positive() + +// MODULE: main()()(common) +// TARGET_PLATFORM: JVM +actual fun onType_negative(): @Ann("") Any = Any() +actual fun onType_positive(): @Ann("incorrect") Any = Any() + +@Ann("") +actual fun onFunction_negative() {} +@Ann("incorrect") +actual fun onFunction_positive() {} + +@Ann +actual fun withEmptyArguments_negative() {} +@Ann("incorrect") +actual fun withEmptyArguments_positive() {} 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 a66726ad746..7b7c55eb266 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 @@ -22820,6 +22820,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/multimodule/dependsOnModule.kt"); } + @Test + @TestMetadata("expectActualAnnotationsWithLazyResolve.kt") + public void testExpectActualAnnotationsWithLazyResolve() throws Exception { + runTest("compiler/testData/diagnostics/tests/multimodule/expectActualAnnotationsWithLazyResolve.kt"); + } + @Test @TestMetadata("friendModule.kt") public void testFriendModule() throws Exception {