Add test on experimental const val in annotation argument
This test checks that a usage inside an annotation argument is a signature usage, which may be too restricting but easier to support at the moment (and the restriction can be lifted in the future)
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
// !API_VERSION: 1.3
|
||||
// MODULE: api
|
||||
// FILE: api.kt
|
||||
|
||||
package api
|
||||
|
||||
@Experimental(Experimental.Level.WARNING, [Experimental.Impact.COMPILATION])
|
||||
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION)
|
||||
annotation class ExperimentalAPI
|
||||
|
||||
@ExperimentalAPI
|
||||
const val MEANING = 42
|
||||
|
||||
annotation class Anno(val value: Int)
|
||||
|
||||
// MODULE: usage1(api)
|
||||
// FILE: usage-propagate.kt
|
||||
|
||||
package usage1
|
||||
|
||||
import api.*
|
||||
|
||||
@ExperimentalAPI
|
||||
@Anno(MEANING)
|
||||
fun usage() {}
|
||||
|
||||
// MODULE: usage2(api)
|
||||
// FILE: usage-use.kt
|
||||
|
||||
@file:UseExperimental(ExperimentalAPI::class)
|
||||
package usage2
|
||||
|
||||
import api.*
|
||||
|
||||
@Anno(<!EXPERIMENTAL_API_USAGE!>MEANING<!>)
|
||||
fun usage() {}
|
||||
|
||||
// MODULE: usage3(api)
|
||||
// FILE: usage-none.kt
|
||||
|
||||
package usage3
|
||||
|
||||
import api.*
|
||||
|
||||
@Anno(<!EXPERIMENTAL_API_USAGE!>MEANING<!>)
|
||||
fun usage() {}
|
||||
@@ -0,0 +1,54 @@
|
||||
// -- Module: <api> --
|
||||
package
|
||||
|
||||
package api {
|
||||
@api.ExperimentalAPI public const val MEANING: kotlin.Int = 42
|
||||
|
||||
public final annotation class Anno : kotlin.Annotation {
|
||||
public constructor Anno(/*0*/ value: kotlin.Int)
|
||||
public final val value: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@kotlin.Experimental(changesMayBreak = {Impact.COMPILATION}, level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION}) public final annotation class ExperimentalAPI : kotlin.Annotation {
|
||||
public constructor ExperimentalAPI()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -- Module: <usage1> --
|
||||
package
|
||||
|
||||
package api {
|
||||
}
|
||||
|
||||
package usage1 {
|
||||
@api.ExperimentalAPI @api.Anno(value = 42) public fun usage(): kotlin.Unit
|
||||
}
|
||||
|
||||
|
||||
// -- Module: <usage2> --
|
||||
package
|
||||
|
||||
package api {
|
||||
}
|
||||
|
||||
package usage2 {
|
||||
@api.Anno(value = 42) public fun usage(): kotlin.Unit
|
||||
}
|
||||
|
||||
|
||||
// -- Module: <usage3> --
|
||||
package
|
||||
|
||||
package api {
|
||||
}
|
||||
|
||||
package usage3 {
|
||||
@api.Anno(value = 42) public fun usage(): kotlin.Unit
|
||||
}
|
||||
+6
@@ -1839,6 +1839,12 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("constVal.kt")
|
||||
public void testConstVal() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/experimental/constVal.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("deeplyNestedClass.kt")
|
||||
public void testDeeplyNestedClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/experimental/deeplyNestedClass.kt");
|
||||
|
||||
compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java
Generated
+6
@@ -1839,6 +1839,12 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("constVal.kt")
|
||||
public void testConstVal() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/experimental/constVal.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("deeplyNestedClass.kt")
|
||||
public void testDeeplyNestedClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/experimental/deeplyNestedClass.kt");
|
||||
|
||||
Reference in New Issue
Block a user