Search in sources :

Example 1 with FIsA

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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) FIsA(org.checkerframework.framework.util.typeinference.constraint.FIsA) F2A(org.checkerframework.framework.util.typeinference.constraint.F2A) AFConstraint(org.checkerframework.framework.util.typeinference.constraint.AFConstraint) ArrayDeque(java.util.ArrayDeque)

Example 2 with FIsA

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);
}
Also used : FIsA(org.checkerframework.framework.util.typeinference.constraint.FIsA) ConstraintMap(org.checkerframework.framework.util.typeinference.solver.ConstraintMap) TUConstraint(org.checkerframework.framework.util.typeinference.constraint.TUConstraint)

Aggregations

FIsA (org.checkerframework.framework.util.typeinference.constraint.FIsA)2 ArrayDeque (java.util.ArrayDeque)1 LinkedHashSet (java.util.LinkedHashSet)1 AFConstraint (org.checkerframework.framework.util.typeinference.constraint.AFConstraint)1 F2A (org.checkerframework.framework.util.typeinference.constraint.F2A)1 TUConstraint (org.checkerframework.framework.util.typeinference.constraint.TUConstraint)1 ConstraintMap (org.checkerframework.framework.util.typeinference.solver.ConstraintMap)1