[test infra] Add a directive for type checking utils that use @Exact
This commit is contained in:
committed by
Space Team
parent
0323b0fb19
commit
5c644bcac8
+6
@@ -165,6 +165,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
|||||||
runTest("compiler/testData/diagnostics/tests/checkTypeTest.kt");
|
runTest("compiler/testData/diagnostics/tests/checkTypeTest.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("checkTypeWithExactTest.kt")
|
||||||
|
public void testCheckTypeWithExactTest() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/checkTypeWithExactTest.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("CompareToWithErrorType.kt")
|
@TestMetadata("CompareToWithErrorType.kt")
|
||||||
public void testCompareToWithErrorType() throws Exception {
|
public void testCompareToWithErrorType() throws Exception {
|
||||||
|
|||||||
+6
@@ -165,6 +165,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
|||||||
runTest("compiler/testData/diagnostics/tests/checkTypeTest.kt");
|
runTest("compiler/testData/diagnostics/tests/checkTypeTest.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("checkTypeWithExactTest.kt")
|
||||||
|
public void testCheckTypeWithExactTest() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/checkTypeWithExactTest.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("CompareToWithErrorType.kt")
|
@TestMetadata("CompareToWithErrorType.kt")
|
||||||
public void testCompareToWithErrorType() throws Exception {
|
public void testCompareToWithErrorType() throws Exception {
|
||||||
|
|||||||
+6
@@ -165,6 +165,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
|||||||
runTest("compiler/testData/diagnostics/tests/checkTypeTest.kt");
|
runTest("compiler/testData/diagnostics/tests/checkTypeTest.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("checkTypeWithExactTest.kt")
|
||||||
|
public void testCheckTypeWithExactTest() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/checkTypeWithExactTest.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("CompareToWithErrorType.kt")
|
@TestMetadata("CompareToWithErrorType.kt")
|
||||||
public void testCompareToWithErrorType() throws Exception {
|
public void testCompareToWithErrorType() throws Exception {
|
||||||
|
|||||||
+6
@@ -165,6 +165,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
|||||||
runTest("compiler/testData/diagnostics/tests/checkTypeTest.kt");
|
runTest("compiler/testData/diagnostics/tests/checkTypeTest.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("checkTypeWithExactTest.kt")
|
||||||
|
public void testCheckTypeWithExactTest() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/checkTypeWithExactTest.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("CompareToWithErrorType.kt")
|
@TestMetadata("CompareToWithErrorType.kt")
|
||||||
public void testCompareToWithErrorType() throws Exception {
|
public void testCompareToWithErrorType() throws Exception {
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||||
|
fun <T> checkExactType(expr: @kotlin.internal.Exact T) {}
|
||||||
|
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||||
|
fun <T> checkTypeEquality(reference: @kotlin.internal.Exact T, expr: @kotlin.internal.Exact T) {}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
// CHECK_TYPE_WITH_EXACT
|
||||||
|
|
||||||
|
open class A
|
||||||
|
open class B: A()
|
||||||
|
class C: B()
|
||||||
|
|
||||||
|
fun test(expr: B) {
|
||||||
|
checkExactType<A>(<!ARGUMENT_TYPE_MISMATCH!>expr<!>)
|
||||||
|
checkExactType<B>(expr)
|
||||||
|
checkExactType<C>(<!ARGUMENT_TYPE_MISMATCH!>expr<!>)
|
||||||
|
checkTypeEquality(A(), <!ARGUMENT_TYPE_MISMATCH!>expr<!>)
|
||||||
|
checkTypeEquality(B(), expr)
|
||||||
|
checkTypeEquality(C(), <!ARGUMENT_TYPE_MISMATCH!>expr<!>)
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
// CHECK_TYPE_WITH_EXACT
|
||||||
|
|
||||||
|
open class A
|
||||||
|
open class B: A()
|
||||||
|
class C: B()
|
||||||
|
|
||||||
|
fun test(expr: B) {
|
||||||
|
checkExactType<A>(<!TYPE_MISMATCH!>expr<!>)
|
||||||
|
checkExactType<B>(expr)
|
||||||
|
checkExactType<C>(<!TYPE_MISMATCH!>expr<!>)
|
||||||
|
checkTypeEquality(A(), <!TYPE_MISMATCH!>expr<!>)
|
||||||
|
checkTypeEquality(B(), expr)
|
||||||
|
checkTypeEquality(C(), <!TYPE_MISMATCH!>expr<!>)
|
||||||
|
}
|
||||||
Generated
+6
@@ -165,6 +165,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/checkTypeTest.kt");
|
runTest("compiler/testData/diagnostics/tests/checkTypeTest.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("checkTypeWithExactTest.kt")
|
||||||
|
public void testCheckTypeWithExactTest() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/checkTypeWithExactTest.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("CompareToWithErrorType.kt")
|
@TestMetadata("CompareToWithErrorType.kt")
|
||||||
public void testCompareToWithErrorType() throws Exception {
|
public void testCompareToWithErrorType() throws Exception {
|
||||||
|
|||||||
+7
@@ -15,6 +15,13 @@ object AdditionalFilesDirectives : SimpleDirectivesContainer() {
|
|||||||
""".trimIndent()
|
""".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(
|
val WITH_COROUTINES by directive(
|
||||||
description = """
|
description = """
|
||||||
Adds util functions for checking coroutines
|
Adds util functions for checking coroutines
|
||||||
|
|||||||
+2
@@ -6,6 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.test.services.sourceProviders
|
package org.jetbrains.kotlin.test.services.sourceProviders
|
||||||
|
|
||||||
import org.jetbrains.kotlin.test.directives.AdditionalFilesDirectives
|
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.CHECK_TYPE
|
||||||
import org.jetbrains.kotlin.test.directives.AdditionalFilesDirectives.INFERENCE_HELPERS
|
import org.jetbrains.kotlin.test.directives.AdditionalFilesDirectives.INFERENCE_HELPERS
|
||||||
import org.jetbrains.kotlin.test.directives.model.DirectivesContainer
|
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 helpersPath = "$baseDir/compiler/testData/diagnostics/helpers"
|
||||||
private val directiveToFileMap: Map<SimpleDirective, String> = mapOf(
|
private val directiveToFileMap: Map<SimpleDirective, String> = mapOf(
|
||||||
CHECK_TYPE to "$helpersPath/types/checkType.kt",
|
CHECK_TYPE to "$helpersPath/types/checkType.kt",
|
||||||
|
CHECK_TYPE_WITH_EXACT to "$helpersPath/types/checkTypeWithExact.kt",
|
||||||
INFERENCE_HELPERS to "$helpersPath/inference/inferenceUtils.kt"
|
INFERENCE_HELPERS to "$helpersPath/inference/inferenceUtils.kt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user