c7435ba760
We are going to deprecate `WITH_RUNTIME` directive. The main reason behind this change is that `WITH_STDLIB` directive better describes its meaning, specifically it will add kotlin stdlib to test's classpath.
32 lines
1011 B
Kotlin
Vendored
32 lines
1011 B
Kotlin
Vendored
// IGNORE_BACKEND: JVM
|
|
// IGNORE_BACKEND: WASM
|
|
// DONT_TARGET_EXACT_BACKEND: JS
|
|
|
|
// WITH_STDLIB
|
|
// !LANGUAGE: +InstantiationOfAnnotationClasses
|
|
|
|
import kotlin.reflect.KClass
|
|
|
|
annotation class Bar(val i:Int, val s: String, val f: Float)
|
|
|
|
annotation class Foo(
|
|
val int: Int,
|
|
val s: String,
|
|
val arr: Array<String>,
|
|
val arr2: IntArray,
|
|
val kClass: KClass<*>,
|
|
val bar: Bar
|
|
)
|
|
|
|
fun makeHC(name: String, value: Any) = (127 * name.hashCode()) xor value.hashCode()
|
|
|
|
fun box(): String {
|
|
val foo1 = Foo(42, "foo", arrayOf("a", "b"), intArrayOf(1,2), Bar::class, Bar(10, "bar", Float.NaN))
|
|
val foo2 = Foo(42, "foo", arrayOf("a", "b"), intArrayOf(1,2), Bar::class, Bar(10, "bar", Float.NaN))
|
|
if (foo1 != foo2) return "Failed equals ${foo1.toString()} ${foo2.toString()}"
|
|
val barlike = makeHC("i", 10) + makeHC("s", "bar") + makeHC("f", Float.NaN)
|
|
if (barlike != foo1.bar.hashCode()) return "Failed HC1"
|
|
if (barlike != foo2.bar.hashCode()) return "Failed HC2"
|
|
return "OK"
|
|
}
|