JVM_IR: fix wrong check in skipping captured vars
This commit is contained in:
+2
-1
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.backend.common.ir.ir2string
|
||||
import org.jetbrains.kotlin.backend.common.peek
|
||||
import org.jetbrains.kotlin.backend.common.pop
|
||||
import org.jetbrains.kotlin.backend.common.push
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.expressions.IrFunctionAccessExpression
|
||||
@@ -189,7 +190,7 @@ class ClosureAnnotator(irFile: IrFile) {
|
||||
|
||||
private fun processMemberAccess(declaration: IrDeclaration) {
|
||||
if (declaration.isLocal) {
|
||||
if (declaration is IrSimpleFunction && declaration.parent is IrClass) {
|
||||
if (declaration is IrSimpleFunction && declaration.visibility != Visibilities.LOCAL) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
class A {
|
||||
val result: String
|
||||
init {
|
||||
val flag = "OK"
|
||||
fun getFlag(): String = flag
|
||||
result = { getFlag() } ()
|
||||
}
|
||||
}
|
||||
fun box(): String = A().result
|
||||
+5
@@ -3966,6 +3966,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/closures/localClassLambdaClosure.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localFunInInit.kt")
|
||||
public void testLocalFunInInit() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/closures/localFunInInit.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localFunctionInFunction.kt")
|
||||
public void testLocalFunctionInFunction() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/closures/localFunctionInFunction.kt");
|
||||
|
||||
+5
@@ -3966,6 +3966,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/closures/localClassLambdaClosure.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localFunInInit.kt")
|
||||
public void testLocalFunInInit() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/closures/localFunInInit.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localFunctionInFunction.kt")
|
||||
public void testLocalFunctionInFunction() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/closures/localFunctionInFunction.kt");
|
||||
|
||||
+5
@@ -3946,6 +3946,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/closures/localClassLambdaClosure.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localFunInInit.kt")
|
||||
public void testLocalFunInInit() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/closures/localFunInInit.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localFunctionInFunction.kt")
|
||||
public void testLocalFunctionInFunction() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/closures/localFunctionInFunction.kt");
|
||||
|
||||
+5
@@ -3946,6 +3946,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/closures/localClassLambdaClosure.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localFunInInit.kt")
|
||||
public void testLocalFunInInit() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/closures/localFunInInit.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localFunctionInFunction.kt")
|
||||
public void testLocalFunctionInFunction() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/closures/localFunctionInFunction.kt");
|
||||
|
||||
Generated
+5
@@ -3291,6 +3291,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/closures/localClassLambdaClosure.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localFunInInit.kt")
|
||||
public void testLocalFunInInit() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/closures/localFunInInit.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localFunctionInFunction.kt")
|
||||
public void testLocalFunctionInFunction() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/closures/localFunctionInFunction.kt");
|
||||
|
||||
+5
@@ -3291,6 +3291,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/closures/localClassLambdaClosure.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localFunInInit.kt")
|
||||
public void testLocalFunInInit() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/closures/localFunInInit.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localFunctionInFunction.kt")
|
||||
public void testLocalFunctionInFunction() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/closures/localFunctionInFunction.kt");
|
||||
|
||||
Reference in New Issue
Block a user