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:
Alexander Udalov
2018-02-07 16:53:30 +01:00
parent a4af9dd5d1
commit e19ed1e001
4 changed files with 112 additions and 0 deletions
@@ -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
}
@@ -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");
@@ -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");