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