Fix for KT-10110: ClassReader$BadClassFile undeclared type variable: E

#KT-10110 Fixed
This commit is contained in:
Michael Bogdanov
2015-11-26 09:52:00 +03:00
parent 9ccb1fd506
commit 2d3d526ccd
4 changed files with 44 additions and 6 deletions
@@ -263,13 +263,13 @@ public class BothSignatureWriter {
}
@NotNull
public JvmMethodSignature makeJvmMethodSignature(@NotNull String name) {
public JvmMethodSignature makeJvmMethodSignature(@NotNull String name, boolean skipGenericSignature) {
List<Type> types = new ArrayList<Type>(kotlinParameterTypes.size());
for (JvmMethodParameterSignature parameter : kotlinParameterTypes) {
types.add(parameter.getAsmType());
}
Method asmMethod = new Method(name, jvmReturnType, types.toArray(new Type[types.size()]));
return new JvmMethodSignature(asmMethod, makeJavaGenericSignature(), kotlinParameterTypes);
return new JvmMethodSignature(asmMethod, !skipGenericSignature ? makeJavaGenericSignature() : null, kotlinParameterTypes);
}
public int getCurrentSignatureSize() {
@@ -405,7 +405,7 @@ public class JetTypeMapper {
sw.writeReturnType();
mapType(descriptor.getType(), sw, JetTypeMapperMode.VALUE_FOR_ANNOTATION);
sw.writeReturnTypeEnd();
return sw.makeJvmMethodSignature(descriptor.getName().asString());
return sw.makeJvmMethodSignature(descriptor.getName().asString(), false);
}
@NotNull
@@ -1071,8 +1071,7 @@ public class JetTypeMapper {
sw.writeReturnTypeEnd();
}
JvmMethodSignature signature = sw.makeJvmMethodSignature(mapFunctionName(f));
JvmMethodSignature signature = sw.makeJvmMethodSignature(mapFunctionName(f), f instanceof AccessorForCallableDescriptor);
if (kind != OwnerKind.DEFAULT_IMPLS) {
SpecialSignatureInfo specialSignatureInfo = BuiltinMethodsWithSpecialGenericSignature.getSpecialSignatureInfo(f);
@@ -1394,7 +1393,7 @@ public class JetTypeMapper {
writeVoidReturn(sw);
return sw.makeJvmMethodSignature("<init>");
return sw.makeJvmMethodSignature("<init>", false);
}
public Type getSharedVarType(DeclarationDescriptor descriptor) {
@@ -0,0 +1,24 @@
class MyList<T> {
private fun noSignature(): T? = null
fun withSignature(): T? = null
fun removeHeader() {
fun a () {
noSignature()
}
}
}
/*
Class signature,
local fun class signature,
'noSignature' and 'withSignature' fun signatures
*/
// 4 signature
// 2 signature \(\)TT\;
// 1 signature Lkotlin/jvm/internal/Lambda\;Lkotlin/jvm/functions/Function0<Lkotlin/Unit\;>\;
// 1 signature <T:Ljava/lang/Object\;>Ljava/lang/Object\;
// 1 public final static synthetic access\$noSignature\(LMyList\;\)Ljava/lang/Object
@@ -800,6 +800,21 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
}
}
@TestMetadata("compiler/testData/codegen/bytecodeText/signature")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Signature extends AbstractBytecodeTextTest {
public void testAllFilesPresentInSignature() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/bytecodeText/signature"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("noSignatureInSyntheticAccessor.kt")
public void testNoSignatureInSyntheticAccessor() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/signature/noSignatureInSyntheticAccessor.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/codegen/bytecodeText/statements")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)