java.lang.Object
org.checkerframework.framework.util.typeinference8.constraint.TypeConstraint
org.checkerframework.framework.util.typeinference8.constraint.Expression
All Implemented Interfaces:
Constraint, ReductionResult

public class Expression extends TypeConstraint
<Expression → T> An expression is compatible in a loose invocation context with type T
  • Constructor Details

    • Expression

      public Expression(Constraint parent, ExpressionTree expressionTree, AbstractType t)
      Creates an expression constraint.
      Parameters:
      parent - the constraint whose reduction created this constraint
      expressionTree - the expression for the constraint
      t - the type that the expression is compatible in a loose invocation context
    • Expression

      public Expression(String source, ExpressionTree expressionTree, AbstractType t)
      Creates an expression constraint.
      Parameters:
      source - a string describing where this constraint came from
      expressionTree - the expression for the constraint
      t - the type that the expression is compatible in a loose invocation context
  • Method Details

    • getKind

      public Constraint.Kind getKind()
      Description copied from interface: Constraint
      Returns the kind of constraint.
      Returns:
      the kind of constraint
    • getInputVariables

      public Set<Variable> getInputVariables()
      Description copied from interface: Constraint
      Returns the input variables of this constraint: the inference variables that must be resolved before this constraint may be reduced.

      For lambda, method reference, and additional-argument constraints, input variables are roughly the inference variables mentioned by the target function type's parameter types. For conditional expression constraints and switch expression constraints, input variables are the union of the input variables of their subexpressions. For all other constraints, no input variables exist.

      Defined in JLS section 18.5.2.2. (Constraint.Kind.ADDITIONAL_ARG constraints are this implementation's own addition, not a JLS-defined constraint kind, but they need the same ordering treatment: see AdditionalArgument.)

      Callers that need to mutate the result should make a defensive copy first.

      Returns:
      the input variables of this constraint
    • getOutputVariables

      public Set<Variable> getOutputVariables()
      Description copied from class: TypeConstraint
      "The output variables of [expression] constraints are all inference variables mentioned by the type on the right-hand side of the constraint, T, that are not input variables."

      As defined in JLS section 18.5.2.2

      Callers that need to mutate the result should make a defensive copy first.

      Specified by:
      getOutputVariables in class TypeConstraint
      Returns:
      output variables for this constraint
    • reduce

      public ReductionResult reduce(Java8InferenceContext context)
      Description copied from interface: Constraint
      Reduce this constraint what this means depends on the kind of constraint. Reduction can produce new bounds and/or new constraints.

      Reduction is documented in JLS section 18.2

      Parameters:
      context - Java8InferenceContext
      Returns:
      the result of reducing this constraint
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class TypeConstraint
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class TypeConstraint