Forbid non-intended usages of Experimental and markers
Experimental and UseExperimental can only be used as annotations or qualifiers (to allow "Experimental.Level.*"); experimental markers can only be used as annotations or qualifiers, or as left-hand side of a ::class literal in arguments to UseExperimental/WasExperimental. This is needed because we're not yet sure of the design of this feature and would like to retain the possibility to drop these declarations (Experimental, UseExperimental) altogether. If they were going to be used as types, it would be problematic because we can't simply delete something from stdlib, should deprecate it first. With this change, these declarations can only be used if the user has opted into using the experimental API somehow (for example, with `-Xuse-experimental=kotlin.Experimental`), so we won't stop conforming to our deprecation policy if we decide to remove these declarations in the future
This commit is contained in:
+4
-4
@@ -1,6 +1,6 @@
|
||||
// !API_VERSION: 1.2
|
||||
// !USE_EXPERIMENTAL: kotlin.Experimental
|
||||
// !DIAGNOSTICS: -INVISIBLE_MEMBER -INVISIBLE_REFERENCE -NEWER_VERSION_IN_SINCE_KOTLIN -UNUSED_PARAMETER
|
||||
// !DIAGNOSTICS: -INVISIBLE_MEMBER -INVISIBLE_REFERENCE -NEWER_VERSION_IN_SINCE_KOTLIN
|
||||
|
||||
@SinceKotlin("1.3")
|
||||
fun newPublishedFun() {}
|
||||
@@ -21,7 +21,7 @@ val newValExperimentalInThePast = ""
|
||||
@WasExperimental(Marker::class)
|
||||
class NewClassExperimentalInThePast
|
||||
|
||||
fun use1(c: <!UNRESOLVED_REFERENCE!>NewClassExperimentalInThePast<!>) {
|
||||
fun use1() {
|
||||
<!UNRESOLVED_REFERENCE!>newPublishedFun<!>()
|
||||
<!UNRESOLVED_REFERENCE!>newFunExperimentalInThePast<!>()
|
||||
<!UNRESOLVED_REFERENCE!>newValExperimentalInThePast<!>
|
||||
@@ -29,7 +29,7 @@ fun use1(c: <!UNRESOLVED_REFERENCE!>NewClassExperimentalInThePast<!>) {
|
||||
}
|
||||
|
||||
@UseExperimental(Marker::class)
|
||||
fun use2(c: NewClassExperimentalInThePast) {
|
||||
fun use2() {
|
||||
<!UNRESOLVED_REFERENCE!>newPublishedFun<!>()
|
||||
newFunExperimentalInThePast()
|
||||
newValExperimentalInThePast
|
||||
@@ -37,7 +37,7 @@ fun use2(c: NewClassExperimentalInThePast) {
|
||||
}
|
||||
|
||||
@Marker
|
||||
fun use3(c: NewClassExperimentalInThePast) {
|
||||
fun use3() {
|
||||
<!UNRESOLVED_REFERENCE!>newPublishedFun<!>()
|
||||
newFunExperimentalInThePast()
|
||||
newValExperimentalInThePast
|
||||
|
||||
Reference in New Issue
Block a user