[FIR-TEST] Add new testdata generated after changes in previous commit
This commit is contained in:
+136
@@ -0,0 +1,136 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.Experimental
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// FILE: api.kt
|
||||
|
||||
package api
|
||||
|
||||
@Experimental(Experimental.Level.WARNING)
|
||||
@Target(AnnotationTarget.TYPE, AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.TYPEALIAS,
|
||||
AnnotationTarget.VALUE_PARAMETER)
|
||||
annotation class ExperimentalAPI
|
||||
|
||||
@ExperimentalAPI
|
||||
@Target(AnnotationTarget.TYPE, AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.TYPEALIAS,
|
||||
AnnotationTarget.VALUE_PARAMETER)
|
||||
annotation class EAnno
|
||||
|
||||
// FILE: usage-propagate.kt
|
||||
|
||||
package usage1
|
||||
|
||||
import api.*
|
||||
|
||||
@ExperimentalAPI
|
||||
@EAnno fun function() {}
|
||||
|
||||
@ExperimentalAPI
|
||||
fun parameter(@EAnno p: String) {}
|
||||
|
||||
@ExperimentalAPI
|
||||
fun parameterType(p: @EAnno String) {}
|
||||
|
||||
@ExperimentalAPI
|
||||
fun returnType(): @EAnno Unit {}
|
||||
|
||||
@ExperimentalAPI
|
||||
@EAnno val property = ""
|
||||
|
||||
@ExperimentalAPI
|
||||
@EAnno typealias Typealias = Unit
|
||||
|
||||
@ExperimentalAPI
|
||||
@EAnno class Klass
|
||||
|
||||
@ExperimentalAPI
|
||||
annotation class AnnotationArgument(val p: EAnno)
|
||||
|
||||
@ExperimentalAPI
|
||||
fun insideBody() {
|
||||
@EAnno fun local() {}
|
||||
}
|
||||
|
||||
@ExperimentalAPI
|
||||
fun inDefaultArgument(f: () -> Unit = @EAnno fun() {}) {}
|
||||
|
||||
@ExperimentalAPI
|
||||
val inProperty = @EAnno fun() {}
|
||||
|
||||
@ExperimentalAPI
|
||||
val inPropertyAccessor: () -> Unit
|
||||
get() = @EAnno fun() {}
|
||||
|
||||
// FILE: usage-use.kt
|
||||
|
||||
package usage2
|
||||
|
||||
import api.*
|
||||
|
||||
@UseExperimental(ExperimentalAPI::class)
|
||||
@EAnno fun function() {}
|
||||
|
||||
@UseExperimental(ExperimentalAPI::class)
|
||||
fun parameter(@EAnno p: String) {}
|
||||
|
||||
@UseExperimental(ExperimentalAPI::class)
|
||||
fun parameterType(p: @EAnno String) {}
|
||||
|
||||
@UseExperimental(ExperimentalAPI::class)
|
||||
fun returnType(): @EAnno Unit {}
|
||||
|
||||
@UseExperimental(ExperimentalAPI::class)
|
||||
@EAnno val property = ""
|
||||
|
||||
@UseExperimental(ExperimentalAPI::class)
|
||||
@EAnno typealias Typealias = Unit
|
||||
|
||||
@UseExperimental(ExperimentalAPI::class)
|
||||
@EAnno class Klass
|
||||
|
||||
@UseExperimental(ExperimentalAPI::class)
|
||||
annotation class AnnotationArgument(val p: EAnno)
|
||||
|
||||
fun insideBody() {
|
||||
@UseExperimental(ExperimentalAPI::class) @EAnno fun local() {}
|
||||
}
|
||||
|
||||
fun inDefaultArgument(@UseExperimental(ExperimentalAPI::class) f: () -> Unit = @EAnno fun() {}) {}
|
||||
|
||||
@UseExperimental(ExperimentalAPI::class)
|
||||
val inProperty = @EAnno fun() {}
|
||||
|
||||
val inPropertyAccessor: () -> Unit
|
||||
@UseExperimental(ExperimentalAPI::class)
|
||||
get() = @EAnno fun() {}
|
||||
|
||||
// FILE: usage-none.kt
|
||||
|
||||
package usage3
|
||||
|
||||
import api.*
|
||||
|
||||
@EAnno fun function() {}
|
||||
|
||||
fun parameter(@EAnno p: String) {}
|
||||
|
||||
fun parameterType(p: @EAnno String) {}
|
||||
|
||||
fun returnType(): @EAnno Unit {}
|
||||
|
||||
@EAnno val property = ""
|
||||
|
||||
@EAnno typealias Typealias = Unit
|
||||
|
||||
@EAnno class Klass
|
||||
|
||||
annotation class AnnotationArgument(val p: EAnno)
|
||||
|
||||
fun insideBody() {
|
||||
@EAnno fun local() {}
|
||||
}
|
||||
|
||||
fun inDefaultArgument(f: () -> Unit = @EAnno fun() {}) {}
|
||||
|
||||
val inProperty = @EAnno fun() {}
|
||||
|
||||
val inPropertyAccessor: () -> Unit
|
||||
get() = @EAnno fun() {}
|
||||
@@ -0,0 +1,30 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.Experimental
|
||||
// FILE: api.kt
|
||||
|
||||
package api
|
||||
|
||||
@Experimental(Experimental.Level.WARNING)
|
||||
annotation class ExperimentalAPI
|
||||
|
||||
interface I
|
||||
|
||||
@ExperimentalAPI
|
||||
class Impl : I
|
||||
|
||||
// FILE: usage.kt
|
||||
|
||||
package usage
|
||||
|
||||
import api.*
|
||||
|
||||
open class Base(val i: I)
|
||||
|
||||
@UseExperimental(ExperimentalAPI::class)
|
||||
class Derived : Base(Impl())
|
||||
|
||||
@UseExperimental(ExperimentalAPI::class)
|
||||
class Delegated : I by Impl()
|
||||
|
||||
@UseExperimental(ExperimentalAPI::class)
|
||||
val delegatedProperty by Impl()
|
||||
operator fun I.getValue(x: Any?, y: Any?) = null
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
// !DIAGNOSTICS: -NOTHING_TO_INLINE -UNUSED_PARAMETER
|
||||
// !USE_EXPERIMENTAL: kotlin.Experimental
|
||||
// FILE: api.kt
|
||||
|
||||
package api
|
||||
|
||||
@Experimental(Experimental.Level.WARNING)
|
||||
annotation class API
|
||||
|
||||
@API
|
||||
fun f() {}
|
||||
|
||||
// FILE: usage.kt
|
||||
|
||||
package usage
|
||||
|
||||
import api.*
|
||||
|
||||
fun use1() {
|
||||
f()
|
||||
}
|
||||
|
||||
val use2 = f()
|
||||
|
||||
// FILE: inline-usage.kt
|
||||
|
||||
package usage
|
||||
|
||||
import api.*
|
||||
|
||||
inline fun inlineUse1() {
|
||||
f()
|
||||
}
|
||||
|
||||
inline var inlineUse2: Unit
|
||||
get() {
|
||||
f()
|
||||
}
|
||||
set(value) {
|
||||
f()
|
||||
}
|
||||
|
||||
var inlineUse3: Unit
|
||||
inline get() {
|
||||
f()
|
||||
}
|
||||
@API
|
||||
inline set(value) {
|
||||
f()
|
||||
}
|
||||
|
||||
@API
|
||||
inline fun inlineUse4() {
|
||||
f()
|
||||
}
|
||||
|
||||
// FILE: private-inline-usage.kt
|
||||
|
||||
package usage
|
||||
|
||||
import api.*
|
||||
|
||||
private inline fun privateInline1() {
|
||||
f()
|
||||
}
|
||||
|
||||
internal inline fun privateInline2() {
|
||||
f()
|
||||
}
|
||||
|
||||
private inline var privateInline3: Unit
|
||||
get() {
|
||||
f()
|
||||
}
|
||||
set(value) {
|
||||
f()
|
||||
}
|
||||
|
||||
internal class InternalClass {
|
||||
inline fun privateInline4() {
|
||||
f()
|
||||
}
|
||||
}
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.Experimental
|
||||
// FILE: api.kt
|
||||
|
||||
package api
|
||||
|
||||
@Experimental(Experimental.Level.WARNING)
|
||||
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
|
||||
annotation class ExperimentalAPI
|
||||
|
||||
@ExperimentalAPI
|
||||
class C {
|
||||
fun function(): String = ""
|
||||
val property: String = ""
|
||||
class Nested
|
||||
inner class Inner
|
||||
}
|
||||
|
||||
@ExperimentalAPI
|
||||
fun C.extension() {}
|
||||
|
||||
// FILE: usage-propagate.kt
|
||||
|
||||
package usage1
|
||||
|
||||
import api.*
|
||||
|
||||
@ExperimentalAPI
|
||||
fun useAll() {
|
||||
val c: C = C()
|
||||
c.function()
|
||||
c.property
|
||||
C.Nested()
|
||||
c.Inner()
|
||||
c.extension()
|
||||
}
|
||||
|
||||
@ExperimentalAPI
|
||||
class Use {
|
||||
fun useAll(c: C) {
|
||||
c.function()
|
||||
c.property
|
||||
C.Nested()
|
||||
c.Inner()
|
||||
c.extension()
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: usage-use.kt
|
||||
|
||||
package usage2
|
||||
|
||||
import api.*
|
||||
|
||||
@UseExperimental(ExperimentalAPI::class)
|
||||
fun useAll() {
|
||||
val c: C = C()
|
||||
c.function()
|
||||
c.property
|
||||
C.Nested()
|
||||
c.Inner()
|
||||
c.extension()
|
||||
}
|
||||
|
||||
@UseExperimental(ExperimentalAPI::class)
|
||||
class Use {
|
||||
fun useAll(c: C) {
|
||||
c.function()
|
||||
c.property
|
||||
C.Nested()
|
||||
c.Inner()
|
||||
c.extension()
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: usage-none.kt
|
||||
|
||||
package usage3
|
||||
|
||||
import api.*
|
||||
|
||||
fun use() {
|
||||
val c: C = C()
|
||||
c.function()
|
||||
c.property
|
||||
C.Nested()
|
||||
c.Inner()
|
||||
c.extension()
|
||||
}
|
||||
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.Experimental
|
||||
// FILE: api.kt
|
||||
|
||||
package api
|
||||
|
||||
@Experimental(Experimental.Level.WARNING)
|
||||
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY)
|
||||
annotation class ExperimentalAPI
|
||||
|
||||
@ExperimentalAPI
|
||||
class C {
|
||||
@ExperimentalAPI
|
||||
fun function() {}
|
||||
|
||||
@ExperimentalAPI
|
||||
val property: String = ""
|
||||
|
||||
@ExperimentalAPI
|
||||
class Nested {
|
||||
@ExperimentalAPI
|
||||
fun nestedFunction() {}
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: usage.kt
|
||||
|
||||
package usage
|
||||
|
||||
import api.*
|
||||
|
||||
fun use() {
|
||||
val c: C = C()
|
||||
c.function()
|
||||
c.property
|
||||
C.Nested().nestedFunction()
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.Experimental
|
||||
// FILE: api.kt
|
||||
|
||||
package api
|
||||
|
||||
@Experimental(Experimental.Level.WARNING)
|
||||
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION)
|
||||
annotation class ExperimentalAPI
|
||||
|
||||
@ExperimentalAPI
|
||||
const val MEANING = 42
|
||||
|
||||
annotation class Anno(val value: Int)
|
||||
|
||||
// FILE: usage-propagate.kt
|
||||
|
||||
package usage1
|
||||
|
||||
import api.*
|
||||
|
||||
@ExperimentalAPI
|
||||
@Anno(MEANING)
|
||||
fun usage() {}
|
||||
|
||||
// FILE: usage-use.kt
|
||||
|
||||
@file:UseExperimental(ExperimentalAPI::class)
|
||||
package usage2
|
||||
|
||||
import api.*
|
||||
|
||||
// TODO: there should be no warning here
|
||||
@Anno(MEANING)
|
||||
fun usage() {}
|
||||
|
||||
// FILE: usage-none.kt
|
||||
|
||||
package usage3
|
||||
|
||||
import api.*
|
||||
|
||||
@Anno(MEANING)
|
||||
fun usage() {}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.Experimental
|
||||
// FILE: api.kt
|
||||
|
||||
package api
|
||||
|
||||
@Experimental(Experimental.Level.WARNING)
|
||||
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
|
||||
annotation class ExperimentalAPI
|
||||
|
||||
@ExperimentalAPI
|
||||
class C {
|
||||
class D {
|
||||
class E {
|
||||
class F
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: usage-propagate.kt
|
||||
|
||||
package usage1
|
||||
|
||||
import api.*
|
||||
|
||||
@ExperimentalAPI
|
||||
fun use1() {
|
||||
C.D.E.F()
|
||||
}
|
||||
|
||||
@ExperimentalAPI
|
||||
fun use2(f: C.D.E.F) = f.hashCode()
|
||||
|
||||
// FILE: usage-use.kt
|
||||
|
||||
package usage2
|
||||
|
||||
import api.*
|
||||
|
||||
@UseExperimental(ExperimentalAPI::class)
|
||||
fun use1() {
|
||||
C.D.E.F()
|
||||
}
|
||||
|
||||
@UseExperimental(ExperimentalAPI::class)
|
||||
fun use2(f: C.D.E.F) = f.hashCode()
|
||||
|
||||
// FILE: usage-none.kt
|
||||
|
||||
package usage3
|
||||
|
||||
import api.*
|
||||
|
||||
fun use1() {
|
||||
C.D.E.F()
|
||||
}
|
||||
|
||||
fun use2(f: C.D.E.F) = f.hashCode()
|
||||
@@ -0,0 +1,26 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.Experimental
|
||||
// FILE: api.kt
|
||||
|
||||
package api
|
||||
|
||||
@Experimental
|
||||
annotation class E
|
||||
|
||||
open class Base {
|
||||
@E
|
||||
open fun foo() {}
|
||||
}
|
||||
|
||||
// FILE: usage.kt
|
||||
|
||||
package usage
|
||||
|
||||
import api.*
|
||||
|
||||
class Derived : Base() {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
fun test(b: Base) {
|
||||
b.foo()
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// FILE: api.kt
|
||||
|
||||
@Experimental
|
||||
annotation class Marker
|
||||
|
||||
@Marker
|
||||
fun f() {}
|
||||
|
||||
// FILE: usage.kt
|
||||
|
||||
fun use1() {
|
||||
f()
|
||||
}
|
||||
|
||||
@Marker
|
||||
fun use2() {
|
||||
f()
|
||||
}
|
||||
|
||||
@UseExperimental(Marker::class)
|
||||
fun use3() {
|
||||
f()
|
||||
}
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.Experimental
|
||||
// !EXPERIMENTAL: api.ExperimentalAPI
|
||||
// MODULE: api
|
||||
// FILE: api.kt
|
||||
|
||||
package api
|
||||
|
||||
@Experimental
|
||||
annotation class ExperimentalAPI
|
||||
|
||||
@ExperimentalAPI
|
||||
fun function(): String = ""
|
||||
|
||||
// MODULE: usage(api)
|
||||
// FILE: usage.kt
|
||||
|
||||
package usage
|
||||
|
||||
import api.*
|
||||
|
||||
fun use() {
|
||||
function()
|
||||
}
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.Experimental
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION, -UNUSED_VARIABLE, -UNUSED_PARAMETER
|
||||
|
||||
fun test() {
|
||||
42u
|
||||
21UL
|
||||
val list = listOf(
|
||||
1u,
|
||||
0xFFu,
|
||||
0xbbU
|
||||
)
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>takeAll<!>(
|
||||
1u,
|
||||
2u,
|
||||
3u,
|
||||
4u,
|
||||
5u
|
||||
)
|
||||
|
||||
@UseExperimental(ExperimentalUnsignedTypes::class) 42u
|
||||
}
|
||||
|
||||
fun takeAll(
|
||||
b: UByte,
|
||||
s: UShort,
|
||||
i: UInt,
|
||||
l: ULong,
|
||||
vararg uints: UInt
|
||||
) {}
|
||||
|
||||
const val unsignedConst = 0u
|
||||
const val unsignedLongConst = 0uL
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.Experimental
|
||||
|
||||
package test.abc
|
||||
|
||||
@Experimental
|
||||
annotation class E
|
||||
|
||||
@UseExperimental(test.abc.E::class)
|
||||
fun f() {}
|
||||
|
||||
@test.abc.E
|
||||
fun g() {}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.Experimental
|
||||
// FILE: api.kt
|
||||
|
||||
package feature.experimental.self
|
||||
|
||||
@Experimental
|
||||
annotation class ImportedMarker
|
||||
|
||||
@ImportedMarker
|
||||
object ImportedClass {
|
||||
@ImportedMarker
|
||||
fun importedObjectMember() {}
|
||||
}
|
||||
|
||||
@ImportedMarker
|
||||
fun importedFunction() {}
|
||||
|
||||
@ImportedMarker
|
||||
val importedProperty = Unit
|
||||
|
||||
// FILE: usage.kt
|
||||
|
||||
import feature.experimental.self.ImportedMarker
|
||||
import feature.experimental.self.ImportedClass
|
||||
import feature.experimental.self.importedFunction
|
||||
import feature.experimental.self.importedProperty
|
||||
import feature.experimental.self.ImportedClass.importedObjectMember
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.Experimental
|
||||
// FILE: api.kt
|
||||
|
||||
package api
|
||||
|
||||
import kotlin.annotation.AnnotationTarget.*
|
||||
|
||||
@Experimental(Experimental.Level.WARNING)
|
||||
@Target(CLASS, ANNOTATION_CLASS, TYPE_PARAMETER, PROPERTY, FIELD, LOCAL_VARIABLE, VALUE_PARAMETER, CONSTRUCTOR, FUNCTION,
|
||||
PROPERTY_GETTER, PROPERTY_SETTER, TYPE, TYPEALIAS)
|
||||
annotation class E1
|
||||
|
||||
@Experimental(Experimental.Level.WARNING)
|
||||
@Target(FILE)
|
||||
annotation class E2
|
||||
|
||||
@Experimental(Experimental.Level.WARNING)
|
||||
@Target(EXPRESSION)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
annotation class E3
|
||||
|
||||
@Experimental(Experimental.Level.WARNING)
|
||||
@Target(FILE, EXPRESSION)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
annotation class E4
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.Experimental
|
||||
|
||||
annotation class NotAMarker
|
||||
|
||||
@UseExperimental
|
||||
fun f1() {}
|
||||
|
||||
@UseExperimental(NotAMarker::class)
|
||||
fun f2() {}
|
||||
@@ -0,0 +1,44 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.Experimental
|
||||
// FILE: api.kt
|
||||
|
||||
package api
|
||||
|
||||
@Experimental(Experimental.Level.WARNING)
|
||||
annotation class E
|
||||
|
||||
open class Base {
|
||||
@E
|
||||
open fun foo() {}
|
||||
}
|
||||
|
||||
class DerivedInSameModule : Base() {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
// FILE: usage-propagate.kt
|
||||
|
||||
package usage1
|
||||
|
||||
import api.*
|
||||
|
||||
open class Derived : Base() {
|
||||
@E
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
class SubDerived : Derived()
|
||||
|
||||
@E
|
||||
class Derived2 : Base() {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
// FILE: usage-none.kt
|
||||
|
||||
package usage2
|
||||
|
||||
import api.*
|
||||
|
||||
class Derived : Base() {
|
||||
override fun foo() {}
|
||||
}
|
||||
compiler/testData/diagnostics/testsWithStdLib/experimental/overrideDifferentExperimentalities.fir.kt
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.Experimental
|
||||
|
||||
@Experimental(Experimental.Level.WARNING)
|
||||
annotation class E1
|
||||
@Experimental(Experimental.Level.WARNING)
|
||||
annotation class E3
|
||||
|
||||
interface Base1 {
|
||||
@E1
|
||||
fun foo()
|
||||
}
|
||||
|
||||
interface Base2 {
|
||||
fun foo()
|
||||
}
|
||||
|
||||
interface Base3 {
|
||||
@E3
|
||||
fun foo()
|
||||
}
|
||||
|
||||
class DerivedA : Base1, Base2, Base3 {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
class DerivedB : Base1, Base3 {
|
||||
@E3
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
class DerivedC : Base1, Base2, Base3 {
|
||||
@E1
|
||||
@E3
|
||||
override fun foo() {}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.Experimental
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
// FILE: api.kt
|
||||
|
||||
package api
|
||||
|
||||
@Experimental(Experimental.Level.WARNING)
|
||||
@Target(AnnotationTarget.TYPE, AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.TYPEALIAS,
|
||||
AnnotationTarget.VALUE_PARAMETER)
|
||||
annotation class ExperimentalAPI
|
||||
|
||||
@ExperimentalAPI
|
||||
fun function(): String = ""
|
||||
|
||||
@ExperimentalAPI
|
||||
val property: String = ""
|
||||
|
||||
@ExperimentalAPI
|
||||
typealias Typealias = String
|
||||
|
||||
// FILE: usage-propagate.kt
|
||||
|
||||
package usage1
|
||||
|
||||
import api.*
|
||||
|
||||
@ExperimentalAPI
|
||||
fun useAll() {
|
||||
function()
|
||||
property
|
||||
val s: Typealias = ""
|
||||
}
|
||||
|
||||
@ExperimentalAPI
|
||||
class Use {
|
||||
fun useAll() {
|
||||
function()
|
||||
property
|
||||
val s: Typealias = ""
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: usage-use.kt
|
||||
|
||||
package usage2
|
||||
|
||||
import api.*
|
||||
|
||||
fun useAll() {
|
||||
@UseExperimental(ExperimentalAPI::class)
|
||||
<!UNRESOLVED_REFERENCE!>{
|
||||
function()
|
||||
property
|
||||
val s: Typealias = ""
|
||||
}()<!>
|
||||
}
|
||||
|
||||
@UseExperimental(ExperimentalAPI::class)
|
||||
class Use {
|
||||
fun useAll() {
|
||||
function()
|
||||
property
|
||||
val s: Typealias = ""
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: usage-none.kt
|
||||
|
||||
package usage3
|
||||
|
||||
import api.*
|
||||
|
||||
fun use() {
|
||||
function()
|
||||
property
|
||||
val s: Typealias = ""
|
||||
s.hashCode()
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.Experimental
|
||||
// FILE: api.kt
|
||||
|
||||
package api
|
||||
|
||||
@Experimental
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
annotation class ExperimentalAPI
|
||||
|
||||
@ExperimentalAPI
|
||||
class Foo
|
||||
|
||||
typealias Bar = Foo
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
// !LANGUAGE: +NestedClassesInAnnotations
|
||||
// !USE_EXPERIMENTAL: kotlin.Experimental
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// FILE: api.kt
|
||||
|
||||
package test
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
// Usages in import should be OK
|
||||
import kotlin.Experimental.Level.*
|
||||
import kotlin.Experimental.Level
|
||||
import kotlin.Experimental
|
||||
|
||||
// Usages with FQ names should be OK
|
||||
|
||||
@kotlin.Experimental(kotlin.Experimental.Level.ERROR)
|
||||
annotation class M
|
||||
|
||||
|
||||
// Usages as types should be errors
|
||||
|
||||
fun f1(e: Experimental) {}
|
||||
fun f2(u: UseExperimental?) {}
|
||||
|
||||
typealias Experimental0 = Experimental
|
||||
typealias UseExperimental0 = UseExperimental
|
||||
fun f3(e: Experimental0 /* TODO */) {}
|
||||
fun f4(u: UseExperimental0 /* TODO */) {}
|
||||
|
||||
|
||||
// Usages as ::class literals should be errors
|
||||
|
||||
annotation class VarargKClasses(vararg val k: KClass<*>)
|
||||
|
||||
@VarargKClasses(
|
||||
Experimental::class,
|
||||
UseExperimental::class,
|
||||
kotlin.Experimental::class,
|
||||
kotlin.UseExperimental::class
|
||||
)
|
||||
fun f5() {}
|
||||
|
||||
|
||||
// Usages of markers as types should be errors
|
||||
|
||||
@Experimental
|
||||
annotation class Marker {
|
||||
class NestedClass
|
||||
|
||||
companion object {
|
||||
const val value = 42
|
||||
}
|
||||
}
|
||||
|
||||
fun f6(m: Marker) {}
|
||||
fun f7(): List<Marker>? = null
|
||||
fun f8(): test.Marker? = null
|
||||
|
||||
typealias Marker0 = Marker
|
||||
|
||||
fun f9(m: Marker0) {}
|
||||
|
||||
|
||||
// Usages of markers as qualifiers are errors as well (we can lift this restriction for select cases)
|
||||
|
||||
fun f10(m: Marker.NestedClass) {
|
||||
Marker.value
|
||||
}
|
||||
|
||||
// FILE: usage-from-other-file.kt
|
||||
|
||||
// Usages of markers in import statements should be OK, but not as qualifiers to import their nested classes
|
||||
|
||||
import test.Marker
|
||||
import test.Marker.NestedClass
|
||||
import test.Marker.Companion
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.Experimental
|
||||
// FILE: api.kt
|
||||
|
||||
package api
|
||||
|
||||
@Experimental(Experimental.Level.WARNING)
|
||||
@Target(AnnotationTarget.FUNCTION)
|
||||
annotation class ExperimentalAPI1
|
||||
|
||||
@Experimental(Experimental.Level.WARNING)
|
||||
@Target(AnnotationTarget.FUNCTION)
|
||||
annotation class ExperimentalAPI2
|
||||
|
||||
@ExperimentalAPI1
|
||||
fun compilation() {}
|
||||
|
||||
@ExperimentalAPI2
|
||||
fun runtime() {}
|
||||
|
||||
// FILE: usage.kt
|
||||
|
||||
@file:UseExperimental(ExperimentalAPI1::class)
|
||||
package usage
|
||||
|
||||
import api.*
|
||||
|
||||
fun use() {
|
||||
compilation()
|
||||
runtime()
|
||||
}
|
||||
|
||||
class Use {
|
||||
fun use() {
|
||||
compilation()
|
||||
runtime()
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.Experimental
|
||||
// FILE: api.kt
|
||||
|
||||
package api
|
||||
|
||||
@Experimental(Experimental.Level.WARNING)
|
||||
annotation class ExperimentalAPI
|
||||
|
||||
@ExperimentalAPI
|
||||
@Experimental(Experimental.Level.WARNING)
|
||||
annotation class VeryExperimentalAPI
|
||||
|
||||
@ExperimentalAPI
|
||||
@VeryExperimentalAPI
|
||||
fun f() {}
|
||||
|
||||
@ExperimentalAPI
|
||||
fun g() {}
|
||||
|
||||
// FILE: usage.kt
|
||||
|
||||
@file:UseExperimental(ExperimentalAPI::class, VeryExperimentalAPI::class)
|
||||
package usage
|
||||
|
||||
import api.*
|
||||
|
||||
fun usage() {
|
||||
f()
|
||||
g()
|
||||
}
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.Experimental api.ExperimentalAPI
|
||||
// MODULE: api
|
||||
// FILE: api.kt
|
||||
|
||||
package api
|
||||
|
||||
@Experimental(Experimental.Level.ERROR)
|
||||
annotation class ExperimentalAPI
|
||||
|
||||
@ExperimentalAPI
|
||||
fun function(): String = ""
|
||||
|
||||
// MODULE: usage(api)
|
||||
// FILE: usage.kt
|
||||
|
||||
package usage
|
||||
|
||||
import api.*
|
||||
|
||||
fun use() {
|
||||
function()
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.Experimental
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// FILE: api.kt
|
||||
|
||||
package api
|
||||
|
||||
@Experimental(Experimental.Level.WARNING)
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
annotation class E
|
||||
|
||||
@E
|
||||
open class Foo(val s: String = "")
|
||||
|
||||
// FILE: usage.kt
|
||||
|
||||
import api.*
|
||||
|
||||
@UseExperimental(E::class)
|
||||
class Klass {
|
||||
init {
|
||||
Foo()
|
||||
}
|
||||
}
|
||||
|
||||
class Constructor {
|
||||
@UseExperimental(E::class) constructor() {
|
||||
Foo()
|
||||
}
|
||||
}
|
||||
|
||||
@UseExperimental(E::class)
|
||||
val property = Foo().s
|
||||
|
||||
@UseExperimental(E::class)
|
||||
fun function() {
|
||||
Foo()
|
||||
}
|
||||
|
||||
fun valueParameter(@UseExperimental(E::class) p: String = Foo().s): String {
|
||||
@UseExperimental(E::class)
|
||||
val localVariable: String = Foo().s
|
||||
return localVariable
|
||||
}
|
||||
|
||||
var propertyAccessors: String
|
||||
@UseExperimental(E::class)
|
||||
get() = Foo().s
|
||||
@UseExperimental(E::class)
|
||||
set(value) { Foo() }
|
||||
|
||||
fun expression(): String {
|
||||
val s = @UseExperimental(E::class) Foo().s
|
||||
return s
|
||||
}
|
||||
|
||||
@UseExperimental(E::class)
|
||||
typealias TypeAlias = Foo
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.Experimental
|
||||
// FILE: api.kt
|
||||
|
||||
package api
|
||||
|
||||
@Experimental(Experimental.Level.WARNING)
|
||||
@Target(AnnotationTarget.FUNCTION)
|
||||
annotation class E1
|
||||
|
||||
@Experimental(Experimental.Level.WARNING)
|
||||
@Target(AnnotationTarget.FUNCTION)
|
||||
annotation class E2
|
||||
|
||||
@Experimental(Experimental.Level.WARNING)
|
||||
@Target(AnnotationTarget.FUNCTION)
|
||||
annotation class E3
|
||||
|
||||
@E1
|
||||
fun e1() {}
|
||||
|
||||
@E2
|
||||
fun e2() {}
|
||||
|
||||
@E3
|
||||
fun e3() {}
|
||||
|
||||
// FILE: usage.kt
|
||||
|
||||
package usage
|
||||
|
||||
import api.*
|
||||
|
||||
@UseExperimental(E1::class, E2::class, E3::class)
|
||||
fun use1() {
|
||||
e1()
|
||||
e2()
|
||||
e3()
|
||||
}
|
||||
|
||||
@UseExperimental(E1::class, E3::class)
|
||||
fun use2() {
|
||||
e1()
|
||||
@UseExperimental(E2::class) e2()
|
||||
e3()
|
||||
}
|
||||
|
||||
@UseExperimental(E1::class, E2::class)
|
||||
fun use3() {
|
||||
e1()
|
||||
e2()
|
||||
e3()
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
// !API_VERSION: 1.2
|
||||
// !USE_EXPERIMENTAL: kotlin.Experimental
|
||||
// !DIAGNOSTICS: -INVISIBLE_MEMBER -INVISIBLE_REFERENCE -NEWER_VERSION_IN_SINCE_KOTLIN -UNUSED_PARAMETER
|
||||
|
||||
@SinceKotlin("1.3")
|
||||
fun newPublishedFun() {}
|
||||
|
||||
|
||||
@Experimental
|
||||
annotation class Marker
|
||||
|
||||
@SinceKotlin("1.3")
|
||||
@WasExperimental(Marker::class)
|
||||
fun newFunExperimentalInThePast() {}
|
||||
|
||||
@SinceKotlin("1.3")
|
||||
@WasExperimental(Marker::class)
|
||||
val newValExperimentalInThePast = ""
|
||||
|
||||
@SinceKotlin("1.3")
|
||||
@WasExperimental(Marker::class)
|
||||
class NewClassExperimentalInThePast
|
||||
|
||||
@SinceKotlin("1.3")
|
||||
@WasExperimental(Marker::class)
|
||||
typealias TypeAliasToNewClass = NewClassExperimentalInThePast
|
||||
|
||||
|
||||
fun use1(
|
||||
c1: NewClassExperimentalInThePast,
|
||||
t1: TypeAliasToNewClass
|
||||
) {
|
||||
newPublishedFun()
|
||||
newFunExperimentalInThePast()
|
||||
newValExperimentalInThePast
|
||||
NewClassExperimentalInThePast()
|
||||
}
|
||||
|
||||
@UseExperimental(Marker::class)
|
||||
fun use2(
|
||||
c2: NewClassExperimentalInThePast,
|
||||
t2: TypeAliasToNewClass
|
||||
) {
|
||||
newPublishedFun()
|
||||
newFunExperimentalInThePast()
|
||||
newValExperimentalInThePast
|
||||
NewClassExperimentalInThePast()
|
||||
}
|
||||
|
||||
@Marker
|
||||
fun use3(
|
||||
c3: NewClassExperimentalInThePast,
|
||||
t3: TypeAliasToNewClass
|
||||
) {
|
||||
newPublishedFun()
|
||||
newFunExperimentalInThePast()
|
||||
newValExperimentalInThePast
|
||||
NewClassExperimentalInThePast()
|
||||
}
|
||||
Reference in New Issue
Block a user