FIR2IR: correct dispatch receiver inside inner class constructor
This commit is contained in:
committed by
Mikhail Glukhikh
parent
aa488eabc9
commit
380226cba0
@@ -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
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
class Outer {
|
||||
val outerProp: String
|
||||
constructor(x: String) {
|
||||
|
||||
Reference in New Issue
Block a user