Use proper KotlinType in get/set methods for property reference

This commit is contained in:
Dmitry Petrov
2018-08-20 15:11:33 +03:00
parent 6cd91e43bb
commit 7d4dfc87b1
10 changed files with 201 additions and 2 deletions
+25
View File
@@ -0,0 +1,25 @@
// !LANGUAGE: +InlineClasses
// IGNORE_BACKEND: JVM_IR
// WITH_RUNTIME
import kotlin.reflect.KMutableProperty0
import kotlin.reflect.KProperty
operator fun <R> KMutableProperty0<R>.setValue(host: Any?, property: KProperty<*>, value: R) = set(value)
operator fun <R> KMutableProperty0<R>.getValue(host: Any?, property: KProperty<*>): R = get()
inline class Foo(val i: Int)
var f = Foo(4)
fun modify(ref: KMutableProperty0<Foo>) {
var a by ref
a = Foo(1)
}
fun box(): String {
modify(::f)
if (f.i != 1) throw AssertionError()
return "OK"
}