Fix this remapping in inner class constructors

Inner class constructors should use the argument instead of reading
outer `this` from a field because if such an access happens before a
delegating constructor call, e.g. when evaluating an argument, a JVM
bytecode validation error will be thrown. (The only operation on `this`
allowed before a delegating constructor call is SETFIELD, and only if
the field in question is declared in the same class.)
This commit is contained in:
pyos
2019-03-15 10:51:48 +01:00
committed by max-kammerer
parent 7e8db4cc4a
commit 82ccf81da8
27 changed files with 35 additions and 45 deletions
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
// TARGET_BACKEND: JVM
// FILE: JavaClass.java
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
open class A1(y: String) {
val x = "A1.x,$y"
}
@@ -45,4 +44,4 @@ fun box(): String {
if (r2 != "A1.x,B1.param,q;A3.x,B2.param,w;A1.x,B1.param,B3.param,e;A3.x,d") return "fail2: $r2"
return "OK"
}
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
open class A(val s: String) {
open inner class B(s: String): A(s)
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
open class Father(val param: String) {
abstract inner class InClass {
fun work(): String {
@@ -15,4 +14,4 @@ open class Father(val param: String) {
fun box(): String {
return Father("fail").Child("OK").Child2().work()
}
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
open class Father(val param: String) {
abstract inner class InClass {
fun work(): String {
@@ -15,4 +14,4 @@ open class Father(val param: String) {
fun box(): String {
return Father("fail").Child("OK").Child2().work()
}
}