Fix equality
This commit is contained in:
parent
6079e96efa
commit
bdaf578f86
@ -14,6 +14,7 @@ import de.dhbwstuttgart.typeinference.result.PairTPHEqualTPH;
|
||||
import de.dhbwstuttgart.typeinference.result.PairTPHequalRefTypeOrWildcardType;
|
||||
import de.dhbwstuttgart.typeinference.result.PairTPHsmallerTPH;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
import de.dhbwstuttgart.util.Pair;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@ -657,7 +658,12 @@ public abstract class GenerateGenerics {
|
||||
}
|
||||
}
|
||||
|
||||
private record ToAdd(TypePlaceholder left, TypePlaceholder right) {}
|
||||
|
||||
void equalizeTypeVariables(Set<Pair> input, Set<TPH> referenced) {
|
||||
|
||||
var elementsToAddToEquality = new ArrayList<ToAdd>();
|
||||
|
||||
for (var pair : new HashSet<>(input)) {
|
||||
if (pair instanceof PairLT ptph && referenced.contains(ptph.left)) {
|
||||
var chain = new ArrayList<TPH>();
|
||||
@ -698,7 +704,8 @@ public abstract class GenerateGenerics {
|
||||
for (var i = 1; i < index; i++) {
|
||||
var cur = chain.get(i);
|
||||
if (!referenced.contains(cur)) continue;
|
||||
addToEquality(cur.resolve(), start.resolve(), referenced);
|
||||
elementsToAddToEquality.add(new ToAdd(cur.resolve(), start.resolve()));
|
||||
//addToEquality(cur.resolve(), start.resolve(), referenced);
|
||||
TPH finalPrev = prev;
|
||||
input.removeIf(p -> p.equals(new PairLT(finalPrev, cur)));
|
||||
for (var pair2 : new HashSet<>(input)) {
|
||||
@ -712,6 +719,11 @@ public abstract class GenerateGenerics {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var pair : elementsToAddToEquality) {
|
||||
System.out.println(pair);
|
||||
addToEquality(pair.left, pair.right, referenced);
|
||||
}
|
||||
}
|
||||
|
||||
void findTphs(RefTypeOrTPHOrWildcardOrGeneric type, Set<TPH> tphs) {
|
||||
@ -894,6 +906,8 @@ public abstract class GenerateGenerics {
|
||||
}
|
||||
}
|
||||
newTph.setVariance(variance);
|
||||
System.out.println(infima + " " + infima.stream().map(i -> i.right.resolve().getVariance()).toList());
|
||||
System.out.println("Infima new TPH " + newTph + " variance " + variance);
|
||||
|
||||
//referenced.add(newTph);
|
||||
addToPairs(input, new PairLT(left, new TPH(newTph)));
|
||||
|
Loading…
Reference in New Issue
Block a user