use of org.checkerframework.framework.util.typeinference.solver.ConstraintMap in project checker-framework by typetools.
the class DefaultTypeArgumentInference method inferFromAssignment.
/**
* The Second half of step 6. Use the assignment context to infer a result.
*/
private InferenceResult inferFromAssignment(final AnnotatedTypeMirror assignedTo, final AnnotatedTypeMirror boxedReturnType, final AnnotatedExecutableType methodType, final Set<AFConstraint> afArgumentConstraints, final InferenceResult inferredArgs, final Set<TypeVariable> targets, final AnnotatedTypeFactory typeFactory) {
ConstraintMap assignmentConstraints = createAssignmentConstraints(assignedTo, boxedReturnType, methodType, afArgumentConstraints, inferredArgs.toAtmMap(), targets, typeFactory);
InferenceResult equalitiesResult = equalitiesSolver.solveEqualities(targets, assignmentConstraints, typeFactory);
Set<TypeVariable> remainingTargets = equalitiesResult.getRemainingTargets(targets, true);
InferenceResult subtypesResult = subtypesSolver.solveFromSubtypes(remainingTargets, assignmentConstraints, typeFactory);
equalitiesResult.mergeSubordinate(subtypesResult);
return equalitiesResult;
}
use of org.checkerframework.framework.util.typeinference.solver.ConstraintMap in project checker-framework by typetools.
the class DefaultTypeArgumentInference method inferFromArguments.
/**
* Step 2. Infer type arguments from the equality (TisU) and the supertype (TSuperU) constraints
* of the methods arguments.
*/
private Pair<InferenceResult, InferenceResult> inferFromArguments(final AnnotatedTypeFactory typeFactory, final Set<AFConstraint> afArgumentConstraints, final Set<TypeVariable> targets) {
Set<TUConstraint> tuArgConstraints = afToTuConstraints(afArgumentConstraints, targets);
addConstraintsBetweenTargets(tuArgConstraints, targets, false, typeFactory);
ConstraintMap argConstraints = constraintMapBuilder.build(targets, tuArgConstraints, typeFactory);
InferenceResult inferredFromArgEqualities = equalitiesSolver.solveEqualities(targets, argConstraints, typeFactory);
Set<TypeVariable> remainingTargets = inferredFromArgEqualities.getRemainingTargets(targets, true);
InferenceResult fromSupertypes = supertypesSolver.solveFromSupertypes(remainingTargets, argConstraints, typeFactory);
InferenceResult fromSubtypes = subtypesSolver.solveFromSubtypes(remainingTargets, argConstraints, typeFactory);
fromSupertypes.mergeSubordinate(fromSubtypes);
return Pair.of(inferredFromArgEqualities, fromSupertypes);
}
use of org.checkerframework.framework.util.typeinference.solver.ConstraintMap 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