Files
kotlin-fork/js/js.translator/testData/box/callableReference/property/delegated.kt
T
Alexey Andreev 3b3fd0fa0d JS: fix DCE limits in test data to fit new kotlin.js size
The size has increased due to new implementation of KClass
2017-10-06 18:16:51 +03:00

29 lines
619 B
Kotlin
Vendored

// EXPECTED_REACHABLE_NODES: 1126
// This test was adapted from compiler/testData/codegen/box/callableReference/property/.
package foo
import kotlin.reflect.KProperty
object NumberDecrypter {
operator fun getValue(instance: Any?, data: KProperty<*>) = when (data.name) {
"four" -> 4
"two" -> 2
else -> throw Exception()
}
}
val four: Int by NumberDecrypter
class A {
val two: Int by NumberDecrypter
}
fun box(): String {
val x = ::four.get()
if (x != 4) return "Fail x: $x"
val a = A()
val y = A::two.get(a)
if (y != 2) return "Fail y: $y"
return "OK"
}