Files
kotlin-fork/compiler/testData/codegen/box/ieee754/kt48648_genericField.kt
T
Alexander Udalov 357f3184bf JVM IR: fix the type of IrGetField
The `irGetField` utility uses the field's own type as the type of the
resulting expression. But the field's type does not make sense outside
of the place of declaration of the field if it references a generic type
parameter of the containing class. Using this non-sensical generic type
led, for example, to an error in Ieee754 intrinsic (KT-48648).

The type of the expression should be kept as is in
JvmPropertiesLowering, i.e. taken from `expression` which the lowering
is replacing with the field access.

 #KT-48648 Fixed
2021-10-12 23:35:17 +02:00

22 lines
348 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
// WITH_RUNTIME
class V1<T : Number>(y: T) {
@JvmField
var x: T = y
}
class V2<T : Number> {
lateinit var x: T
}
fun check(a: V1<Float>, b: V2<Float>): Boolean =
a.x != b.x
fun box(): String {
val v1 = V1(1.0f)
val v2 = V2<Float>()
v2.x = 2.0f
return if (check(v1, v2)) "OK" else "Fail"
}