FIR2IR: fix dispatch receiver generation (non-function case)
This commit is contained in:
@@ -128,6 +128,18 @@ class Fir2IrVisitor(
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun lastDispatchReceiverParameter(): IrValueParameter? {
|
||||||
|
val dispatchReceiver = functionStack.lastOrNull()?.dispatchReceiverParameter
|
||||||
|
return if (dispatchReceiver != null) {
|
||||||
|
// Use the dispatch receiver of the containing function
|
||||||
|
dispatchReceiver
|
||||||
|
} else {
|
||||||
|
val lastClassSymbol = classStack.lastOrNull()?.symbol
|
||||||
|
// Use the dispatch receiver of the containing class
|
||||||
|
lastClassSymbol?.owner?.thisReceiver
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private val subjectVariableStack = mutableListOf<IrVariable>()
|
private val subjectVariableStack = mutableListOf<IrVariable>()
|
||||||
|
|
||||||
private fun <T> IrVariable?.withSubject(f: () -> T): T {
|
private fun <T> IrVariable?.withSubject(f: () -> T): T {
|
||||||
@@ -708,9 +720,8 @@ class Fir2IrVisitor(
|
|||||||
return typeRef.convertWithOffsets { startOffset, endOffset ->
|
return typeRef.convertWithOffsets { startOffset, endOffset ->
|
||||||
if (calleeReference is FirSuperReference) {
|
if (calleeReference is FirSuperReference) {
|
||||||
if (typeRef !is FirComposedSuperTypeRef) {
|
if (typeRef !is FirComposedSuperTypeRef) {
|
||||||
val dispatchReceiver = functionStack.lastOrNull()?.dispatchReceiverParameter
|
val dispatchReceiver = lastDispatchReceiverParameter()
|
||||||
if (dispatchReceiver != null) {
|
if (dispatchReceiver != null) {
|
||||||
// Use the dispatch receiver of the containing function
|
|
||||||
return@convertWithOffsets IrGetValueImpl(startOffset, endOffset, dispatchReceiver.type, dispatchReceiver.symbol)
|
return@convertWithOffsets IrGetValueImpl(startOffset, endOffset, dispatchReceiver.type, dispatchReceiver.symbol)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -912,9 +923,8 @@ class Fir2IrVisitor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val dispatchReceiver = this.functionStack.lastOrNull()?.dispatchReceiverParameter
|
val dispatchReceiver = lastDispatchReceiverParameter()
|
||||||
if (dispatchReceiver != null) {
|
if (dispatchReceiver != null) {
|
||||||
// Use the dispatch receiver of the containing function
|
|
||||||
return thisReceiverExpression.convertWithOffsets { startOffset, endOffset ->
|
return thisReceiverExpression.convertWithOffsets { startOffset, endOffset ->
|
||||||
IrGetValueImpl(startOffset, endOffset, dispatchReceiver.type, dispatchReceiver.symbol)
|
IrGetValueImpl(startOffset, endOffset, dispatchReceiver.type, dispatchReceiver.symbol)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
open class A {
|
open class A {
|
||||||
open val foo: String = "OK"
|
open val foo: String = "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
open class A {
|
open class A {
|
||||||
internal open val field = "F"
|
internal open val field = "F"
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
open class A {
|
open class A {
|
||||||
internal open val field = "F"
|
internal open val field = "F"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user