Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/experimental/topLevel.kt
T
Alexander Udalov c57864e46c Require "-Xuse-experimental=kotlin.Experimental" on usages of Experimental
Since we're not yet sure of the design of Experimental/UseExperimental,
we're making them "experimental" themselves in some sense, in that the
user is required to provide the magic argument
"-Xuse-experimental=kotlin.Experimental" to be allowed to use either
Experimental or UseExperimental. This is more convenient than the
previous approach of "-language-version 1.3
-Xskip-metadata-version-check" because it's simpler and does not cause
pre-release binaries to be produced
2018-05-04 13:48:24 +02:00

79 lines
1.3 KiB
Kotlin
Vendored

// !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)
{
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() {
<!EXPERIMENTAL_API_USAGE!>function<!>()
<!EXPERIMENTAL_API_USAGE!>property<!>
val s: <!EXPERIMENTAL_API_USAGE!>Typealias<!> = ""
s.hashCode()
}