use of org.checkerframework.framework.util.typeinference.constraint.FIsA in project checker-framework by typetools.
the class DefaultTypeArgumentInference method createInitialAssignmentConstraints.
/**
* Create a set of constraints between return type and any type to which it is assigned. Reduce
* these set of constraints and remove any that is not an equality (FIsA) constraint.
*/
protected Set<FIsA> createInitialAssignmentConstraints(final AnnotatedTypeMirror assignedTo, final AnnotatedTypeMirror boxedReturnType, final AnnotatedTypeFactory typeFactory, final Set<TypeVariable> targets) {
final Set<FIsA> result = new LinkedHashSet<>();
if (assignedTo != null) {
final Set<AFConstraint> reducedConstraints = new LinkedHashSet<>();
final Queue<AFConstraint> constraints = new ArrayDeque<>();
constraints.add(new F2A(boxedReturnType, assignedTo));
reduceAfConstraints(typeFactory, reducedConstraints, constraints, targets);
for (final AFConstraint reducedConstraint : reducedConstraints) {
if (reducedConstraint instanceof FIsA) {
result.add((FIsA) reducedConstraint);
}
}
}
return result;
}
use of org.checkerframework.framework.util.typeinference.constraint.FIsA in project checker-framework by typetools.
the class DefaultTypeArgumentInference method inferFromAssignmentEqualities.
/**
* Step 3. Infer type arguments from the equality constraints of the assignment context.
*/
private InferenceResult inferFromAssignmentEqualities(final AnnotatedTypeMirror assignedTo, final AnnotatedTypeMirror boxedReturnType, final Set<TypeVariable> targets, final AnnotatedTypeFactory typeFactory) {
Set<FIsA> afInitialAssignmentConstraints = createInitialAssignmentConstraints(assignedTo, boxedReturnType, typeFactory, targets);
Set<TUConstraint> tuInitialAssignmentConstraints = afToTuConstraints(afInitialAssignmentConstraints, targets);
ConstraintMap initialAssignmentConstraints = constraintMapBuilder.build(targets, tuInitialAssignmentConstraints, typeFactory);
return equalitiesSolver.solveEqualities(targets, initialAssignmentConstraints, typeFactory);
}
Aggregations