Fehler beim Ausrechnen zusammenhängender Constraints beheben

This commit is contained in:
JanUlrich 2017-06-20 01:14:04 +02:00
parent cf6d9880e3
commit c272688b2d

View File

@ -73,40 +73,31 @@ public class TypeInsertFactory {
}
}
//Alle Bounds finden:
Map<TypePlaceholder, TypePlaceholder> newGenerics = new HashMap<>();
Set<TypePlaceholder> additionalBoundInserts = new HashSet<>();
Set<Pair> newGenerics = new HashSet<>();
boolean added = true;
while(added){
added = false;
additionalInserts.addAll(additionalBoundInserts);
for(TypePlaceholder tph : additionalInserts){
boolean foundPair = false;
for(Pair pair : pairs){
if (pair.TA1.equals(tph) || pair.TA2.equals(tph)) {
newGenerics.put((TypePlaceholder) pair.TA1, (TypePlaceholder) pair.TA2);
foundPair = true;
added |= additionalBoundInserts.add((TypePlaceholder) pair.TA1);
added |= additionalBoundInserts.add((TypePlaceholder) pair.TA2);
}
}
if(foundPair == false){
newGenerics.put(tph, null);
for(Pair pair : pairs){
if (additionalInserts.contains(pair.TA1) || additionalInserts.contains(pair.TA2)) {
newGenerics.add(pair);
added |= additionalInserts.add((TypePlaceholder) pair.TA1);
added |= additionalInserts.add((TypePlaceholder) pair.TA2);
}
}
}
//Alle TPHs die man noch als Generics anfügen muss einsetzen:
additionalInserts.clear();
for(TypePlaceholder tph : newGenerics.values()){
if(! newGenerics.containsKey(tph)){
additionalInserts.add(tph);
for(Pair subtypings : newGenerics){
if(additionalInserts.contains(subtypings.TA1)){
additionalInserts.remove(subtypings.TA1);
}
}
for(TypePlaceholder tph : additionalInserts){
newGenerics.put(tph, null);
newGenerics.add(new Pair(tph, null));
}
for(TypePlaceholder tph : newGenerics.keySet()){
ret.add(createGenericInsert(tph, newGenerics.get(tph), cl, m));
for(Pair subtyping : newGenerics){
ret.add(createGenericInsert((TypePlaceholder)subtyping.TA1, (TypePlaceholder)subtyping.TA2, cl, m));
}
return ret;