Files
kotlin-fork/compiler/testData/codegen/box/fir/callableReferenceToJavaField.kt
T
Pavel Kunyavskiy cd409abfd8 [Fir2IR] Fix dispatch receiver of fake override lazy function
After the fix, it's at least consistent with what generated
for other fake overrides.

^KT-61386
2023-09-21 13:09:32 +00:00

42 lines
704 B
Kotlin
Vendored

// TARGET_BACKEND: JVM_IR
// DUMP_IR
// FULL_JDK
// WITH_REFLECT
// FILE: bar/Base.java
package bar;
import foo.A;
public abstract class Base {
protected A a = new A("fail");
protected void foo() {}
}
// FILE: main.kt
package foo
import kotlin.reflect.jvm.javaField
import bar.Base
class A(val s: String)
class Derived : Base() {
override fun foo() {
// ir: resolved to fake-override field Derived.a in K1,
// but to base field Base.a in K2
// However, box() works correctly in both cases
(Derived::a).javaField!![this] = A("OK")
}
fun box(): String {
foo()
return a.s
}
}
fun box(): String {
return Derived().box()
}