diff --git a/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java b/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java index bd122e55..61be1e8c 100644 --- a/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java +++ b/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java @@ -1,5 +1,6 @@ package de.dhbwstuttgart.target.generate; +import com.google.j2objc.annotations.LoopTranslation; import de.dhbwstuttgart.bytecode.funN.FunNGenerator; import de.dhbwstuttgart.core.JavaTXCompiler; import de.dhbwstuttgart.parser.NullToken; @@ -145,7 +146,7 @@ public class ASTToTargetAST { findTypeVariables(field.getType(), typeVariablesOfFields); } - findTypeVariables(method.getReturnType(), typeVariables); + //findTypeVariables(method.getReturnType(), typeVariables); for (var arg : method.getParameterList().getFormalparalist()) { findTypeVariables(arg.getType(), typeVariables); } @@ -155,6 +156,15 @@ public class ASTToTargetAST { public void visit(LocalVarDecl localVarDecl) { findTypeVariables(localVarDecl.getType(), typeVariables); } + + @Override + public void visit(MethodCall methodCall) { + super.visit(methodCall); + findTypeVariables(methodCall.getType(), typeVariables); + } + + @Override + public void visit(Assign assign) {} }); // Type variables with bounds that are also type variables of the method @@ -221,6 +231,7 @@ public class ASTToTargetAST { for (var pair2 : simplifiedConstraints) { if (!(pair2.right.equals(tph2) && pair2.left.equals(type))) continue; + if (tph.equals(tph2)) continue; var newPair = new PairTPHsmallerTPH(tph, tph2); newPairs.add(newPair); @@ -572,6 +583,8 @@ public class ASTToTargetAST { for (var i = 0; i < pars.size(); i++) { var type1 = convert(pars.get(i).getType()); var type2 = convert(arguments.get(i).getType()); + if (type2 instanceof TargetGenericType && type1 instanceof TargetGenericType) + return true; if (!type1.equals(type2)) return false; } diff --git a/src/test/java/targetast/TestComplete.java b/src/test/java/targetast/TestComplete.java index 7c22c388..cf8cdac8 100644 --- a/src/test/java/targetast/TestComplete.java +++ b/src/test/java/targetast/TestComplete.java @@ -355,8 +355,8 @@ public class TestComplete { @Test public void tph4Test() throws Exception { var classFiles = generateClassFiles("Tph4.jav", new ByteArrayClassLoader()); - var tph5 = classFiles.get("Tph4"); - var instance = tph5.getDeclaredConstructor().newInstance(); + var tph4 = classFiles.get("Tph4"); + var instance = tph4.getDeclaredConstructor().newInstance(); } @Test