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
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
// 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"
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
// !LANGUAGE: -ProhibitJvmFieldOnOverrideFromInterfaceInPrimaryConstructor
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// ^ generates 'GETFIELD B.x : I' instead of 'GETFIELD BB.x : I'
|
||||
// WITH_RUNTIME
|
||||
|
||||
interface A { val x: Int }
|
||||
|
||||
Reference in New Issue
Block a user