Files
kotlin-fork/compiler/testData/codegen/box/properties/primitiveOverrideDelegateAccessor.kt
T
Alexander Udalov 7041a10ecf Fix VerifyError on primitive override properties
Don't just blindly map property type in PropertyCodegen when generating getter:
we already have its full signature, so we can just as well take the type from
it. The former also isn't correct for properties which are overrides with a
primitive type. Simple mapType is safe for setter though, because the type of a
method parameter cannot change with override on JVM

The change in StackValue relates to call sites of properties which return Unit:
in that case StackValue's this.type is V, whereas the return type of its getter
is Ljet/Unit; -- so coerceTo was coercing from the wrong type in case of getter
calls

 #KT-4373 Fixed
 #KT-4383 Fixed
2014-01-14 17:52:27 +04:00

19 lines
411 B
Kotlin

class Holder(var value: Int) {
fun get(that: Any?, desc: PropertyMetadata) = value
fun set(that: Any?, desc: PropertyMetadata, newValue: Int) { value = newValue }
}
trait R<in T: Comparable<T>> {
var value: T
}
class A(start: Int) : R<Int> {
override var value: Int by Holder(start)
}
fun box(): String {
val a = A(239)
a.value = 42
return if (a.value == 42) "OK" else "Fail 1"
}