We actually need the signature of the class

This commit is contained in:
Victorious3 2023-01-31 14:53:02 +01:00
parent 21fb477ee1
commit 62fad15b6f
3 changed files with 4 additions and 6 deletions

View File

@ -979,7 +979,7 @@ public class Codegen {
} }
private void generateConstructor(TargetConstructor constructor) { private void generateConstructor(TargetConstructor constructor) {
MethodVisitor mv = cw.visitMethod(constructor.access() | ACC_PUBLIC, "<init>", constructor.getDescriptor(), null, null); MethodVisitor mv = cw.visitMethod(constructor.access() | ACC_PUBLIC, "<init>", constructor.getDescriptor(), constructor.getSignature(), null);
mv.visitCode(); mv.visitCode();
var state = new State(null, mv, 1); var state = new State(null, mv, 1);
for (var param: constructor.parameters()) for (var param: constructor.parameters())
@ -1028,7 +1028,7 @@ public class Codegen {
public byte[] generate() { public byte[] generate() {
cw.visit(V1_8, clazz.modifiers() | ACC_PUBLIC | ACC_SUPER, clazz.qualifiedName(), cw.visit(V1_8, clazz.modifiers() | ACC_PUBLIC | ACC_SUPER, clazz.qualifiedName(),
null, clazz.superType() != null ? clazz.superType().getInternalName(): "java/lang/Object", generateSignature(clazz), clazz.superType() != null ? clazz.superType().getInternalName(): "java/lang/Object",
clazz.implementingInterfaces().stream().map(TargetType::toSignature).toArray(String[]::new) clazz.implementingInterfaces().stream().map(TargetType::toSignature).toArray(String[]::new)
); );
clazz.fields().forEach(this::generateField); clazz.fields().forEach(this::generateField);

View File

@ -135,7 +135,7 @@ public class ASTToTargetAST {
typeVariablesOfFields.addAll(findTypeVariables(field.getType())); typeVariablesOfFields.addAll(findTypeVariables(field.getType()));
} }
//findTypeVariables(method.getReturnType(), typeVariables); typeVariables.addAll(findTypeVariables(method.getReturnType()));
for (var arg : method.getParameterList().getFormalparalist()) { for (var arg : method.getParameterList().getFormalparalist()) {
typeVariables.addAll(findTypeVariables(arg.getType())); typeVariables.addAll(findTypeVariables(arg.getType()));
} }
@ -459,7 +459,6 @@ public class ASTToTargetAST {
addToPairs(result, new PairTPHequalRefTypeOrWildcardType(pair.right, OBJECT)); addToPairs(result, new PairTPHequalRefTypeOrWildcardType(pair.right, OBJECT));
} }
} }
eliminateCyclesAndInfima(result); eliminateCyclesAndInfima(result);
usedTPHsOfMethods.put(method, typeVariables); usedTPHsOfMethods.put(method, typeVariables);
@ -471,7 +470,7 @@ public class ASTToTargetAST {
} }
typeVariablesOfSignature.addAll(findTypeVariables(method.getReturnType())); typeVariablesOfSignature.addAll(findTypeVariables(method.getReturnType()));
eliminateInnerTypeVariables(typeVariablesOfSignature, result); //eliminateInnerTypeVariables(typeVariablesOfSignature, result);
System.out.println(method.name + ": " + result); System.out.println(method.name + ": " + result);
return result; return result;

View File

@ -226,7 +226,6 @@ public class TestGenerics {
} }
@Test @Test
@Ignore("This doesn't work properly")
public void testThreeArgs() throws Exception { public void testThreeArgs() throws Exception {
var result = computeGenerics("TestThreeArgs.jav"); var result = computeGenerics("TestThreeArgs.jav");
} }