IR: skip script inner classes in LDL
#KT-49012 fixed
This commit is contained in:
+4
@@ -953,6 +953,8 @@ class LocalDeclarationsLowering(
|
|||||||
super.visitConstructor(declaration, data)
|
super.visitConstructor(declaration, data)
|
||||||
|
|
||||||
if (!isScriptMode && !declaration.constructedClass.isLocalNotInner()) return
|
if (!isScriptMode && !declaration.constructedClass.isLocalNotInner()) return
|
||||||
|
// Inner classes in scripts are handled properly in the InnerClassesLowering
|
||||||
|
if (isScriptMode && declaration.constructedClass.isInner) return
|
||||||
// LDL doesn't work on the enums because local enums are not allowed, so skipping them in scripts too
|
// LDL doesn't work on the enums because local enums are not allowed, so skipping them in scripts too
|
||||||
if (isScriptMode && declaration.constructedClass.kind == ClassKind.ENUM_CLASS) return
|
if (isScriptMode && declaration.constructedClass.kind == ClassKind.ENUM_CLASS) return
|
||||||
|
|
||||||
@@ -964,6 +966,8 @@ class LocalDeclarationsLowering(
|
|||||||
super.visitClass(declaration, data.withCurrentClass(declaration))
|
super.visitClass(declaration, data.withCurrentClass(declaration))
|
||||||
|
|
||||||
if (!isScriptMode && !declaration.isLocalNotInner()) return
|
if (!isScriptMode && !declaration.isLocalNotInner()) return
|
||||||
|
// Inner classes in scripts are handled properly in the InnerClassesLowering
|
||||||
|
if (isScriptMode && declaration.isInner) return
|
||||||
// LDL doesn't work on the enums because local enums are not allowed, so skipping them in scripts too
|
// LDL doesn't work on the enums because local enums are not allowed, so skipping them in scripts too
|
||||||
if (isScriptMode && declaration.kind == ClassKind.ENUM_CLASS) return
|
if (isScriptMode && declaration.kind == ClassKind.ENUM_CLASS) return
|
||||||
|
|
||||||
|
|||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
val b = "K"
|
||||||
|
|
||||||
|
inner class InnerClass(val s: String) {
|
||||||
|
fun test1() = s + b
|
||||||
|
|
||||||
|
inner class C1 {
|
||||||
|
fun bar(c: String) = s + b + c
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test2() = C1().bar("!")
|
||||||
|
|
||||||
|
inner class C2 {
|
||||||
|
fun bar(c: String) = s + b + c
|
||||||
|
|
||||||
|
fun test(): String {
|
||||||
|
var c = "?"
|
||||||
|
return object {
|
||||||
|
fun run() = s + b + c
|
||||||
|
}.run()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test3() = C2().test()
|
||||||
|
}
|
||||||
|
|
||||||
|
val rv = InnerClass("O").test1() + InnerClass("_O").test2() + InnerClass("__O").test3()
|
||||||
|
|
||||||
|
// expected: rv: OK_OK!__OK?
|
||||||
+5
@@ -64,6 +64,11 @@ public class ScriptCodegenTestGenerated extends AbstractScriptCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/script/inline.kts");
|
runTest("compiler/testData/codegen/script/inline.kts");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("innerClass.kts")
|
||||||
|
public void testInnerClass() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/script/innerClass.kts");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt20707.kts")
|
@TestMetadata("kt20707.kts")
|
||||||
public void testKt20707() throws Exception {
|
public void testKt20707() throws Exception {
|
||||||
runTest("compiler/testData/codegen/script/kt20707.kts");
|
runTest("compiler/testData/codegen/script/kt20707.kts");
|
||||||
|
|||||||
+5
@@ -65,6 +65,11 @@ public class IrScriptCodegenTestGenerated extends AbstractIrScriptCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/script/inline.kts");
|
runTest("compiler/testData/codegen/script/inline.kts");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("innerClass.kts")
|
||||||
|
public void testInnerClass() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/script/innerClass.kts");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt20707.kts")
|
@TestMetadata("kt20707.kts")
|
||||||
public void testKt20707() throws Exception {
|
public void testKt20707() throws Exception {
|
||||||
runTest("compiler/testData/codegen/script/kt20707.kts");
|
runTest("compiler/testData/codegen/script/kt20707.kts");
|
||||||
|
|||||||
Reference in New Issue
Block a user