diff --git a/src/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java b/src/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java index 4a331353..1c45680b 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java +++ b/src/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java @@ -122,8 +122,13 @@ public class FiniteClosure implements IFiniteClosure { Set permResult = new HashSet<>(); permuteParams(paramCandidates, 0, permResult, new Type[paramCandidates.size()]); - for (TypeParams newParams : permResult) - result3.add(t.setTypeParams(newParams)); + for (TypeParams newParams : permResult) { + Type tPrime = t.setTypeParams(newParams); + if(tPrime.equals(t)) + result3.add(t); + else + result3.addAll(smaller(tPrime)); + } } diff --git a/test/unify/FiniteClosureTest.java b/test/unify/FiniteClosureTest.java index d1f99d60..33ba1d0a 100644 --- a/test/unify/FiniteClosureTest.java +++ b/test/unify/FiniteClosureTest.java @@ -375,22 +375,22 @@ public class FiniteClosureTest { /* * Test Case 15: * - * MyMap <* HashMap> + * MyMap <* TreeMap> * - * smaller(NavigableSet>) = - * { NavigableSet>, - * NavigableSet> - * NavigableSet> - * NavigableSet> - * TreeSet>, - * TreeSet> - * TreeSet> - * TreeSet> } + * smaller(NavigableSet>) = + * { Permutationen der List, + * Permutationen der List in TreeSets, + * MyMap und MyMap + * } */ - Type navSet = tf.getSimpleType("NavigableSet", extInt, tf.getExtendsType(tf.getSimpleType("ArrayList", extInt))); + Type navSet = tf.getSimpleType("NavigableMap", extInt, tf.getExtendsType(tf.getSimpleType("List", extInt))); - Assert.assertEquals(8, fc.smaller(navSet).size()); + actual = fc.smaller(navSet); + + Assert.assertEquals(82, actual.size()); + Assert.assertTrue(actual.contains(myMapExtInt)); + Assert.assertTrue(actual.contains(myMapInt)); } @Test