From 78794e377ab6fb25e8f1332b048950a247808003 Mon Sep 17 00:00:00 2001 From: Florian Steurer Date: Tue, 3 May 2016 20:44:55 +0200 Subject: [PATCH 1/2] fixed vector --- .../typeinference/unify/TypeUnifyTask.java | 10 +++++----- test/unify/UnifyTest.java | 7 +++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java b/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java index 178f7bc1..9cb2df6e 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java +++ b/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java @@ -425,9 +425,9 @@ public class TypeUnifyTask extends RecursiveTask>> { protected Set> unifyCase1(PlaceholderType a, UnifyType thetaPrime, IFiniteClosure fc) { Set> result = new HashSet<>(); - boolean allGen = true; + boolean allGen = thetaPrime.getTypeParams().size() > 0; for(UnifyType t : thetaPrime.getTypeParams()) - if(t instanceof PlaceholderType && !((PlaceholderType) t).isGenerated()) { + if(!(t instanceof PlaceholderType) || !((PlaceholderType) t).isGenerated()) { allGen = false; break; } @@ -437,7 +437,7 @@ public class TypeUnifyTask extends RecursiveTask>> { for(UnifyType c : cs) { Set thetaQs = fc.getChildren(c).stream().collect(Collectors.toCollection(HashSet::new)); - thetaQs.add(thetaPrime); + //thetaQs.add(thetaPrime); Set thetaQPrimes = new HashSet<>(); TypeParams cParams = c.getTypeParams(); if(cParams.size() == 0) @@ -549,9 +549,9 @@ public class TypeUnifyTask extends RecursiveTask>> { protected Set> unifyCase5(UnifyType theta, PlaceholderType a, IFiniteClosure fc) { Set> result = new HashSet<>(); - boolean allGen = true; + boolean allGen = theta.getTypeParams().size() > 0; for(UnifyType t : theta.getTypeParams()) - if(t instanceof PlaceholderType && !((PlaceholderType) t).isGenerated()) { + if(!(t instanceof PlaceholderType) || !((PlaceholderType) t).isGenerated()) { allGen = false; break; } diff --git a/test/unify/UnifyTest.java b/test/unify/UnifyTest.java index 825fd40d..16b3380d 100644 --- a/test/unify/UnifyTest.java +++ b/test/unify/UnifyTest.java @@ -862,13 +862,12 @@ public class UnifyTest { UnifyType tphT1 = tf.getPlaceholderType("T1"); UnifyType tphT2 = tf.getPlaceholderType("T2"); - UnifyType gtv = tf.getSimpleType("gtv"); - UnifyType vector = tf.getSimpleType("Vector", gtv); + UnifyType vector = tf.getSimpleType("Vector", "T"); UnifyType vectorE = tf.getSimpleType("Vector", tphT2); UnifyType string = tf.getSimpleType("String"); UnifyType vectorString = tf.getSimpleType("Vector", string); - fcb.add(vector, vector); + fcb.add(vector, tf.getSimpleType("java.lang.Object")); IFiniteClosure fc = fcb.getFiniteClosure(); @@ -879,7 +878,7 @@ public class UnifyTest { Set> actual = new TypeUnify().unifySequential(eq, fc); System.out.println("Test OverloadingVector:"); - System.out.println(actual); + System.out.println(actual + "\n"); } @Test From 005ed60c26057432e47c44002278a7787d9a6ea3 Mon Sep 17 00:00:00 2001 From: Florian Steurer Date: Tue, 3 May 2016 21:07:52 +0200 Subject: [PATCH 2/2] fixed vector --- src/de/dhbwstuttgart/typeinference/unify/RuleSet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/dhbwstuttgart/typeinference/unify/RuleSet.java b/src/de/dhbwstuttgart/typeinference/unify/RuleSet.java index efa7f55e..d14a26f5 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/RuleSet.java +++ b/src/de/dhbwstuttgart/typeinference/unify/RuleSet.java @@ -287,7 +287,7 @@ public class RuleSet implements IRuleSet{ if(lhsSType.getTypeParams().empty()) return Optional.empty(); - UnifyType rhsType = pair.getLhsType(); + UnifyType rhsType = pair.getRhsType(); ReferenceType rhsSType; if(rhsType instanceof ReferenceType)