Fix for KT-11677: Generic type signatures for local classes in inlined lambdas are not written properly
#KT-11677 Fixed
This commit is contained in:
@@ -292,8 +292,8 @@ public class MethodInliner {
|
||||
super.visitMethodInsn(opcode, changeOwnerForExternalPackage(owner, opcode), name, desc, itf);
|
||||
}
|
||||
}
|
||||
else if (ReifiedTypeInliner.isNeedClassReificationMarker(new MethodInsnNode(opcode, owner, name, desc, false))) {
|
||||
// we will put it if needed in anew processing
|
||||
else if (!inliningContext.isInliningLambda && ReifiedTypeInliner.isNeedClassReificationMarker(new MethodInsnNode(opcode, owner, name, desc, false))) {
|
||||
//we shouldn't process here content of inlining lambda it should be reified at external level
|
||||
}
|
||||
else {
|
||||
super.visitMethodInsn(opcode, changeOwnerForExternalPackage(owner, opcode), name, desc, itf);
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
// FILE: 1.kt
|
||||
// FULL_JDK
|
||||
// WITH_REFLECT
|
||||
|
||||
package test
|
||||
|
||||
import java.lang.reflect.ParameterizedType
|
||||
import java.lang.reflect.Type
|
||||
|
||||
open class TypeLiteral<T> {
|
||||
val type: Type
|
||||
get() = (javaClass.genericSuperclass as ParameterizedType).getActualTypeArguments()[0]
|
||||
}
|
||||
|
||||
// normal inline function works fine
|
||||
inline fun <reified T> typeLiteral(): TypeLiteral<T> = object : TypeLiteral<T>() {}
|
||||
|
||||
// nested lambda loses reification of T
|
||||
inline fun <reified T> brokenTypeLiteral(): TypeLiteral<T> = "".run { typeLiteral<T>() }
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
val type1 = typeLiteral<List<String>>().type.toString()
|
||||
if (type1 != "java.util.List<? extends java.lang.String>") return "fail 1: $type1"
|
||||
|
||||
val type2 = brokenTypeLiteral<List<String>>().type.toString()
|
||||
if (type2 != "java.util.List<? extends java.lang.String>") return "fail 2: $type2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1525,6 +1525,12 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt11677.kt")
|
||||
public void testKt11677() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/reified/kt11677.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt6988.kt")
|
||||
public void testKt6988() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/reified/kt6988.kt");
|
||||
|
||||
+6
@@ -1525,6 +1525,12 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt11677.kt")
|
||||
public void testKt11677() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/reified/kt11677.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt6988.kt")
|
||||
public void testKt6988() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/reified/kt6988.kt");
|
||||
|
||||
Reference in New Issue
Block a user