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:
Alexander Udalov
2018-04-27 19:01:17 +02:00
parent ed6f044fb0
commit 9995438b37
10 changed files with 177 additions and 9 deletions
@@ -0,0 +1,38 @@
package
package test {
public fun f1(/*0*/ e: kotlin.Experimental): kotlin.Unit
public fun f2(/*0*/ u: kotlin.UseExperimental?): kotlin.Unit
public fun f3(/*0*/ e: test.Experimental0 /* = kotlin.Experimental */): kotlin.Unit
public fun f4(/*0*/ u: test.UseExperimental0 /* = kotlin.UseExperimental */): kotlin.Unit
@test.VarargKClasses(k = {kotlin.Experimental::class, kotlin.UseExperimental::class, kotlin.Experimental::class, kotlin.UseExperimental::class}) public fun f5(): kotlin.Unit
public fun f6(/*0*/ m: test.Marker): kotlin.Unit
public fun f7(): kotlin.collections.List<test.Marker>?
public fun f8(): test.Marker?
public fun f9(/*0*/ m: test.Marker0 /* = test.Marker */): kotlin.Unit
@kotlin.Experimental(level = Level.ERROR) public final annotation class M : kotlin.Annotation {
public constructor M()
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 public final annotation class Marker : kotlin.Annotation {
public constructor Marker()
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
}
public final annotation class VarargKClasses : kotlin.Annotation {
public constructor VarargKClasses(/*0*/ vararg k: kotlin.reflect.KClass<*> /*kotlin.Array<out kotlin.reflect.KClass<*>>*/)
public final val k: kotlin.Array<out kotlin.reflect.KClass<*>>
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
}
public typealias Experimental0 = kotlin.Experimental
public typealias Marker0 = test.Marker
public typealias UseExperimental0 = kotlin.UseExperimental
}