Class InferenceResult
java.lang.Object
org.checkerframework.framework.util.typeinference8.InferenceResult
The result of type argument inferrece.
-
Constructor Summary
ConstructorsConstructorDescriptionInferenceResult(Collection<Variable> variables, boolean uncheckedConversion, boolean annoInferenceFailed, boolean inferenceCrashed, boolean inferenceBudgetExceeded, String errorMsg) Creates an inference result.InferenceResult(Collection<Variable> variables, boolean uncheckedConversion, boolean annoInferenceFailed, boolean inferenceCrashed, String errorMsg) Creates an inference result.InferenceResult(Collection<Variable> variables, boolean uncheckedConversion, boolean annoInferenceFailed, String errorMsg) Creates an inference result. -
Method Summary
Modifier and TypeMethodDescriptioncopyFor(AnnotatedTypeMirror.AnnotatedExecutableType methodType, ExpressionTree tree) Returns a copy of this result for another computation of the same method type,methodType, oftree: its type arguments are deep copies, so that a caller can modify them, and they are keyed by the type variables ofmethodType.static InferenceResultReturns an empty inference result.An error message to report to the user.A mapping from a tree that needs type argument inference to a map from type parameter to its inferred annotated type argument.getTypeArgumentsForExpression(ExpressionTree expressionTree) Returns a mapping from type variable to its type argument for theexpressionTree.booleanWhether inference was abandoned because it exceeded its work budget.booleanTrue if inference crashed.booleanTrue if type argument inference failed because an annotated type could not be inferred.booleanTrue if unchecked conversion was necessary to infer the type arguments.booleanWhether the return type must be defaulted because inference did not produce usable type arguments (it crashed or was abandoned for exceeding its budget).
-
Constructor Details
-
InferenceResult
public InferenceResult(Collection<Variable> variables, boolean uncheckedConversion, boolean annoInferenceFailed, String errorMsg) Creates an inference result.- Parameters:
variables- instantiated variablesuncheckedConversion- where unchecked conversion was required to infer the type argumentsannoInferenceFailed- true if inference failed because of annotationserrorMsg- 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 variablesuncheckedConversion- where unchecked conversion was required to infer the type argumentsannoInferenceFailed- true if inference failed because of annotationsinferenceCrashed- the type argument inference code crashederrorMsg- 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 variablesuncheckedConversion- where unchecked conversion was required to infer the type argumentsannoInferenceFailed- whether inference failed because of annotationsinferenceCrashed- the type argument inference code crashedinferenceBudgetExceeded- inference was abandoned because it exceeded its work budgeterrorMsg- message to report to users if inference failed
-
-
Method Details
-
emptyResult
Returns an empty inference result.- Returns:
- an empty inference result
-
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 inferenceinferenceCrashed()orinferenceBudgetExceeded(). Otherwise populated with the resolved type arguments, even wheninferenceFailed()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 theexpressionTree.- Parameters:
expressionTree- a tree for which type arguments were inferred- Returns:
- a mapping from type variable to its type argument for the
expressionTree
-
getErrorMsg
An error message to report to the user.- Returns:
- an error message to report to the user
-
copyFor
public InferenceResult copyFor(AnnotatedTypeMirror.AnnotatedExecutableType methodType, ExpressionTree tree) Returns a copy of this result for another computation of the same method type,methodType, oftree: its type arguments are deep copies, so that a caller can modify them, and they are keyed by the type variables ofmethodType.- Parameters:
methodType- the type of the method or constructor before type argument substitutiontree- the tree whose type arguments this result contains- Returns:
- a copy of this result for
methodType
-