Merge branch 'unify-test' of ssh://gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore into unify-test

This commit is contained in:
Pluemicke Martin 2019-01-29 14:48:54 +01:00
commit 7f239d11ee
3 changed files with 47 additions and 4 deletions

View File

@ -326,7 +326,8 @@ public class RuleSet implements IRuleSet{
lhsSType = (ReferenceType) lhsType; lhsSType = (ReferenceType) lhsType;
rhsSType = (ReferenceType) rhsType; rhsSType = (ReferenceType) rhsType;
} }
else if ((lhsType instanceof WildcardType) && (rhsType instanceof WildcardType)) { else if (((lhsType instanceof ExtendsType) && (rhsType instanceof ExtendsType))
|| ((lhsType instanceof SuperType) && (rhsType instanceof SuperType))) {
UnifyType lhsSTypeRaw = ((WildcardType) lhsType).getWildcardedType(); UnifyType lhsSTypeRaw = ((WildcardType) lhsType).getWildcardedType();
UnifyType rhsSTypeRaw = ((WildcardType) rhsType).getWildcardedType(); UnifyType rhsSTypeRaw = ((WildcardType) rhsType).getWildcardedType();
if ((lhsSTypeRaw instanceof ReferenceType) && (rhsSTypeRaw instanceof ReferenceType)) { if ((lhsSTypeRaw instanceof ReferenceType) && (rhsSTypeRaw instanceof ReferenceType)) {

View File

@ -829,6 +829,23 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
nextSetasListRest.remove(a_next); nextSetasListRest.remove(a_next);
} }
} }
//Alle maximale Elemente in nextSetasListRest bestimmen
List<Set<UnifyPair>> nextSetasListRestTest;
do {
nextSetasListRestTest = new ArrayList<Set<UnifyPair>>(nextSetasListRest);
if (!nextSetasListRest.isEmpty()) {
Set<UnifyPair> max = oup.max(nextSetasListRest.iterator());
Iterator<Set<UnifyPair>> nextSetasListItRest2 = new ArrayList<Set<UnifyPair>>(nextSetasListRest).iterator();
while (nextSetasListItRest2.hasNext()) {
Set<UnifyPair> a_nextRest = nextSetasListItRest2.next();
if (//a.equals(a_next) ||
(oup.compare(max, a_nextRest) == 1)) {
nextSetasListRest.remove(a_nextRest);
}
}}
} while(!nextSetasListRestTest.equals(nextSetasListRest));
} }
else if (variance == -1) { else if (variance == -1) {
a = oup.min(nextSetasList.iterator()); a = oup.min(nextSetasList.iterator());
@ -842,6 +859,23 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
nextSetasListRest.remove(a_next); nextSetasListRest.remove(a_next);
} }
} }
//Alle minimalen Elemente in nextSetasListRest bestimmen
List<Set<UnifyPair>> nextSetasListRestTest;
do {
nextSetasListRestTest = new ArrayList<Set<UnifyPair>>(nextSetasListRest);
if (!nextSetasListRest.isEmpty()) {
Set<UnifyPair> min = oup.min(nextSetasListRest.iterator());
Iterator<Set<UnifyPair>> nextSetasListItRest2 = new ArrayList<Set<UnifyPair>>(nextSetasListRest).iterator();
while (nextSetasListItRest2.hasNext()) {
Set<UnifyPair> a_nextRest = nextSetasListItRest2.next();
if (//a.equals(a_next) ||
(oup.compare(min, a_nextRest) == -1)) {
nextSetasListRest.remove(a_nextRest);
}
}}
} while(!nextSetasListRestTest.equals(nextSetasListRest));
} }
else if (variance == 2) { else if (variance == 2) {
a = nextSetasList.remove(0); a = nextSetasList.remove(0);
@ -1879,13 +1913,17 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
for(UnifyType c : csPHRenamed) { for(UnifyType c : csPHRenamed) {
//PL 18-02-05 getChildren durch smaller ersetzt in getChildren werden die Varianlen nicht ersetzt. //PL 18-02-05 getChildren durch smaller ersetzt in getChildren werden die Varianlen nicht ersetzt.
Set<UnifyType> thetaQs = fc.smaller(c, new HashSet<>()).stream().collect(Collectors.toCollection(HashSet::new)); Set<UnifyType> thetaQs = new HashSet<>();
//TODO smaller wieder reinnehmen?
//thetaQs.add(c);//
thetaQs = fc.smaller(c, new HashSet<>()).stream().collect(Collectors.toCollection(HashSet::new));
//Set<UnifyType> thetaQs = fc.getChildren(c).stream().collect(Collectors.toCollection(HashSet::new)); //Set<UnifyType> thetaQs = fc.getChildren(c).stream().collect(Collectors.toCollection(HashSet::new));
//thetaQs.add(thetaPrime); //PL 18-02-05 wieder geloescht //thetaQs.add(thetaPrime); //PL 18-02-05 wieder geloescht
//PL 2017-10-03: War auskommentiert habe ich wieder einkommentiert, //PL 2017-10-03: War auskommentiert habe ich wieder einkommentiert,
//da children offensichtlich ein echtes kleiner und kein kleinergleich ist //da children offensichtlich ein echtes kleiner und kein kleinergleich ist
//PL 18-02-06: eingefuegt, thetaQs der Form V<V<...>> <. V'<V<...>> werden entfernt //PL 18-02-06: eingefuegt, thetaQs der Form V<V<...>> <. V'<V<...>> werden entfernt
//TODO PL 19-01-14 wieder reinnehmen kurzfristig auskommentiert
thetaQs = thetaQs.stream().filter(ut -> ut.getTypeParams().arePlaceholders()).collect(Collectors.toCollection(HashSet::new)); thetaQs = thetaQs.stream().filter(ut -> ut.getTypeParams().arePlaceholders()).collect(Collectors.toCollection(HashSet::new));
//PL 18-02-06: eingefuegt //PL 18-02-06: eingefuegt
@ -1950,13 +1988,16 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
if(allGen) { if(allGen) {
UnifyPair up = new UnifyPair(a, theta, PairOperator.EQUALSDOT, pair.getSubstitution(), pair); UnifyPair up = new UnifyPair(a, theta, PairOperator.EQUALSDOT, pair.getSubstitution(), pair);
Iterator<UnifyType> upit = up.getRhsType().getTypeParams().iterator(); Iterator<UnifyType> upit = up.getRhsType().getTypeParams().iterator();
while (upit.hasNext()) ((PlaceholderType)upit.next()).setVariance(a.getVariance()); //TODO PL 2019-01-24: upit.next() ist nicht unbedingt ein PlaceholderType -> Visitor
while (upit.hasNext()) upit.next().accept(new distributeVariance(), a.getVariance());//((PlaceholderType)upit.next()).setVariance(a.getVariance());
resultPrime.add(up); resultPrime.add(up);
} }
else { else {
UnifyPair up = new UnifyPair(a, theta.setTypeParams(new TypeParams(freshTphs.toArray(new UnifyType[0]))), PairOperator.EQUALSDOT, pair.getSubstitution(), pair); UnifyPair up = new UnifyPair(a, theta.setTypeParams(new TypeParams(freshTphs.toArray(new UnifyType[0]))), PairOperator.EQUALSDOT, pair.getSubstitution(), pair);
Iterator<UnifyType> upit = up.getRhsType().getTypeParams().iterator(); Iterator<UnifyType> upit = up.getRhsType().getTypeParams().iterator();
while (upit.hasNext()) ((PlaceholderType)upit.next()).setVariance(a.getVariance()); distributeVariance dv = new distributeVariance();
//TODO PL 2019-01-24: upit.next() ist nicht unbedingt ein PlaceholderType -> Visitor
while (upit.hasNext()) upit.next().accept(new distributeVariance(), a.getVariance()); //((PlaceholderType)upit.next()).setVariance(a.getVariance());
resultPrime.add(up); resultPrime.add(up);
} }
resultPrime.addAll(substitutionSet); resultPrime.addAll(substitutionSet);

View File

@ -2,6 +2,7 @@ package de.dhbwstuttgart.typeinference.unify;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set;
import de.dhbwstuttgart.typeinference.result.ResultSet; import de.dhbwstuttgart.typeinference.result.ResultSet;