diff --git a/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java b/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java index 9ab01e4b..a421a087 100644 --- a/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java +++ b/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java @@ -72,6 +72,10 @@ public class ASTToTargetAST { } else if (type instanceof RefType refType) { for (var t : refType.getParaList()) result.addAll(findTypeVariables(t)); + } else if (type instanceof ExtendsWildcardType wildcardType) { + result.addAll(findTypeVariables(wildcardType.getInnerType())); + } else if (type instanceof SuperWildcardType wildcardType) { + result.addAll(findTypeVariables(wildcardType.getInnerType())); } return result; } @@ -126,7 +130,6 @@ public class ASTToTargetAST { HashSet typeVariables = new HashSet<>(); HashSet typeVariablesOfFields = new HashSet<>(); - HashSet typeVariablesOfLocals = new HashSet<>(); for (var field : owner.getFieldDecl()) { typeVariablesOfFields.addAll(findTypeVariables(field.getType())); @@ -140,9 +143,7 @@ public class ASTToTargetAST { method.block.accept(new TracingStatementVisitor() { @Override public void visit(LocalVarDecl localVarDecl) { - var tphs = findTypeVariables(localVarDecl.getType()); - typeVariablesOfLocals.addAll(tphs); - typeVariables.addAll(tphs); + typeVariables.addAll(findTypeVariables(localVarDecl.getType())); } @Override @@ -463,13 +464,12 @@ public class ASTToTargetAST { usedTPHsOfMethods.put(method, typeVariables); // For eliminating inner type variables we need to figure out which ones are actually used + // TODO Maybe don't do this twice? var typeVariablesOfSignature = new HashSet(); for (var param : method.getParameterList().getFormalparalist()) { - if (param.getType() instanceof TypePlaceholder tph) - typeVariablesOfSignature.add(equality.getOrDefault(tph, tph)); + typeVariablesOfSignature.addAll(findTypeVariables(param.getType())); } - if (method.getReturnType() instanceof TypePlaceholder tph) - typeVariablesOfSignature.add(equality.getOrDefault(tph, tph)); + typeVariablesOfSignature.addAll(findTypeVariables(method.getReturnType())); eliminateInnerTypeVariables(typeVariablesOfSignature, result); System.out.println(method.name + ": " + result);