From 41b3e4f6c2a9555e5f3ac13357bbce7df0fe4ec0 Mon Sep 17 00:00:00 2001 From: Florian Steurer Date: Fri, 8 Apr 2016 18:28:34 +0200 Subject: [PATCH] extended case 5 --- .../typeinference/unify/Unify.java | 9 ++++++- test/unify/UnifyTest.java | 25 ++++++++++++++++--- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/de/dhbwstuttgart/typeinference/unify/Unify.java b/src/de/dhbwstuttgart/typeinference/unify/Unify.java index b0e3d7a9..6048fbe2 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/Unify.java +++ b/src/de/dhbwstuttgart/typeinference/unify/Unify.java @@ -463,7 +463,14 @@ public class Unify { Set> result = new HashSet<>(); for(UnifyType thetaS : fc.greater(theta)) { Set resultPrime = new HashSet<>(); - resultPrime.add(new UnifyPair(a, thetaS, PairOperator.EQUALSDOT)); + + UnifyType[] freshTphs = new UnifyType[thetaS.getTypeParams().size()]; + for(int i = 0; i < freshTphs.length; i++) { + freshTphs[i] = PlaceholderType.freshPlaceholder(); + resultPrime.add(new UnifyPair(thetaS.getTypeParams().get(i), freshTphs[i], PairOperator.SMALLERDOTWC)); + } + + resultPrime.add(new UnifyPair(a, thetaS.setTypeParams(new TypeParams(freshTphs)), PairOperator.EQUALSDOT)); result.add(resultPrime); } diff --git a/test/unify/UnifyTest.java b/test/unify/UnifyTest.java index 1a9ec729..a9773809 100644 --- a/test/unify/UnifyTest.java +++ b/test/unify/UnifyTest.java @@ -457,11 +457,28 @@ public class UnifyTest extends Unify { //Assert.assertEquals(expected, actual); /* - * Test 4: - * This is a test for the extension of case 4 of the cartesian product of step 4. - * - * + * Case 4 has no extension */ + + /* + * Test 5: + * This is a test for the extension of case 5 of the cartesian product of step 4. + * + * Vector <. a + * b =. Number + */ + + eq = new HashSet<>(); + eq.add(new UnifyPair(tf.getSimpleType("HashSet", tphB), tphA, PairOperator.SMALLERDOT)); + eq.add(new UnifyPair(tphB, number, PairOperator.EQUALSDOT)); + + expected = new HashSet<>(); + + actual = unify(eq, fc); + + System.out.println(actual); + //Assert.assertEquals(expected, actual); + } @Test