Files
kotlin-fork/compiler/testData/codegen/box/javaFieldAndKotlinProperty/javaFieldAndKotlinInvisibleProperty.kt
T
Alexander Udalov 4ad594a3cd Minor, move tests about Java field and Kotlin property
Because the `fieldRename` directory was originally about cases when
private fields are renamed because of clashes.
2023-02-23 12:54:00 +01:00

29 lines
594 B
Kotlin
Vendored

// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_K1: JVM_IR
// IGNORE_BACKEND_K2: JVM_IR
// tried to access field Derived.a from class DerivedKt
// FILE: BaseJava.java
public class BaseJava {
public String a = "OK";
public String foo() {
return a;
}
}
// FILE: Derived.kt
class Derived : BaseJava() {
private val a = "FAIL"
}
fun box(): String {
val first = Derived().a
if (first != "OK") return first
val d = Derived()
if (d::a.get() != "OK") return d::a.get()
d.a = "12"
if (d.foo() != "12") return "Error writing: ${d.foo()}"
return "OK"
}