diff --git a/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java b/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java index 6a8e2612..a118339b 100644 --- a/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java +++ b/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java @@ -270,10 +270,29 @@ public class ASTToTargetAST { computedGenericsOfClasses.put(classOrInterface, result); eliminateCyclesAndInfima(result); eliminateInnerTypeVariables(classOrInterface, result); + equalizeTypeVariables(result); + System.out.println("Class " + classOrInterface.getClassName().getClassName() + ": " + result); return result; } + void equalizeTypeVariables(Set> input) { + for (var pair : new HashSet<>(input)) { + if (pair instanceof PairTPHsmallerTPH ptph) { + if (ptph.left.getVariance() == 1 && ptph.right.getVariance() == -1) { + equality.put(ptph.left, ptph.right); + input.remove(ptph); + for (var pair2 : new HashSet<>(input)) { + if (pair2 instanceof PairTPHsmallerTPH ptph2 && ptph2.right.equals(ptph.left)) { + input.remove(pair2); + input.add(new PairTPHsmallerTPH(ptph2.left, ptph.right)); + } + } + } + } + } + } + void findTphs(RefTypeOrTPHOrWildcardOrGeneric type, Set tphs) { if (type instanceof RefType refType) { refType.getParaList().forEach(t -> findTphs(t, tphs));