Files
kotlin-fork/compiler/testData/codegen/box/collectionLiterals/collectionLiteralsWithVarargs.kt
T
Alexander Udalov 5b58eb8491 Remove LANGUAGE_VERSION from non-coroutine codegen tests
Most of these tests used this directive as a way to opt in to a new
language feature, and most of those features are already stable for a
long time, so no opt-in is needed. Some other tests used the directive
to opt out from a language feature, replace those by the `LANGUAGE`
directive. One test used the directive to test behavior that actually
depended on the API version; use `API_VERSION` directive there instead.
2018-12-20 12:53:23 +01:00

42 lines
930 B
Kotlin
Vendored

// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND: JS_IR
// WITH_REFLECT
// IGNORE_BACKEND: JS
// IGNORE_BACKEND: NATIVE
import java.util.Arrays
import kotlin.reflect.KClass
import kotlin.reflect.KFunction0
inline fun <reified T> test(kFunction: KFunction0<Unit>, test: T.() -> Unit) {
val annotation = kFunction.annotations.single() as T
annotation.test()
}
fun check(b: Boolean, message: String) {
if (!b) throw RuntimeException(message)
}
annotation class Foo(vararg val a: String = ["a", "b"])
annotation class Bar(vararg val a: KClass<*> = [Int::class])
@Foo(*["/"])
fun test1() {}
@Bar(*[Long::class, String::class])
fun test2() {}
fun box(): String {
test<Foo>(::test1) {
check(a.contentEquals(arrayOf("/")), "Fail 1: ${a.joinToString()}")
}
test<Bar>(::test2) {
check(a.contentEquals(arrayOf(Long::class, String::class)), "Fail 2: ${a.joinToString()}")
}
return "OK"
}