FIR2IR: correct dispatch receiver inside inner class constructor

This commit is contained in:
Jinseong Jeon
2020-10-01 23:53:04 -07:00
committed by Mikhail Glukhikh
parent aa488eabc9
commit 380226cba0
3 changed files with 5 additions and 2 deletions
@@ -118,6 +118,11 @@ class Fir2IrConversionScope {
fun dispatchReceiverParameter(irClass: IrClass): IrValueParameter? {
for (function in functionStack.asReversed()) {
if (function.parentClassOrNull == irClass) {
// An inner class's constructor needs an instance of the outer class as a dispatch receiver.
// However, if we are converting `this` receiver inside that constructor, now we should point to the inner class instance.
if (function is IrConstructor && irClass.isInner) {
irClass.thisReceiver?.let { return it }
}
function.dispatchReceiverParameter?.let { return it }
}
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class Outer {
val outerProp: String
constructor(x: String) {
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class Outer {
val outerProp: String
constructor(x: String) {