KT-62584 Fix generation of type arguments for local classes

Merge-request: KT-MR-13684
Merged-by: Pavel Mikhailovskii <Pavel.Mikhailovskii@jetbrains.com>
This commit is contained in:
strangepleasures
2024-01-10 14:20:09 +00:00
committed by Space Team
parent b645997dc4
commit bb8ff9e299
16 changed files with 114 additions and 31 deletions
@@ -28406,6 +28406,12 @@ public class LLFirBlackBoxCodegenBasedTestGenerated extends AbstractLLFirBlackBo
runTest("compiler/testData/codegen/box/innerNested/kt5363.kt");
}
@Test
@TestMetadata("kt62584.kt")
public void testKt62584() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/kt62584.kt");
}
@Test
@TestMetadata("kt63732.kt")
public void testKt63732() throws Exception {
@@ -28406,6 +28406,12 @@ public class LLFirReversedBlackBoxCodegenBasedTestGenerated extends AbstractLLFi
runTest("compiler/testData/codegen/box/innerNested/kt5363.kt");
}
@Test
@TestMetadata("kt62584.kt")
public void testKt62584() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/kt62584.kt");
}
@Test
@TestMetadata("kt63732.kt")
public void testKt63732() throws Exception {
@@ -28063,6 +28063,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
runTest("compiler/testData/codegen/box/innerNested/kt5363.kt");
}
@Test
@TestMetadata("kt62584.kt")
public void testKt62584() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/kt62584.kt");
}
@Test
@TestMetadata("kt63732.kt")
public void testKt63732() throws Exception {
@@ -28063,6 +28063,12 @@ public class FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated
runTest("compiler/testData/codegen/box/innerNested/kt5363.kt");
}
@Test
@TestMetadata("kt62584.kt")
public void testKt62584() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/kt62584.kt");
}
@Test
@TestMetadata("kt63732.kt")
public void testKt63732() throws Exception {
@@ -28063,6 +28063,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
runTest("compiler/testData/codegen/box/innerNested/kt5363.kt");
}
@Test
@TestMetadata("kt62584.kt")
public void testKt62584() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/kt62584.kt");
}
@Test
@TestMetadata("kt63732.kt")
public void testKt63732() throws Exception {
@@ -72,7 +72,7 @@ private fun IrSimpleType.buildPossiblyInnerType(classifier: IrClass?, index: Int
"${arguments.size - toIndex} trailing arguments were found in this type: ${render()}"
}
return PossiblyInnerIrType(classifier, arguments.subList(index, arguments.size), null)
return PossiblyInnerIrType(classifier, arguments.subList(index, toIndex), null)
}
val argumentsSubList = arguments.subList(index, toIndex)
@@ -1,13 +0,0 @@
MODULE main
CLASS Outer$Inner$p$1.class
Property: class.signature
K1
Lkotlin/jvm/internal/FunctionReferenceImpl;Lkotlin/jvm/functions/Function2<TPT;TPT;LOuter$Inner$p$PLocal<TPT;TIT;TOT;>;>;
K2
Lkotlin/jvm/internal/FunctionReferenceImpl;Lkotlin/jvm/functions/Function2<TPT;TPT;LOuter$Inner$p$PLocal<TPT;TPT;TIT;TOT;>;>;
METHOD invoke(Ljava/lang/Object;Ljava/lang/Object;)LOuter$Inner$p$PLocal;
Property: method.signature
K1
(TPT;TPT;)LOuter$Inner$p$PLocal<TPT;TIT;TOT;>;
K2
(TPT;TPT;)LOuter$Inner$p$PLocal<TPT;TPT;TIT;TOT;>;
@@ -1,5 +1,3 @@
// JVM_ABI_K1_K2_DIFF: KT-62584
// KT-42025
open class L<LL>(val ll: LL)
@@ -1,13 +0,0 @@
MODULE main
CLASS GenericLocalClassConstructorReferenceKt$p$1.class
Property: class.signature
K1
Lkotlin/jvm/internal/FunctionReferenceImpl;Lkotlin/jvm/functions/Function2<TPT;TPT;LGenericLocalClassConstructorReferenceKt$p$PLocal<TPT;>;>;
K2
Lkotlin/jvm/internal/FunctionReferenceImpl;Lkotlin/jvm/functions/Function2<TPT;TPT;LGenericLocalClassConstructorReferenceKt$p$PLocal<TPT;TPT;>;>;
METHOD invoke(Ljava/lang/Object;Ljava/lang/Object;)LGenericLocalClassConstructorReferenceKt$p$PLocal;
Property: method.signature
K1
(TPT;TPT;)LGenericLocalClassConstructorReferenceKt$p$PLocal<TPT;>;
K2
(TPT;TPT;)LGenericLocalClassConstructorReferenceKt$p$PLocal<TPT;TPT;>;
@@ -1,5 +1,3 @@
// JVM_ABI_K1_K2_DIFF: KT-62584
// KT-42025
open class L<LL>(val ll: LL)
@@ -0,0 +1,15 @@
MODULE main
CLASS C$bar$L2.class
CLASS METADATA
Property: class.metadata.superTypes
K1
[.C$bar$L1<T#0>]
K2
[.C$bar$L1]
CLASS Kt62584Kt$baz$L2.class
CLASS METADATA
Property: class.metadata.superTypes
K1
[.Kt62584Kt$baz$L1<kotlin/String, T#0>]
K2
[.Kt62584Kt$baz$L1<kotlin/String>]
+45
View File
@@ -0,0 +1,45 @@
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND: ANDROID
// WITH_STDLIB
// JVM_ABI_K1_K2_DIFF: KT-62584
// For some reason, the tests fails on Android. Might be caused by obfuscation.
class C<T> {
open inner class I1
inner class I2 : I1()
fun foo(): Any = I2()
fun bar(): Any {
open class L1
class L2 : L1()
return L2()
}
}
val <T> C<T>.property: Any
get() {
open class L1<X>
class L2 : L1<String>()
return L2()
}
fun <T> C<T>.baz(): Any {
open class L1<X>
class L2 : L1<String>()
return L2()
}
fun box(): String {
val fooSignature = C<String>().foo().javaClass.genericSuperclass.toString()
if (fooSignature != "C<T>\$I1") return fooSignature
val barSignature = C<String>().bar().javaClass.genericSuperclass.toString()
if (barSignature != "class C\$bar\$L1") return barSignature
val bazSignature = C<String>().baz().javaClass.genericSuperclass.toString()
if (bazSignature != "Kt62584Kt\$baz\$L1<java.lang.String>") return bazSignature
val propertySignature = C<String>().property.javaClass.genericSuperclass.toString()
if (propertySignature != "Kt62584Kt\$property\$L1<java.lang.String>") return propertySignature
return "OK"
}
@@ -28063,6 +28063,12 @@ public class JvmAbiConsistencyTestBoxGenerated extends AbstractJvmAbiConsistency
runTest("compiler/testData/codegen/box/innerNested/kt5363.kt");
}
@Test
@TestMetadata("kt62584.kt")
public void testKt62584() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/kt62584.kt");
}
@Test
@TestMetadata("kt63732.kt")
public void testKt63732() throws Exception {
@@ -28063,6 +28063,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/innerNested/kt5363.kt");
}
@Test
@TestMetadata("kt62584.kt")
public void testKt62584() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/kt62584.kt");
}
@Test
@TestMetadata("kt63732.kt")
public void testKt63732() throws Exception {
@@ -28063,6 +28063,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack
runTest("compiler/testData/codegen/box/innerNested/kt5363.kt");
}
@Test
@TestMetadata("kt62584.kt")
public void testKt62584() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/kt62584.kt");
}
@Test
@TestMetadata("kt63732.kt")
public void testKt63732() throws Exception {
@@ -23663,6 +23663,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/innerNested/kt5363.kt");
}
@TestMetadata("kt62584.kt")
public void testKt62584() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/kt62584.kt");
}
@TestMetadata("kt63732.kt")
public void testKt63732() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/kt63732.kt");