JVM_IR KT-46597 fix receiver type for inlined callable reference

Receiver type is used by SyntheticAccessorLowering to determine class in
which a synthetic accessor should be generated.
This commit is contained in:
Dmitry Petrov
2021-05-17 15:56:41 +03:00
committed by TeamCityServer
parent 80ce3a5cf8
commit 3a0e3798ec
23 changed files with 612 additions and 60 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;
}