KT-47475 Do not copy InnerClass attribute for WhenMapping classes
This commit is contained in:
committed by
teamcity
parent
38099e11c3
commit
d65775ca1a
@@ -83,6 +83,13 @@ class WhenMappingTransformer(
|
|||||||
methodNodes.add(this)
|
methodNodes.add(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun visitInnerClass(name: String?, outerName: String?, innerName: String?, access: Int) {
|
||||||
|
// Drop the attribute as the recreated class is not an inner class of the original outer class.
|
||||||
|
// In principle, we could also generate a new attribute with outerName set to the caller-side class,
|
||||||
|
// but that would require modification of both the inner (recreated) and the outer (caller-side) classes.
|
||||||
|
// The latter would require a lot of work without any clear benefits.
|
||||||
|
}
|
||||||
}, ClassReader.SKIP_FRAMES)
|
}, ClassReader.SKIP_FRAMES)
|
||||||
|
|
||||||
assert(methodNodes.size == 1) {
|
assert(methodNodes.size == 1) {
|
||||||
|
|||||||
+6
@@ -50275,6 +50275,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/when/kt47365.kt");
|
runTest("compiler/testData/codegen/box/when/kt47365.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt47475.kt")
|
||||||
|
public void testKt47475() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/when/kt47475.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt5307.kt")
|
@TestMetadata("kt5307.kt")
|
||||||
public void testKt5307() throws Exception {
|
public void testKt5307() throws Exception {
|
||||||
|
|||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
// CHECK_BYTECODE_TEXT
|
||||||
|
|
||||||
|
// MODULE: lib
|
||||||
|
// FILE: lib.kt
|
||||||
|
|
||||||
|
enum class SomeEnum{A, B}
|
||||||
|
|
||||||
|
inline fun inlineEnumWhen(someEnum: SomeEnum) = when(someEnum) {
|
||||||
|
SomeEnum.A -> "A"
|
||||||
|
else -> "not A"
|
||||||
|
}
|
||||||
|
|
||||||
|
// JVM_IR_TEMPLATES
|
||||||
|
// 2 INNERCLASS
|
||||||
|
|
||||||
|
// MODULE: caller(lib)
|
||||||
|
// FILE: caller.kt
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
inlineEnumWhen(SomeEnum.A)
|
||||||
|
val mappings = Class.forName("CallerKt\$box\$\$inlined\$inlineEnumWhen\$1\$wm\$LibKt\$WhenMappings")
|
||||||
|
return if (mappings.enclosingClass == null) "OK" else "FAIL"
|
||||||
|
}
|
||||||
|
|
||||||
|
// JVM_IR_TEMPLATES
|
||||||
|
// 0 INNERCLASS
|
||||||
+6
@@ -48739,6 +48739,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/when/kt47365.kt");
|
runTest("compiler/testData/codegen/box/when/kt47365.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt47475.kt")
|
||||||
|
public void testKt47475() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/when/kt47475.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt5307.kt")
|
@TestMetadata("kt5307.kt")
|
||||||
public void testKt5307() throws Exception {
|
public void testKt5307() throws Exception {
|
||||||
|
|||||||
+6
@@ -50275,6 +50275,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/when/kt47365.kt");
|
runTest("compiler/testData/codegen/box/when/kt47365.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt47475.kt")
|
||||||
|
public void testKt47475() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/when/kt47475.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt5307.kt")
|
@TestMetadata("kt5307.kt")
|
||||||
public void testKt5307() throws Exception {
|
public void testKt5307() throws Exception {
|
||||||
|
|||||||
+5
@@ -39608,6 +39608,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/when/kt47365.kt");
|
runTest("compiler/testData/codegen/box/when/kt47365.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt47475.kt")
|
||||||
|
public void testKt47475() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/when/kt47475.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt5307.kt")
|
@TestMetadata("kt5307.kt")
|
||||||
public void testKt5307() throws Exception {
|
public void testKt5307() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/when/kt5307.kt");
|
runTest("compiler/testData/codegen/box/when/kt5307.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user