java.lang.Object
org.checkerframework.framework.util.typeinference8.InferenceResult

public class InferenceResult extends Object
The result of type argument inferrece.
  • Constructor Details

    • InferenceResult

      public InferenceResult(Collection<Variable> variables, boolean uncheckedConversion, boolean annoInferenceFailed, String errorMsg)
      Creates an inference result.
      Parameters:
      variables - instantiated variables
      uncheckedConversion - where unchecked conversion was required to infer the type arguments
      annoInferenceFailed - true if inference failed because of annotations
      errorMsg - message to report to users if inference failed
    • InferenceResult

      public InferenceResult(Collection<Variable> variables, boolean uncheckedConversion, boolean annoInferenceFailed, boolean inferenceCrashed, String errorMsg)
      Creates an inference result.
      Parameters:
      variables - instantiated variables
      uncheckedConversion - where unchecked conversion was required to infer the type arguments
      annoInferenceFailed - true if inference failed because of annotations
      inferenceCrashed - the type argument inference code crashed
      errorMsg - message to report to users if inference failed
    • InferenceResult

      public InferenceResult(Collection<Variable> variables, boolean uncheckedConversion, boolean annoInferenceFailed, boolean inferenceCrashed, boolean inferenceBudgetExceeded, String errorMsg)
      Creates an inference result.
      Parameters:
      variables - instantiated variables
      uncheckedConversion - where unchecked conversion was required to infer the type arguments
      annoInferenceFailed - whether inference failed because of annotations
      inferenceCrashed - the type argument inference code crashed
      inferenceBudgetExceeded - inference was abandoned because it exceeded its work budget
      errorMsg - message to report to users if inference failed
  • Method Details

    • emptyResult

      public static InferenceResult emptyResult()
      Returns an empty inference result.
      Returns:
      an empty inference result
    • getResults

      public Map<Tree,Map<TypeVariable,AnnotatedTypeMirror>> getResults()
      A mapping from a tree that needs type argument inference to a map from type parameter to its inferred annotated type argument. Empty when inference inferenceCrashed() or inferenceBudgetExceeded(). Otherwise populated with the resolved type arguments, even when inferenceFailed() due to an annotated (qualifier) mismatch: those are the best-effort arguments Java-level resolution reached before the qualifiers were found unsatisfiable, not arguments that have been checked against the annotated bounds.
      Returns:
      mapping from a tree that needs type argument inference to a map from type parameter to its inferred annotated type argument
    • isUncheckedConversion

      public boolean isUncheckedConversion()
      True if unchecked conversion was necessary to infer the type arguments.
      Returns:
      true if unchecked conversion was necessary to infer the type arguments
    • inferenceFailed

      public boolean inferenceFailed()
      True if type argument inference failed because an annotated type could not be inferred.
      Returns:
      true if type argument inference failed because an annotated type could not be inferred
    • inferenceCrashed

      public boolean inferenceCrashed()
      True if inference crashed.
      Returns:
      true if inference crashed
    • inferenceBudgetExceeded

      public boolean inferenceBudgetExceeded()
      Whether inference was abandoned because it exceeded its work budget. This is a deliberate give-up (the invocation is too complex to infer), not a crash.
      Returns:
      whether inference exceeded its work budget
    • needsDefaultedReturnType

      public boolean needsDefaultedReturnType()
      Whether the return type must be defaulted because inference did not produce usable type arguments (it crashed or was abandoned for exceeding its budget). In that case the inferred return type would not have the correct Java type, which can crash later framework code.
      Returns:
      whether the return type must be defaulted
    • getTypeArgumentsForExpression

      public Map<TypeVariable,AnnotatedTypeMirror> getTypeArgumentsForExpression(ExpressionTree expressionTree)
      Returns a mapping from type variable to its type argument for the expressionTree.
      Parameters:
      expressionTree - a tree for which type arguments were inferred
      Returns:
      a mapping from type variable to its type argument for the expressionTree
    • getErrorMsg

      public String getErrorMsg()
      An error message to report to the user.
      Returns:
      an error message to report to the user
    • copyFor

      Returns a copy of this result for another computation of the same method type, methodType, of tree: its type arguments are deep copies, so that a caller can modify them, and they are keyed by the type variables of methodType.
      Parameters:
      methodType - the type of the method or constructor before type argument substitution
      tree - the tree whose type arguments this result contains
      Returns:
      a copy of this result for methodType