[K/N] Fix extracting local classes from lambda in cached inline function
^KT-52540
This commit is contained in:
+6
@@ -32263,6 +32263,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/objects/kt46136.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt52540.kt")
|
||||
public void testKt52540() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/objects/kt52540.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt535.kt")
|
||||
public void testKt535() throws Exception {
|
||||
|
||||
+1
-1
@@ -883,7 +883,7 @@ class LocalDeclarationsLowering(
|
||||
}
|
||||
|
||||
private fun collectLocalDeclarations() {
|
||||
val enclosingFile = container.file
|
||||
val enclosingFile by lazy { container.file }
|
||||
val enclosingClass = run {
|
||||
var currentParent = container as? IrClass ?: container.parent
|
||||
while (currentParent is IrDeclaration && currentParent !is IrClass) {
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// IGNORE_BACKEND: WASM
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
interface I {
|
||||
fun result(): String
|
||||
}
|
||||
|
||||
inline fun <T> foo(block: () -> T): T = block()
|
||||
|
||||
inline fun bar() = foo {
|
||||
object : I {
|
||||
override fun result() = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: box.kt
|
||||
fun box() = bar().result()
|
||||
+6
@@ -31759,6 +31759,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/objects/kt46136.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt52540.kt")
|
||||
public void testKt52540() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/objects/kt52540.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt535.kt")
|
||||
public void testKt535() throws Exception {
|
||||
|
||||
+6
@@ -32263,6 +32263,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/objects/kt46136.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt52540.kt")
|
||||
public void testKt52540() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/objects/kt52540.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt535.kt")
|
||||
public void testKt535() throws Exception {
|
||||
|
||||
+5
@@ -27042,6 +27042,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/objects/kt46136.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt52540.kt")
|
||||
public void testKt52540() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/objects/kt52540.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt535.kt")
|
||||
public void testKt535() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/objects/kt535.kt");
|
||||
|
||||
+6
@@ -23049,6 +23049,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/objects/kt46136.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt52540.kt")
|
||||
public void testKt52540() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/objects/kt52540.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt535.kt")
|
||||
public void testKt535() throws Exception {
|
||||
|
||||
+6
@@ -23013,6 +23013,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/objects/kt46136.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt52540.kt")
|
||||
public void testKt52540() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/objects/kt52540.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt535.kt")
|
||||
public void testKt535() throws Exception {
|
||||
|
||||
+5
@@ -20595,6 +20595,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
||||
runTest("compiler/testData/codegen/box/objects/kt46136.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt52540.kt")
|
||||
public void testKt52540() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/objects/kt52540.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt535.kt")
|
||||
public void testKt535() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/objects/kt535.kt");
|
||||
|
||||
+4
-4
@@ -832,10 +832,10 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
||||
|| body == null)
|
||||
return
|
||||
val isNotInlinedLambda = declaration.origin == IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA
|
||||
val file = ((declaration as? IrSimpleFunction)?.attributeOwnerId as? IrSimpleFunction)?.file.takeIf {
|
||||
it ?: return@takeIf false
|
||||
(currentCodeContext.fileScope() as FileScope).file != it && isNotInlinedLambda
|
||||
}
|
||||
val file = ((declaration as? IrSimpleFunction)?.attributeOwnerId as? IrSimpleFunction)
|
||||
.takeIf { isNotInlinedLambda }
|
||||
?.file
|
||||
.takeIf { (currentCodeContext.fileScope() as FileScope).file != it }
|
||||
val scope = file?.let {
|
||||
FileScope(it)
|
||||
}
|
||||
|
||||
+6
@@ -25812,6 +25812,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
|
||||
runTest("compiler/testData/codegen/box/objects/kt46136.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt52540.kt")
|
||||
public void testKt52540() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/objects/kt52540.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt535.kt")
|
||||
public void testKt535() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user