Fix incorrect generics for derived FunN

This commit is contained in:
Victorious3 2023-03-21 12:12:42 +01:00
parent b5af3a42a8
commit d93836d110
4 changed files with 12 additions and 4 deletions

7
Test.java Normal file
View File

@ -0,0 +1,7 @@
public interface Test<A, B> extends Base<A, B> {
}
interface Base<A, B> {
}

View File

@ -1025,6 +1025,8 @@ public class Codegen {
if (!method.txGenerics().isEmpty())
mv.visitAttribute(new JavaTXSignatureAttribute(method.getTXSignature()));
System.out.println(method.getDescriptor());
System.out.println(method.getSignature());
mv.visitCode();
var state = new State(method.returnType(), mv, method.isStatic() ? 0 : 1);
for (var param: method.parameters())

View File

@ -1,5 +1,6 @@
package de.dhbwstuttgart.bytecode;
import de.dhbwstuttgart.target.tree.TargetGeneric;
import de.dhbwstuttgart.target.tree.type.TargetGenericType;
import de.dhbwstuttgart.target.tree.type.TargetRefType;
import de.dhbwstuttgart.target.tree.type.TargetType;
@ -66,7 +67,7 @@ public class FunNGenerator {
List<TargetType> parameters = Stream
.concat(argumentTypes.stream(), Stream.of(returnType))
.collect(Collectors.toList());
StringBuilder funNClassSignature = new StringBuilder(objectSignature + applySignature(new TargetRefType(getSuperClassName(argumentTypes.size()), parameters)));
StringBuilder funNClassSignature = new StringBuilder(objectSignature + applyDescriptor(new TargetRefType(getSuperClassName(argumentTypes.size()), parameters)));
boolean containsGeneric = false;
String genericSignature = "<";
@ -74,13 +75,12 @@ public class FunNGenerator {
//ToDo Etienne: Refactor
if (typeArgument instanceof TargetGenericType generic){
//if(genericSignature.contains(generic.name())) continue;
genericSignature += String.format("%s:%s", generic.name(), applyDescriptor(generic));
genericSignature += String.format("%s:%s", generic.name(), objectSignature);
containsGeneric = true;
}
}
genericSignature += ">";
if (containsGeneric) funNClassSignature.insert(0, genericSignature);
System.out.println(funNClassSignature.toString());
ClassWriter classWriter = new ClassWriter(0);
classWriter.visit(bytecodeVersion, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, getSpecializedClassName(argumentTypes, returnType), funNClassSignature.toString(), objectSuperType, new String[]{getSuperClassName(argumentTypes.size())});

View File

@ -233,7 +233,6 @@ public class TestComplete {
}
@Test
@Ignore
public void matrixTest() throws Exception {
var classFiles = generateClassFiles("Matrix.jav", new ByteArrayClassLoader());
var matrix = classFiles.get("Matrix");