Fix not looking up the tph in equality
This commit is contained in:
parent
7556b9f590
commit
fe2b3accb3
@ -47,8 +47,9 @@ public class ASTToTargetAST {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void generics(ClassOrInterface owner, Method method, Set<ResultPair<?, ?>> result, HashSet<TypePlaceholder> referenced) {
|
void generics(ClassOrInterface owner, Method method, Set<ResultPair<?, ?>> result, Set<TypePlaceholder> referenced) {
|
||||||
eliminateInfima(result, referenced);
|
eliminateInfima(result, referenced);
|
||||||
|
eliminateInnerTypeVariables(referenced, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -64,18 +65,19 @@ public class ASTToTargetAST {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void generics(ClassOrInterface owner, Method method, Set<ResultPair<?, ?>> result, HashSet<TypePlaceholder> referenced) {
|
void generics(ClassOrInterface owner, Method method, Set<ResultPair<?, ?>> result, Set<TypePlaceholder> referenced) {
|
||||||
eliminateCycles(result, referenced);
|
eliminateCycles(result, referenced);
|
||||||
eliminateInfima(result, referenced);
|
eliminateInfima(result, referenced);
|
||||||
equalizeTypeVariables(result, referenced);
|
equalizeTypeVariables(result, referenced);
|
||||||
|
eliminateInnerTypeVariables(referenced, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void generics(ClassOrInterface classOrInterface, Set<ResultPair<?, ?>> result, Set<TypePlaceholder> referenced) {
|
void generics(ClassOrInterface classOrInterface, Set<ResultPair<?, ?>> result, Set<TypePlaceholder> referenced) {
|
||||||
eliminateCycles(result, referenced);
|
eliminateCycles(result, referenced);
|
||||||
eliminateInfima(result, referenced);
|
eliminateInfima(result, referenced);
|
||||||
eliminateInnerTypeVariablesOfClass(classOrInterface, result, referenced);
|
|
||||||
equalizeTypeVariables(result, referenced);
|
equalizeTypeVariables(result, referenced);
|
||||||
|
eliminateInnerTypeVariablesOfClass(classOrInterface, result, referenced);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +174,7 @@ public class ASTToTargetAST {
|
|||||||
|
|
||||||
static Set<ResultPair<?, ?>> transitiveClosure(Set<ResultPair<?, ?>> generics) {
|
static Set<ResultPair<?, ?>> transitiveClosure(Set<ResultPair<?, ?>> generics) {
|
||||||
Set<ResultPair<?, ?>> all = new HashSet<>(generics);
|
Set<ResultPair<?, ?>> all = new HashSet<>(generics);
|
||||||
HashSet<ResultPair<?, ?>> toAdd = new HashSet<>();
|
Set<ResultPair<?, ?>> toAdd = new HashSet<>();
|
||||||
int sizeBefore;
|
int sizeBefore;
|
||||||
do {
|
do {
|
||||||
sizeBefore = all.size();
|
sizeBefore = all.size();
|
||||||
@ -221,7 +223,7 @@ public class ASTToTargetAST {
|
|||||||
//Anfang es werden Paare von TPHs gespeichert, die bei den Generated Generics ueber die Methodengrenzen hinweg
|
//Anfang es werden Paare von TPHs gespeichert, die bei den Generated Generics ueber die Methodengrenzen hinweg
|
||||||
//betrachtet werden muessen
|
//betrachtet werden muessen
|
||||||
//Definition 7.2 (Family of generated generics). T1 <. R1 <.^∗ R2 <. T2
|
//Definition 7.2 (Family of generated generics). T1 <. R1 <.^∗ R2 <. T2
|
||||||
Set<RefTypeOrTPHOrWildcardOrGeneric> T1s =
|
Set<TypePlaceholder> T1s =
|
||||||
methodCall.getArgumentList()
|
methodCall.getArgumentList()
|
||||||
.getArguments()
|
.getArguments()
|
||||||
.stream()
|
.stream()
|
||||||
@ -230,10 +232,10 @@ public class ASTToTargetAST {
|
|||||||
.stream().filter(x -> x instanceof TypePlaceholder)
|
.stream().filter(x -> x instanceof TypePlaceholder)
|
||||||
.map(tph -> equality.getOrDefault(tph, (TypePlaceholder) tph))
|
.map(tph -> equality.getOrDefault(tph, (TypePlaceholder) tph))
|
||||||
.collect(Collectors.toCollection(HashSet::new));
|
.collect(Collectors.toCollection(HashSet::new));
|
||||||
RefTypeOrTPHOrWildcardOrGeneric T2 = superType;
|
Set<TypePlaceholder> T2s = new HashSet<>();
|
||||||
if (T2 instanceof TypePlaceholder tph) T2 = equality.getOrDefault(tph, tph);
|
findTphs(superType, T2s);
|
||||||
|
|
||||||
System.out.println("T1s: " + T1s + " T2: " + T2);
|
System.out.println("T1s: " + T1s + " T2s: " + T2s);
|
||||||
//Ende
|
//Ende
|
||||||
|
|
||||||
superType = methodCall.receiverType;
|
superType = methodCall.receiverType;
|
||||||
@ -264,6 +266,7 @@ public class ASTToTargetAST {
|
|||||||
// Loop from hell
|
// Loop from hell
|
||||||
outer:
|
outer:
|
||||||
for (var R1 : typeVariables) {
|
for (var R1 : typeVariables) {
|
||||||
|
R1 = equality.getOrDefault(R1, R1);
|
||||||
if (typeVariablesOfClass.contains(R1)) continue;
|
if (typeVariablesOfClass.contains(R1)) continue;
|
||||||
for (var generic : all) if (generic instanceof PairTPHsmallerTPH ptph) {
|
for (var generic : all) if (generic instanceof PairTPHsmallerTPH ptph) {
|
||||||
var l = equality.getOrDefault(ptph.left, ptph.left);
|
var l = equality.getOrDefault(ptph.left, ptph.left);
|
||||||
@ -276,13 +279,17 @@ public class ASTToTargetAST {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (var R2 : typeVariables) {
|
for (var R2 : typeVariables) {
|
||||||
|
R2 = equality.getOrDefault(R2, R2);
|
||||||
for (var pair2 : simplifiedConstraints) {
|
for (var pair2 : simplifiedConstraints) {
|
||||||
var l3 = equality.getOrDefault(pair2.left, pair2.left);
|
var l3 = equality.getOrDefault(pair2.left, pair2.left);
|
||||||
var r3 = equality.getOrDefault(pair2.right, pair2.right);
|
var r3 = equality.getOrDefault(pair2.right, pair2.right);
|
||||||
|
|
||||||
if (!(r3.equals(R2) && l3.equals(r)))
|
if (!(r3.equals(R2) && l3.equals(r)))
|
||||||
continue;
|
continue;
|
||||||
if (R1.equals(R2)) continue;
|
if (R1.equals(R2)) continue;
|
||||||
if (!T1s.contains(R1) || !R2.equals(T2)) continue;
|
T2s = T2s.stream().map(tph -> equality.getOrDefault(tph, tph)).collect(Collectors.toSet());
|
||||||
|
T1s = T1s.stream().map(tph -> equality.getOrDefault(tph, tph)).collect(Collectors.toSet());
|
||||||
|
if (!T1s.contains(R1) || !T2s.contains(R2)) continue;
|
||||||
|
|
||||||
var newPair = new PairTPHsmallerTPH(R1, R2);
|
var newPair = new PairTPHsmallerTPH(R1, R2);
|
||||||
newPairs.add(newPair);
|
newPairs.add(newPair);
|
||||||
@ -466,7 +473,7 @@ public class ASTToTargetAST {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract void generics(ClassOrInterface owner, Method method, Set<ResultPair<?,?>> result, HashSet<TypePlaceholder> javaTypeVariablesOfClass);
|
abstract void generics(ClassOrInterface owner, Method method, Set<ResultPair<?,?>> result, Set<TypePlaceholder> javaTypeVariablesOfClass);
|
||||||
|
|
||||||
Set<ResultPair<?, ?>> family(ClassOrInterface owner, Method method) {
|
Set<ResultPair<?, ?>> family(ClassOrInterface owner, Method method) {
|
||||||
if (familyOfMethods.containsKey(method))
|
if (familyOfMethods.containsKey(method))
|
||||||
@ -492,8 +499,8 @@ public class ASTToTargetAST {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Set<ResultPair<?, ?>> generics(ClassOrInterface owner, Method method) {
|
Set<ResultPair<?, ?>> generics(ClassOrInterface owner, Method method) {
|
||||||
//if (computedGenericsOfMethods.containsKey(method))
|
if (computedGenericsOfMethods.containsKey(method))
|
||||||
// return computedGenericsOfMethods.get(method);
|
return computedGenericsOfMethods.get(method);
|
||||||
|
|
||||||
var classGenerics = generics(owner);
|
var classGenerics = generics(owner);
|
||||||
|
|
||||||
@ -520,7 +527,6 @@ public class ASTToTargetAST {
|
|||||||
generics(owner, method, result, referenced);
|
generics(owner, method, result, referenced);
|
||||||
usedTPHsOfMethods.put(method, usedTphs);
|
usedTPHsOfMethods.put(method, usedTphs);
|
||||||
|
|
||||||
eliminateInnerTypeVariables(referenced, result);
|
|
||||||
addMissingObjectBounds(result, classGenerics, usedTphs);
|
addMissingObjectBounds(result, classGenerics, usedTphs);
|
||||||
|
|
||||||
System.out.println(this.getClass().getSimpleName() + " " + method.name + ": " + result);
|
System.out.println(this.getClass().getSimpleName() + " " + method.name + ": " + result);
|
||||||
|
Loading…
Reference in New Issue
Block a user