java.lang.Object
org.checkerframework.framework.util.typeinference8.types.AbstractType
org.checkerframework.framework.util.typeinference8.types.ProperType

public class ProperType extends AbstractType
A type that does not contain any inference variables.
  • Constructor Details

    • ProperType

      public ProperType(AnnotatedTypeMirror type, Java8InferenceContext context)
      Creates a proper type.
      Parameters:
      type - the annotated type
      context - the context
    • ProperType

      public ProperType(AnnotatedTypeMirror type, Java8InferenceContext context, boolean ignoreAnnotations)
      Creates a proper type.
      Parameters:
      type - the annotated type
      context - the context
      ignoreAnnotations - true if the annotations on this type should be ignored
    • ProperType

      public ProperType(AnnotatedTypeMirror type, AnnotationMirrorMap<QualifierVar> qualifierVars, Java8InferenceContext context, boolean ignoreAnnotations)
      Creates a proper type.
      Parameters:
      type - the annotated type
      qualifierVars - a mapping from polymorphic annotation to QualifierVar
      context - the context
      ignoreAnnotations - true if the annotations on this type should be ignored
    • ProperType

      public ProperType(ExpressionTree tree, Java8InferenceContext context)
      Creates a proper type from the type of the expression.
      Parameters:
      tree - an expression tree
      context - the context
    • ProperType

      public ProperType(VariableTree varTree, Java8InferenceContext context)
      Creates a proper type from the type of the variable.
      Parameters:
      varTree - a variable tree
      context - the context
  • Method Details

    • getKind

      public AbstractType.Kind getKind()
      Description copied from class: AbstractType
      Returns the kind of AbstractType.
      Specified by:
      getKind in class AbstractType
      Returns:
      the kind of AbstractType
    • create

      public AbstractType create(AnnotatedTypeMirror atm, boolean ignoreAnnotations)
      Creates a type using the given types.

      type is ignored, because the Java type of a proper type is the underlying type of its annotated type. (Callers such as AbstractType.getErased() do not always pass atm.getUnderlyingType() as type.)

      Specified by:
      create in class AbstractType
      Parameters:
      atm - annotated type mirror
      ignoreAnnotations - true if the annotations on this type should be ignored
      Returns:
      the new type
    • boxType

      public ProperType boxType()
      If this is a primitive type, then the proper type corresponding to its wrapper is returned. Otherwise, this object is return.
      Returns:
      the proper type that is the wrapper type for this type or this if no such wrapper exists
    • isSubType

      public ReductionResult isSubType(ProperType superType)
      Is this a subtype of superType?
      Parameters:
      superType - super type
      Returns:
      if this is a subtype of superType, then return ConstraintSet.TRUE; otherwise, a false bound is returned
    • isSubTypeUnchecked

      public ReductionResult isSubTypeUnchecked(ProperType superType)
      Is this an unchecked subtype of superType?
      Parameters:
      superType - super type
      Returns:
      if this is an unchecked subtype of superType, then return ConstraintSet.TRUE; otherwise, a false bound is returned
    • isAssignable

      public ReductionResult isAssignable(ProperType superType)
      Is this assignable to superType?
      Parameters:
      superType - super type
      Returns:
      if this is assignable to superType, then return ConstraintSet.TRUE; otherwise, a false bound is returned
    • checkAnnotationEquality

      public ConstraintSet checkAnnotationEquality(ProperType other)
      Checks whether the annotations of this are the same as those of other, assuming that their underlying Java types have already been found to be the same. If either type is marked as having annotations that should be ignored, then the annotations are not compared.

      Neither type may be an uncaptured wildcard: the type hierarchy compares a wildcard's extends bound against the other type, which for a lower-bounded wildcard is not the bound that holds its qualifiers.

      The type hierarchy compares a polymorphic qualifier as though it were concrete, so it reports a conflict with every qualifier that the polymorphic qualifier could be instantiated to; see AbstractQualifier.isUnsolvedPolymorphic() for why inference cannot solve for the qualifier instead. If the comparison fails, it is therefore retried on copies in which each polymorphic qualifier has been replaced by the qualifier it is compared against; see Java8InferenceContext.replacePolymorphicQualifiers(org.checkerframework.framework.type.AnnotatedTypeMirror, org.checkerframework.framework.type.AnnotatedTypeMirror). The retry suppresses only the positions and qualifier hierarchies that a polymorphic qualifier occupies, so a conflict at another type argument, or one in another qualifier hierarchy, is still reported.

      Parameters:
      other - the type to compare against
      Returns:
      ConstraintSet.TRUE if the annotations are ignored or if the annotations of this are the same as those of other; otherwise ConstraintSet.TRUE_ANNO_FAIL
    • equals

      public boolean equals(Object o)
      Specified by:
      equals in class AbstractType
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in class AbstractType
    • getJavaType

      public TypeMirror getJavaType()
      Description copied from class: AbstractType
      Returns the underlying Java type without inference variables.
      Specified by:
      getJavaType in class AbstractType
      Returns:
      the underlying Java type without inference variables
    • getAnnotatedType

      public AnnotatedTypeMirror getAnnotatedType()
      Description copied from class: AbstractType
      Returns the underlying annotated type.
      Specified by:
      getAnnotatedType in class AbstractType
      Returns:
      the underlying annotated type
    • isObject

      public boolean isObject()
      Description copied from class: AbstractType
      Returns true if this type is java.lang.Object.
      Specified by:
      isObject in class AbstractType
      Returns:
      true if this type is java.lang.Object
    • getInferenceVariables

      public Collection<Variable> getInferenceVariables()
      Description copied from class: AbstractType
      Returns a collection of all inference variables referenced by this type.
      Specified by:
      getInferenceVariables in class AbstractType
      Returns:
      a collection of all inference variables referenced by this type
    • applyInstantiations

      public AbstractType applyInstantiations()
      Description copied from class: AbstractType
      Returns a new type that is the same as this one except the variables in instantiations have been replaced by their instantiation.
      Specified by:
      applyInstantiations in class AbstractType
      Returns:
      a new type that is the same as this one except the variables in instantiations have been replaced by their instantiation
    • getQualifiers

      public Set<AbstractQualifier> getQualifiers()
      Description copied from class: AbstractType
      Returns the primary qualifiers on this type.
      Specified by:
      getQualifiers in class AbstractType
      Returns:
      the primary qualifiers on this type
    • toString

      public String toString()
      Overrides:
      toString in class Object