FIR: consider all functions in scope when computing dispatch receiver parameter.
This commit is contained in:
committed by
Mikhail Glukhikh
parent
de0c9a5c73
commit
acbe3126b1
@@ -77,17 +77,14 @@ class Fir2IrConversionScope {
|
||||
fun parent(): IrDeclarationParent? = parentStack.lastOrNull()
|
||||
|
||||
fun lastDispatchReceiverParameter(): IrValueParameter? {
|
||||
var dispatchReceiver = functionStack.lastOrNull()?.dispatchReceiverParameter
|
||||
// Use the dispatch receiver of the containing function
|
||||
dispatchReceiver?.let { return it }
|
||||
|
||||
// Use the dispatch receiver of the enclosing function if any
|
||||
dispatchReceiver = functionStack.elementAtOrNull(functionStack.size - 2)?.dispatchReceiverParameter
|
||||
dispatchReceiver?.let { return it }
|
||||
// Use the dispatch receiver of the containing/enclosing functions (from the last to the first)
|
||||
for (function in functionStack.asReversed()) {
|
||||
function.dispatchReceiverParameter?.let { return it }
|
||||
}
|
||||
|
||||
// Use the dispatch receiver of the containing class
|
||||
val lastClassSymbol = classStack.lastOrNull()?.symbol
|
||||
return lastClassSymbol?.owner?.thisReceiver
|
||||
val lastClass = classStack.lastOrNull()
|
||||
return lastClass?.thisReceiver
|
||||
}
|
||||
|
||||
fun lastClass(): IrClass? = classStack.lastOrNull()
|
||||
|
||||
Generated
+10
@@ -18285,6 +18285,16 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/properties/classFieldInsideNested.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("classFieldInsideNestedLambda.kt")
|
||||
public void testClassFieldInsideNestedLambda() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/properties/classFieldInsideNestedLambda.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("classFieldInsideNestedNestedLambda.kt")
|
||||
public void testClassFieldInsideNestedNestedLambda() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/properties/classFieldInsideNestedNestedLambda.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("classObjectProperties.kt")
|
||||
public void testClassObjectProperties() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/properties/classObjectProperties.kt");
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
class My {
|
||||
val my: String = "O"
|
||||
get() = { { field }() }() + "K"
|
||||
}
|
||||
|
||||
fun box() = My().my
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class My {
|
||||
val my: String = "O"
|
||||
get() = { { { field }() }() }() + "K"
|
||||
}
|
||||
|
||||
fun box() = My().my
|
||||
+10
@@ -19806,6 +19806,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/properties/classFieldInsideNested.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("classFieldInsideNestedLambda.kt")
|
||||
public void testClassFieldInsideNestedLambda() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/properties/classFieldInsideNestedLambda.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("classFieldInsideNestedNestedLambda.kt")
|
||||
public void testClassFieldInsideNestedNestedLambda() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/properties/classFieldInsideNestedNestedLambda.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("classObjectProperties.kt")
|
||||
public void testClassObjectProperties() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/properties/classObjectProperties.kt");
|
||||
|
||||
+10
@@ -18285,6 +18285,16 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/properties/classFieldInsideNested.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("classFieldInsideNestedLambda.kt")
|
||||
public void testClassFieldInsideNestedLambda() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/properties/classFieldInsideNestedLambda.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("classFieldInsideNestedNestedLambda.kt")
|
||||
public void testClassFieldInsideNestedNestedLambda() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/properties/classFieldInsideNestedNestedLambda.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("classObjectProperties.kt")
|
||||
public void testClassObjectProperties() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/properties/classObjectProperties.kt");
|
||||
|
||||
Reference in New Issue
Block a user