diff --git a/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java b/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java index 39ad380d2..1a9589d86 100644 --- a/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java +++ b/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java @@ -303,11 +303,24 @@ public class ASTToTargetAST { foundInfima = true; var newTph = TypePlaceholder.fresh(new NullToken()); input.add(new PairTPHsmallerTPH(left, newTph)); - input.add(new PairTPHequalRefTypeOrWildcardType(newTph, OBJECT)); input.removeAll(infima); for (var infimum : infima) { equality.put(infimum.right, newTph); - input.removeIf(pair -> pair.getLeft().equals(infimum.right)); + new HashSet<>(input).stream().forEach(pair -> { + if (pair.getLeft().equals(infimum.right)) { + input.remove(pair); + if (pair instanceof PairTPHsmallerTPH stph) { + input.add(new PairTPHsmallerTPH(newTph, stph.right)); + } else if (pair instanceof PairTPHequalRefTypeOrWildcardType rtph) { + input.add(new PairTPHequalRefTypeOrWildcardType(newTph, rtph.getRight())); + } + } else if (pair.getRight().equals(infimum.right)) { + input.remove(pair); + if (pair instanceof PairTPHsmallerTPH stph) { + input.add(new PairTPHsmallerTPH(stph.left, newTph)); + } + } + }); } } }