use of org.checkerframework.framework.util.typeinference.constraint.FIsAReducer in project checker-framework by typetools.
the class DefaultTypeArgumentInference method reduceAfConstraints.
/**
* Given a set of AFConstraints, remove all constraints that are not relevant to inference and
* return a set of AFConstraints in which the F is a use of one of the type parameters to infer.
*/
protected void reduceAfConstraints(final AnnotatedTypeFactory typeFactory, final Set<AFConstraint> outgoing, final Queue<AFConstraint> toProcess, final Set<TypeVariable> targets) {
final Set<AFConstraint> visited = new HashSet<>();
List<AFReducer> reducers = new ArrayList<>();
reducers.add(new A2FReducer(typeFactory));
reducers.add(new F2AReducer(typeFactory));
reducers.add(new FIsAReducer(typeFactory));
Set<AFConstraint> newConstraints = new HashSet<>(10);
while (!toProcess.isEmpty()) {
newConstraints.clear();
AFConstraint constraint = toProcess.remove();
if (!visited.contains(constraint)) {
if (constraint.isIrreducible(targets)) {
outgoing.add(constraint);
} else {
final Iterator<AFReducer> reducerIterator = reducers.iterator();
boolean handled = false;
while (!handled && reducerIterator.hasNext()) {
handled = reducerIterator.next().reduce(constraint, newConstraints);
}
if (!handled) {
ErrorReporter.errorAbort("Unhandled constraint type: " + constraint.toString());
}
toProcess.addAll(newConstraints);
}
visited.add(constraint);
}
}
}
Aggregations