From 5c644bcac891a0b70605d55d5d0a06c58256f7d6 Mon Sep 17 00:00:00 2001 From: Stanislav Ruban Date: Thu, 13 Jul 2023 10:35:05 +0300 Subject: [PATCH] [test infra] Add a directive for type checking utils that use @Exact --- ...osticCompilerTestFE10TestdataTestGenerated.java | 6 ++++++ ...iagnosticCompilerFE10TestDataTestGenerated.java | 6 ++++++ ...ghtTreeOldFrontendDiagnosticsTestGenerated.java | 6 ++++++ .../FirPsiOldFrontendDiagnosticsTestGenerated.java | 6 ++++++ .../helpers/types/checkTypeWithExact.kt | 4 ++++ .../tests/checkTypeWithExactTest.fir.kt | 14 ++++++++++++++ .../diagnostics/tests/checkTypeWithExactTest.kt | 14 ++++++++++++++ .../test/runners/DiagnosticTestGenerated.java | 6 ++++++ .../test/directives/AdditionalFilesDirectives.kt | 7 +++++++ .../AdditionalDiagnosticsSourceFilesProvider.kt | 2 ++ 10 files changed, 71 insertions(+) create mode 100644 compiler/testData/diagnostics/helpers/types/checkTypeWithExact.kt create mode 100644 compiler/testData/diagnostics/tests/checkTypeWithExactTest.fir.kt create mode 100644 compiler/testData/diagnostics/tests/checkTypeWithExactTest.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 ac8fbc620a7..2c8a7269e82 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 @@ -165,6 +165,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/tests/checkTypeTest.kt"); } + @Test + @TestMetadata("checkTypeWithExactTest.kt") + public void testCheckTypeWithExactTest() throws Exception { + runTest("compiler/testData/diagnostics/tests/checkTypeWithExactTest.kt"); + } + @Test @TestMetadata("CompareToWithErrorType.kt") public void testCompareToWithErrorType() 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 515f018c1b1..073577c299e 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 @@ -165,6 +165,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/tests/checkTypeTest.kt"); } + @Test + @TestMetadata("checkTypeWithExactTest.kt") + public void testCheckTypeWithExactTest() throws Exception { + runTest("compiler/testData/diagnostics/tests/checkTypeWithExactTest.kt"); + } + @Test @TestMetadata("CompareToWithErrorType.kt") public void testCompareToWithErrorType() 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 31a721facce..1ca47a02462 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 @@ -165,6 +165,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/checkTypeTest.kt"); } + @Test + @TestMetadata("checkTypeWithExactTest.kt") + public void testCheckTypeWithExactTest() throws Exception { + runTest("compiler/testData/diagnostics/tests/checkTypeWithExactTest.kt"); + } + @Test @TestMetadata("CompareToWithErrorType.kt") public void testCompareToWithErrorType() 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 142adad5b9f..799714249ba 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 @@ -165,6 +165,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/checkTypeTest.kt"); } + @Test + @TestMetadata("checkTypeWithExactTest.kt") + public void testCheckTypeWithExactTest() throws Exception { + runTest("compiler/testData/diagnostics/tests/checkTypeWithExactTest.kt"); + } + @Test @TestMetadata("CompareToWithErrorType.kt") public void testCompareToWithErrorType() throws Exception { diff --git a/compiler/testData/diagnostics/helpers/types/checkTypeWithExact.kt b/compiler/testData/diagnostics/helpers/types/checkTypeWithExact.kt new file mode 100644 index 00000000000..e8371bce6ba --- /dev/null +++ b/compiler/testData/diagnostics/helpers/types/checkTypeWithExact.kt @@ -0,0 +1,4 @@ +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +fun checkExactType(expr: @kotlin.internal.Exact T) {} +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +fun checkTypeEquality(reference: @kotlin.internal.Exact T, expr: @kotlin.internal.Exact T) {} diff --git a/compiler/testData/diagnostics/tests/checkTypeWithExactTest.fir.kt b/compiler/testData/diagnostics/tests/checkTypeWithExactTest.fir.kt new file mode 100644 index 00000000000..6e8985ba6bc --- /dev/null +++ b/compiler/testData/diagnostics/tests/checkTypeWithExactTest.fir.kt @@ -0,0 +1,14 @@ +// CHECK_TYPE_WITH_EXACT + +open class A +open class B: A() +class C: B() + +fun test(expr: B) { + checkExactType(expr) + checkExactType(expr) + checkExactType(expr) + checkTypeEquality(A(), expr) + checkTypeEquality(B(), expr) + checkTypeEquality(C(), expr) +} diff --git a/compiler/testData/diagnostics/tests/checkTypeWithExactTest.kt b/compiler/testData/diagnostics/tests/checkTypeWithExactTest.kt new file mode 100644 index 00000000000..7e72e68dadb --- /dev/null +++ b/compiler/testData/diagnostics/tests/checkTypeWithExactTest.kt @@ -0,0 +1,14 @@ +// CHECK_TYPE_WITH_EXACT + +open class A +open class B: A() +class C: B() + +fun test(expr: B) { + checkExactType(expr) + checkExactType(expr) + checkExactType(expr) + checkTypeEquality(A(), expr) + checkTypeEquality(B(), expr) + checkTypeEquality(C(), expr) +} 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 8d9537e5861..8f6dc9c1131 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 @@ -165,6 +165,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/checkTypeTest.kt"); } + @Test + @TestMetadata("checkTypeWithExactTest.kt") + public void testCheckTypeWithExactTest() throws Exception { + runTest("compiler/testData/diagnostics/tests/checkTypeWithExactTest.kt"); + } + @Test @TestMetadata("CompareToWithErrorType.kt") public void testCompareToWithErrorType() throws Exception { diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/AdditionalFilesDirectives.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/AdditionalFilesDirectives.kt index 0821ddc2f01..3ee55f3500c 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/AdditionalFilesDirectives.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/AdditionalFilesDirectives.kt @@ -15,6 +15,13 @@ object AdditionalFilesDirectives : SimpleDirectivesContainer() { """.trimIndent() ) + val CHECK_TYPE_WITH_EXACT by directive( + description = """ + Adds util functions for type checking that use @kotlin.internal.Exact annotation + See file ./compiler/testData/diagnostics/helpers/types/checkTypeWithExact.kt + """.trimIndent() + ) + val WITH_COROUTINES by directive( description = """ Adds util functions for checking coroutines diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/sourceProviders/AdditionalDiagnosticsSourceFilesProvider.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/sourceProviders/AdditionalDiagnosticsSourceFilesProvider.kt index 831b689a19a..192988715d3 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/sourceProviders/AdditionalDiagnosticsSourceFilesProvider.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/sourceProviders/AdditionalDiagnosticsSourceFilesProvider.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.test.services.sourceProviders import org.jetbrains.kotlin.test.directives.AdditionalFilesDirectives +import org.jetbrains.kotlin.test.directives.AdditionalFilesDirectives.CHECK_TYPE_WITH_EXACT import org.jetbrains.kotlin.test.directives.AdditionalFilesDirectives.CHECK_TYPE import org.jetbrains.kotlin.test.directives.AdditionalFilesDirectives.INFERENCE_HELPERS import org.jetbrains.kotlin.test.directives.model.DirectivesContainer @@ -21,6 +22,7 @@ class AdditionalDiagnosticsSourceFilesProvider(testServices: TestServices, baseD private val helpersPath = "$baseDir/compiler/testData/diagnostics/helpers" private val directiveToFileMap: Map = mapOf( CHECK_TYPE to "$helpersPath/types/checkType.kt", + CHECK_TYPE_WITH_EXACT to "$helpersPath/types/checkTypeWithExact.kt", INFERENCE_HELPERS to "$helpersPath/inference/inferenceUtils.kt" )