forked from JavaTX/JavaCompilerCore
Use family instead of generated generics
This commit is contained in:
parent
8fb4f062ec
commit
b0cbac529e
@ -245,7 +245,7 @@ public class ASTToTargetAST {
|
|||||||
var optMethod = findMethod(owner, methodCall.name, methodCall.getArgumentList());
|
var optMethod = findMethod(owner, methodCall.name, methodCall.getArgumentList());
|
||||||
if (optMethod.isEmpty()) return;
|
if (optMethod.isEmpty()) return;
|
||||||
var method = optMethod.get();
|
var method = optMethod.get();
|
||||||
var generics = generics(owner, method);
|
var generics = family(owner, method);
|
||||||
|
|
||||||
// transitive and
|
// transitive and
|
||||||
var all = transitiveClosure(generics);
|
var all = transitiveClosure(generics);
|
||||||
@ -293,7 +293,6 @@ public class ASTToTargetAST {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(LambdaExpression lambdaExpression) {
|
public void visit(LambdaExpression lambdaExpression) {
|
||||||
superType = new Void(new NullToken());
|
superType = new Void(new NullToken());
|
||||||
@ -355,6 +354,8 @@ public class ASTToTargetAST {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
System.out.println(method.getName() + " " + result);
|
||||||
|
|
||||||
var closure = transitiveClosure((Set) simplifiedConstraints);
|
var closure = transitiveClosure((Set) simplifiedConstraints);
|
||||||
// Type variables with bounds that are also type variables of the class
|
// Type variables with bounds that are also type variables of the class
|
||||||
for (var typeVariable : new HashSet<>(typeVariables)) {
|
for (var typeVariable : new HashSet<>(typeVariables)) {
|
||||||
@ -454,26 +455,39 @@ 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, HashSet<TypePlaceholder> javaTypeVariablesOfClass);
|
||||||
|
|
||||||
Set<ResultPair<?, ?>> generics(ClassOrInterface owner, Method method) {
|
Set<ResultPair<?, ?>> family(ClassOrInterface owner, Method method) {
|
||||||
if (computedGenericsOfMethods.containsKey(method))
|
var result = new HashSet<ResultPair<?, ?>>();
|
||||||
return computedGenericsOfMethods.get(method);
|
|
||||||
|
|
||||||
Set<ResultPair<?, ?>> result = new HashSet<>();
|
|
||||||
computedGenericsOfMethods.put(method, result);
|
|
||||||
|
|
||||||
var classGenerics = generics(owner);
|
var classGenerics = generics(owner);
|
||||||
|
|
||||||
HashSet<TypePlaceholder> javaTypeVariables = new HashSet<>();
|
|
||||||
HashSet<TypePlaceholder> typeVariablesOfClass = new HashSet<>();
|
HashSet<TypePlaceholder> typeVariablesOfClass = new HashSet<>();
|
||||||
|
|
||||||
for (var pair : classGenerics) {
|
for (var pair : classGenerics) {
|
||||||
typeVariablesOfClass.add((TypePlaceholder) pair.getLeft());
|
typeVariablesOfClass.add((TypePlaceholder) pair.getLeft());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HashSet<TypePlaceholder> javaTypeVariables = new HashSet<>();
|
||||||
|
|
||||||
methodFindTypeVariables(method, javaTypeVariables);
|
methodFindTypeVariables(method, javaTypeVariables);
|
||||||
methodFindConstraints(owner, method, javaTypeVariables, typeVariablesOfClass, result);
|
methodFindConstraints(owner, method, javaTypeVariables, typeVariablesOfClass, result);
|
||||||
eliminateTransitives(result);
|
eliminateTransitives(result);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<ResultPair<?, ?>> generics(ClassOrInterface owner, Method method) {
|
||||||
|
if (computedGenericsOfMethods.containsKey(method))
|
||||||
|
return computedGenericsOfMethods.get(method);
|
||||||
|
|
||||||
|
var classGenerics = generics(owner);
|
||||||
|
|
||||||
|
HashSet<TypePlaceholder> typeVariablesOfClass = new HashSet<>();
|
||||||
|
|
||||||
|
for (var pair : classGenerics) {
|
||||||
|
typeVariablesOfClass.add((TypePlaceholder) pair.getLeft());
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = family(owner, method);
|
||||||
|
computedGenericsOfMethods.put(method, result);
|
||||||
|
|
||||||
var referenced = new HashSet<TypePlaceholder>();
|
var referenced = new HashSet<TypePlaceholder>();
|
||||||
|
|
||||||
generics(owner, method, result, referenced);
|
generics(owner, method, result, referenced);
|
||||||
|
Loading…
Reference in New Issue
Block a user