Class VariableBounds
java.lang.Object
org.checkerframework.framework.util.typeinference8.types.VariableBounds
Data structure to stores the bounds of a variable.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionBounds on this variable.final ConstraintSetConstraints implied by complementary pairs of bounds found during incorporation.booleanWhether this variable has a throws bounds.Qualifier bounds on this variable.Saved bounds used in the event the first attempt at resolution fails.Saved qualifier bounds used in the event the first attempt at resolution fails. -
Constructor Summary
ConstructorsConstructorDescriptionVariableBounds(Variable variable, Java8InferenceContext context) Creates bounds forvariable. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddBound(Constraint parent, VariableBounds.BoundKind kind, AbstractType otherType) AddsotherTypeas bound against this variable.voidaddConstraintsFromComplementaryBounds(Constraint parent, VariableBounds.BoundKind kind, AbstractType boundType) Add constraints created via incorporation of the bound.voidaddConstraintsFromComplementaryBounds(VariableBounds.BoundKind kind, Set<? extends AbstractQualifier> s) Adds constraints from complementary bounds.voidaddConstraintsFromComplementaryQualifierBounds(VariableBounds.BoundKind kind, Set<? extends AbstractQualifier> qualifiers) Add constraints created via incorporation of the bound.voidaddQualifierBound(VariableBounds.BoundKind kind, Set<? extends AbstractQualifier> qualifiers) Addsqualifiersas a qualifier bound against this variable.booleanApply instantiations to all bounds and constraints of this variable.Return all lower bounds that are proper types.Returns all upper bounds that proper types.Returns the instantiation of this variable.Collection<? extends Variable> Return all variables mentioned in a bound against this variable.Returns the constraints generated when incorporating a capture bound.booleanReturn true if this has an instantiation.booleanDoes this bound set contain two bounds of the formsS1 <: varandS2 <: var, where S1 and S2 have supertypes that are two different parameterizations of the same generic class or interface?booleanReturns true if any bound mentions a primitive wrapper type.booleanReturns true if there exists an equal or lower bound against a type, S, such that S is not a subtype ofG<...>, but S is a subtype of the raw type|G<...>|, whereGa generic class or interface for which the parameter of this method,t, is a parameterization.booleanReturn true if this has a throws bound.booleanReturns true if any lower or equal bound is a parameterized type with at least one wildcard as a type argument.booleanReturns whether this variable only has bounds against proper types.voidrestore()Restore the bounds to the state previously saved.voidsave()Save the current bounds in case the first attempt at resolution fails.voidsetHasThrowsBound(boolean b) Set has throws boundReturns all upper bounds.
-
Field Details
-
bounds
Bounds on this variable. Stored as a map from kind of bound (upper, lower, equal) to a set ofAbstractTypes. -
qualifierBounds
Qualifier bounds on this variable. Stored as a map from kind of bound (upper, lower, equal) to a set ofAnnotationMirrors. A qualifier bound is a bound on the primary annotation of this variable. -
constraints
Constraints implied by complementary pairs of bounds found during incorporation. -
hasThrowsBound
public boolean hasThrowsBoundWhether this variable has a throws bounds. -
savedBounds
Saved bounds used in the event the first attempt at resolution fails. -
savedQualifierBounds
Saved qualifier bounds used in the event the first attempt at resolution fails.
-
-
Constructor Details
-
VariableBounds
Creates bounds forvariable.- Parameters:
variable- a variablecontext- the context
-
-
Method Details
-
save
public void save()Save the current bounds in case the first attempt at resolution fails. -
restore
public void restore()Restore the bounds to the state previously saved. This method is called if the first attempt at resolution fails. -
hasThrowsBound
public boolean hasThrowsBound()Return true if this has a throws bound.- Returns:
- true if this has a throws bound
-
setHasThrowsBound
public void setHasThrowsBound(boolean b) Set has throws bound- Parameters:
b- has thrown bound
-
addBound
AddsotherTypeas bound against this variable.- Parameters:
parent- the constraint whose reduction created this boundkind- the kind of boundotherType- the bound type- Returns:
- if a new bound was added
-
addQualifierBound
public void addQualifierBound(VariableBounds.BoundKind kind, Set<? extends AbstractQualifier> qualifiers) Addsqualifiersas a qualifier bound against this variable.- Parameters:
kind- the kind of boundqualifiers- the qualifiers
-
addConstraintsFromComplementaryQualifierBounds
public void addConstraintsFromComplementaryQualifierBounds(VariableBounds.BoundKind kind, Set<? extends AbstractQualifier> qualifiers) Add constraints created via incorporation of the bound. See JLS 18.3.1.- Parameters:
kind- the kind of boundqualifiers- the qualifiers
-
addConstraintsFromComplementaryBounds
public void addConstraintsFromComplementaryBounds(Constraint parent, VariableBounds.BoundKind kind, AbstractType boundType) Add constraints created via incorporation of the bound. See JLS 18.3.1.- Parameters:
parent- the constraint whose reduction created this boundkind- the kind of boundboundType- the type of the bound
-
addConstraintsFromComplementaryBounds
public void addConstraintsFromComplementaryBounds(VariableBounds.BoundKind kind, Set<? extends AbstractQualifier> s) Adds constraints from complementary bounds.- Parameters:
kind- kind of bounds- qualifiers
-
onlyProperBounds
public boolean onlyProperBounds()Returns whether this variable only has bounds against proper types.- Returns:
- whether this variable only has bounds against proper types
-
findProperLowerBounds
Return all lower bounds that are proper types.- Returns:
- all lower bounds that are proper types
-
findProperUpperBounds
Returns all upper bounds that proper types.- Returns:
- all upper bounds that are proper types
-
upperBounds
Returns all upper bounds.- Returns:
- all upper bounds
-
applyInstantiationsToBounds
public boolean applyInstantiationsToBounds()Apply instantiations to all bounds and constraints of this variable.- Returns:
- whether any of the bounds changed
-
getVariablesMentionedInBounds
Return all variables mentioned in a bound against this variable.- Returns:
- all variables mentioned in a bound against this variable
-
getInstantiation
Returns the instantiation of this variable.- Returns:
- the instantiation of this variable
-
hasInstantiation
public boolean hasInstantiation()Return true if this has an instantiation.- Returns:
- true if this has an instantiation
-
hasPrimitiveWrapperBound
public boolean hasPrimitiveWrapperBound()Returns true if any bound mentions a primitive wrapper type.- Returns:
- true if any bound mentions a primitive wrapper type
-
hasWildcardParameterizedLowerOrEqualBound
public boolean hasWildcardParameterizedLowerOrEqualBound()Returns true if any lower or equal bound is a parameterized type with at least one wildcard as a type argument.- Returns:
- true if any lower or equal bound is a parameterized type with at least one wildcard for a type argument
-
hasLowerBoundDifferentParam
public boolean hasLowerBoundDifferentParam()Does this bound set contain two bounds of the formsS1 <: varandS2 <: var, where S1 and S2 have supertypes that are two different parameterizations of the same generic class or interface?- Returns:
- whether this bound set contain two bounds of the forms
S1 <: varandS2 <: var, where S1 and S2 have supertypes that are two different parameterizations of the same generic class or interface
-
hasRawTypeLowerOrEqualBound
Returns true if there exists an equal or lower bound against a type, S, such that S is not a subtype ofG<...>, but S is a subtype of the raw type|G<...>|, whereGa generic class or interface for which the parameter of this method,t, is a parameterization.- Parameters:
t- a parameterization of a generic class or interface,G- Returns:
- true if there exists an equal or lower bound against a type, S, such that S is not a
subtype of
G<...>, but S is a subtype of the raw type|G<...>|, whereGa generic class or interface for which the parameter of this method,t, is a parameterization.
-
getWildcardConstraints
Returns the constraints generated when incorporating a capture bound. See JLS 18.3.2.- Parameters:
Ai- the captured type argumentBi- the bound of the type variable- Returns:
- constraints generated when incorporating a capture bound
-