JVM_IR KT-46578 resolve fake overrides for fields

This commit is contained in:
Dmitry Petrov
2021-05-11 16:23:54 +03:00
committed by teamcityserver
parent a255f44d6e
commit d1322280dd
15 changed files with 413 additions and 8 deletions
@@ -0,0 +1,26 @@
// TARGET_BACKEND: JVM
// WITH_RUNTIME
// FILE: kt46578_anonObject.kt
import p.*
class Derived : Base() {
init {
javaProtectedField = "OK"
}
val anonObject = object {
override fun toString(): String =
javaProtectedField
}
}
fun box(): String {
return Derived().anonObject.toString()
}
// FILE: p/Base.java
package p;
public class Base {
protected String javaProtectedField;
}
@@ -0,0 +1,24 @@
// TARGET_BACKEND: JVM
// WITH_RUNTIME
// IGNORE_BACKEND_FIR: JVM_IR
// ^ ::jpf is incorrectly represented as a reference to Base::jpf (should be: reference to fake override in Derived)
// FILE: kt46578_delegated.kt
import p.*
class Derived : Base() {
var delegated by ::jpf
}
fun box(): String {
val d = Derived()
d.delegated = "OK"
return d.delegated
}
// FILE: p/Base.java
package p;
public class Base {
protected String jpf;
}
@@ -0,0 +1,23 @@
// TARGET_BACKEND: JVM
// WITH_RUNTIME
// FILE: kt46578_kotlin_delegated.kt
import p.*
class Derived : Base() {
init {
pf = "OK"
}
val delegated by ::pf
}
fun box(): String {
return Derived().delegated
}
// FILE: p/Base.kt
package p
open class Base {
protected var pf = ""
}
@@ -0,0 +1,23 @@
// TARGET_BACKEND: JVM
// WITH_RUNTIME
// FILE: kt46578_kotlin_propertyRef.kt
import p.*
class Derived : Base() {
init {
pf = "OK"
}
val ref = ::pf
}
fun box(): String {
return Derived().ref.get()
}
// FILE: p/Base.kt
package p
open class Base {
protected var pf = ""
}
@@ -0,0 +1,23 @@
// TARGET_BACKEND: JVM
// WITH_RUNTIME
// FILE: kt46578_lambda.kt
import p.*
class Derived : Base() {
init {
jpf = "OK"
}
val lambda = { jpf }
}
fun box(): String {
return Derived().lambda()
}
// FILE: p/Base.java
package p;
public class Base {
protected String jpf;
}
@@ -0,0 +1,25 @@
// TARGET_BACKEND: JVM
// WITH_RUNTIME
// IGNORE_BACKEND_FIR: JVM_IR
// ^ ::jpf is incorrectly represented as a reference to Base::jpf (should be: reference to fake override in Derived)
// FILE: kt46578_propertyRef.kt
import p.*
class Derived : Base() {
init {
jpf = "OK"
}
val ref = ::jpf
}
fun box(): String {
return Derived().ref.get()
}
// FILE: p/Base.java
package p;
public class Base {
protected String jpf;
}