From ef06a8de380f965042f4aee0c9c11686ec25304a Mon Sep 17 00:00:00 2001 From: Victorious3 Date: Sun, 3 Jul 2022 15:25:35 +0200 Subject: [PATCH] Actually replace instead of removing pairs --- .../target/generate/ASTToTargetAST.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java b/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java index 39ad380d..1a9589d8 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)); + } + } + }); } } }