modified: src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java

modified:   src/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java
This commit is contained in:
Martin Plümicke 2018-03-22 20:40:22 +01:00
parent 95e9b2dbda
commit 0b680f831d
2 changed files with 26 additions and 7 deletions

View File

@ -350,7 +350,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
a_next = nextSetasList.iterator().next();
}
*/
if (nextSetasList.iterator().next().iterator().next().getLhsType().getName().equals("D") && nextSetasList.size()>1)
if (!nextSetasList.iterator().hasNext())
System.out.print("");
if (nextSetasList.iterator().next().stream().filter(x -> x.getLhsType().getName().equals("D")).findFirst().isPresent() && nextSetasList.size()>1)
System.out.print("");
while (nextSetasList.size() > 0) { //(nextSetasList.size() != 0) {
Set<UnifyPair> a = nextSetasList.remove(0);
@ -388,8 +390,10 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
else {
result.addAll(computeCartesianRecursive(elems, remainingSets, eq, fc, parallel));
}
if (!result.isEmpty() && !isUndefinedPairSetSet(result)) {
if (nextSetasList.iterator().hasNext() && nextSetasList.iterator().next().stream().filter(x -> x.getLhsType().getName().equals("D")).findFirst().isPresent() && nextSetasList.size()>1)
System.out.print("");
Iterator<Set<UnifyPair>> nextSetasListIt = new ArrayList<Set<UnifyPair>>(nextSetasList).iterator();
if (variance == 1) {
while (nextSetasListIt.hasNext()) {
@ -802,10 +806,18 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
resultPrime.add(new UnifyPair(freshTphs.get(i), theta.getTypeParams().get(i), PairOperator.SMALLERDOTWC));
}
if(allGen)
resultPrime.add(new UnifyPair(a, theta, PairOperator.EQUALSDOT));
else
resultPrime.add(new UnifyPair(a, theta.setTypeParams(new TypeParams(freshTphs.toArray(new UnifyType[0]))), PairOperator.EQUALSDOT));
if(allGen) {
UnifyPair up = new UnifyPair(a, theta, PairOperator.EQUALSDOT);
Iterator<UnifyType> upit = up.getRhsType().getTypeParams().iterator();
while (upit.hasNext()) ((PlaceholderType)upit.next()).setVariance(a.getVariance());
resultPrime.add(up);
}
else {
UnifyPair up = new UnifyPair(a, theta.setTypeParams(new TypeParams(freshTphs.toArray(new UnifyType[0]))), PairOperator.EQUALSDOT);
Iterator<UnifyType> upit = up.getRhsType().getTypeParams().iterator();
while (upit.hasNext()) ((PlaceholderType)upit.next()).setVariance(a.getVariance());
resultPrime.add(up);
}
resultPrime.addAll(substitutionSet);
//writeLog("Substitution: " + substitutionSet.toString());
resultPrime = resultPrime.stream().map(x -> { x.setVariance(variance); return x;}).collect(Collectors.toCollection(HashSet::new));

View File

@ -137,7 +137,14 @@ public class UnifyPair {
@Override
public String toString() {
return "(" + lhs + " " + pairOp + " " + rhs + ", " + variance + ")";
String ret = "";
if (lhs instanceof PlaceholderType) {
ret = new Integer(((PlaceholderType)lhs).getVariance()).toString();
}
if (rhs instanceof PlaceholderType) {
ret = ret + ", " + new Integer(((PlaceholderType)rhs).getVariance()).toString();
}
return "(" + lhs + " " + pairOp + " " + rhs + ", " + ret + ")";
}
/*