diff --git a/src/de/dhbwstuttgart/syntaxtree/factory/Unify_FC_TTO_Builder.java b/src/de/dhbwstuttgart/syntaxtree/factory/Unify_FC_TTO_Builder.java index 524e729e..d8276f99 100644 --- a/src/de/dhbwstuttgart/syntaxtree/factory/Unify_FC_TTO_Builder.java +++ b/src/de/dhbwstuttgart/syntaxtree/factory/Unify_FC_TTO_Builder.java @@ -14,11 +14,13 @@ public class Unify_FC_TTO_Builder { public void AddInheritance(Type t1, Type t2) { if(t1 instanceof RefType) - classes.add(new Class(t1.get_Name(), t1.getOffset())); + if(!classes.stream().anyMatch(x -> x.getName().equals(t1.getName()))) + classes.add(new Class(t1.get_Name(), t1.getOffset())); if(t2 instanceof RefType) - classes.add(new Class(t2.get_Name(), t2.getOffset())); - + if(!classes.stream().anyMatch(x -> x.getName().equals(t2.getName()))) + classes.add(new Class(t2.get_Name(), t2.getOffset())); + fc.add(new Pair(t1, t2)); } diff --git a/test/unify/UnifyTest.java b/test/unify/UnifyTest.java index 3c5792a3..7e3cff74 100644 --- a/test/unify/UnifyTest.java +++ b/test/unify/UnifyTest.java @@ -50,8 +50,9 @@ public class UnifyTest extends Unify { Set eq = new HashSet(); Set> expected = new HashSet<>(); + expected.add(new HashSet<>()); Set> actual = unify(eq, fc); - Assert.assertEquals(actual, expected); + Assert.assertEquals(expected, actual); /* * Test 2: