Class BoundSet
java.lang.Object
org.checkerframework.framework.util.typeinference8.bound.BoundSet
- All Implemented Interfaces:
ReductionResult
Manages a set of bounds. Bounds are stored in the variable to which they apply, except for
capture bounds which are stored in this class.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.checkerframework.framework.util.typeinference8.constraint.ReductionResult
ReductionResult.ReductionResultPair
-
Field Summary
Modifier and TypeFieldDescriptionboolean
If true, then type argument inference failed because an annotated type could not be inferred.The error message to report to users.static final int
Max number of incorporation loops.Fields inherited from interface org.checkerframework.framework.util.typeinference8.constraint.ReductionResult
UNCHECKED_CONVERSION
-
Constructor Summary
ConstructorDescriptionCopy constructor.BoundSet
(Java8InferenceContext context) Creates a bound set. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCapture
(CaptureBound capture) Addscapture
to this bound set.void
addFalse()
Adds the false bound to this bound set.boolean
Does the bound set contain a bound of the formG<..., ai, ...> = capture(G<...>)
for any variable inas
?boolean
Return whether this bound set contains false.Returns the dependencies between variables.getDependencies
(Collection<Variable> additionalVars) Adds theadditionalVars
to this bound set and returns the dependencies between all variables in this bound set.Returns a list of all variables in this bound set that are instantiated.getInstantiationsInAlphas
(Collection<Variable> alphas) Returns a list of variables inalphas
that are instantiated.void
incorporateToFixedPoint
(BoundSet newBounds) IncorporatesnewBounds
into this bounds set.static BoundSet
initialBounds
(Theta theta, Java8InferenceContext context) Creates a new bound set for the variables in theta.boolean
Return whether unchecked conversion was necessary to reduce and incorporate this bound setboolean
MergesnewSet
into this bound set.void
removeCaptures
(Set<Variable> as) Remove any capture bound that mentions any variable inas
.resolve()
Resolve all inference variables mentioned in any bound.void
restore()
Restore the bounds to the last saved state.void
Save the current state of the variables so they can be restored if the first attempt at resolution fails.void
setUncheckedConversion
(boolean uncheckedConversion) Sets whether unchecked conversion was necessary to reduce and incorporate this bound set.toString()
-
Field Details
-
MAX_INCORPORATION_STEPS
public static final int MAX_INCORPORATION_STEPSMax number of incorporation loops. Use same constant asInfer.MAX_INCORPORATION_STEPS
- See Also:
-
annoInferenceFailed
public boolean annoInferenceFailedIf true, then type argument inference failed because an annotated type could not be inferred. -
errorMsg
The error message to report to users.
-
-
Constructor Details
-
BoundSet
Creates a bound set.- Parameters:
context
- the context
-
BoundSet
Copy constructor.- Parameters:
toCopy
- bound set to copy
-
-
Method Details
-
saveBounds
public void saveBounds()Save the current state of the variables so they can be restored if the first attempt at resolution fails. -
restore
public void restore()Restore the bounds to the last saved state. This method is called if the first attempt at resolution fails. -
initialBounds
Creates a new bound set for the variables in theta. (The initial bounds for the variables were added to the variables when theta was created.)- Parameters:
theta
- a Map from type variable to inference variablecontext
- inference context- Returns:
- initial bounds
-
merge
MergesnewSet
into this bound set.- Parameters:
newSet
- bound set to merge- Returns:
- whether the merge changed this bound set
-
addFalse
public void addFalse()Adds the false bound to this bound set. -
containsFalse
public boolean containsFalse()Return whether this bound set contains false.- Returns:
- whether this bound set contains false
-
isUncheckedConversion
public boolean isUncheckedConversion()Return whether unchecked conversion was necessary to reduce and incorporate this bound set- Returns:
- whether unchecked conversion was necessary to reduce and incorporate this bound set
-
setUncheckedConversion
public void setUncheckedConversion(boolean uncheckedConversion) Sets whether unchecked conversion was necessary to reduce and incorporate this bound set.- Parameters:
uncheckedConversion
- whether unchecked conversion was necessary to reduce and incorporate this bound set
-
addCapture
Addscapture
to this bound set.- Parameters:
capture
- a capture bound
-
containsCapture
Does the bound set contain a bound of the formG<..., ai, ...> = capture(G<...>)
for any variable inas
?- Parameters:
as
- a collection of varialbes- Returns:
- whether the bound set contain a bound of the form
G<..., ai, ...> = capture(G<...>)
for any variable inas
-
getInstantiationsInAlphas
Returns a list of variables inalphas
that are instantiated.- Parameters:
alphas
- a list of variables- Returns:
- a list of variables in
alphas
that are instantiated
-
getInstantiatedVariables
Returns a list of all variables in this bound set that are instantiated.- Returns:
- a list of all variables in this bound set that are instantiated
-
resolve
Resolve all inference variables mentioned in any bound.- Returns:
- a list of resolved variables in this bounds set
-
getDependencies
Returns the dependencies between variables.- Returns:
- the dependencies between variables
-
getDependencies
Adds theadditionalVars
to this bound set and returns the dependencies between all variables in this bound set.- Parameters:
additionalVars
- variables to add to this bound set- Returns:
- the dependencies between all variables in this bound set
-
incorporateToFixedPoint
IncorporatesnewBounds
into this bounds set.Incorporation creates new constraints that are then reduced to a bound set which is further incorporated into this bound set. Incorporation terminates when the bounds set has reached a fixed point. JLS 18 .1 defines this fixed point and further explains incorporation.
- Parameters:
newBounds
- bounds to incorporate
-
removeCaptures
Remove any capture bound that mentions any variable inas
.- Parameters:
as
- a set of variables
-
toString
-