Class TypeVariableBinding

Direct Known Subclasses:
CaptureBinding, InferenceVariable

public class TypeVariableBinding extends ReferenceBinding
Binding for a type parameter, held by source/binary type or method.
  • Field Details

    • declaringElement

      public Binding declaringElement
    • rank

      public int rank
    • firstBound

      public TypeBinding firstBound
      Denote the first explicit (binding) bound amongst the supertypes (from declaration in source) If no superclass was specified, then it denotes the first superinterface, or null if none was specified.
    • superclass

      public ReferenceBinding superclass
    • superInterfaces

      public ReferenceBinding[] superInterfaces
    • genericTypeSignature

      public char[] genericTypeSignature
  • Constructor Details

    • TypeVariableBinding

      public TypeVariableBinding(char[] sourceName, Binding declaringElement, int rank, LookupEnvironment environment)
    • TypeVariableBinding

      protected TypeVariableBinding(char[] sourceName, LookupEnvironment environment)
    • TypeVariableBinding

      public TypeVariableBinding(TypeVariableBinding prototype)
  • Method Details

    • boundCheck

      public TypeConstants.BoundCheckStatus boundCheck(Substitution substitution, TypeBinding argumentType, Scope scope, ASTNode location)
      Returns true if the argument type satisfies all bounds of the type parameter
      Parameters:
      location - if non-null this may be used for reporting errors relating to null type annotations (if enabled)
    • boundsCount

      public int boundsCount()
    • canBeInstantiated

      public boolean canBeInstantiated()
      Description copied from class: ReferenceBinding
      Answer true if the receiver can be instantiated
      Overrides:
      canBeInstantiated in class ReferenceBinding
      See Also:
      • invalid reference
        org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding#canBeInstantiated()
    • collectMissingTypes

      public List<TypeBinding> collectMissingTypes(List<TypeBinding> missingTypes)
      Description copied from class: TypeBinding
      Iterate through the type components to collect instances of leaf missing types
      Overrides:
      collectMissingTypes in class TypeBinding
      Returns:
      missing types
    • collectSubstitutes

      public void collectSubstitutes(Scope scope, TypeBinding actualType, InferenceContext inferenceContext, int constraint)
      Collect the substitutes into a map for certain type variables inside the receiver type e.g. Collection<T>.collectSubstitutes(Collection<List<X>>, Map) will populate Map with: T --> List<X>
      
       Constraints:
         A << F   corresponds to:   F.collectSubstitutes(..., A, ..., CONSTRAINT_EXTENDS (1))
         A = F    corresponds to:   F.collectSubstitutes(..., A, ..., CONSTRAINT_EQUAL (0))
         A >> F   corresponds to:   F.collectSubstitutes(..., A, ..., CONSTRAINT_SUPER (2))
       
      Overrides:
      collectSubstitutes in class TypeBinding
    • computeUniqueKey

      public char[] computeUniqueKey(boolean isLeaf)
      Description copied from class: ReferenceBinding
      p.X<T extends Y & I, U extends Y> -> Lp/X<TT;TU;>;
      Overrides:
      computeUniqueKey in class ReferenceBinding
    • constantPoolName

      public char[] constantPoolName()
      Description copied from class: ReferenceBinding
      Answer the receiver's constant pool name. NOTE: This method should only be used during/after code gen.
      Overrides:
      constantPoolName in class ReferenceBinding
    • clone

      public TypeBinding clone(TypeBinding enclosingType)
      Description copied from class: TypeBinding
      Virtual copy constructor: a copy is made of the receiver's entire instance state and then suitably parameterized by the arguments to the clone operation as seen fit by each type. Parameters may not make sense for every type in the hierarchy, in which case they are silently ignored. A type may choose to retain a copy of the prototype for reference.
      Overrides:
      clone in class TypeBinding
    • annotatedDebugName

      public String annotatedDebugName()
      Overrides:
      annotatedDebugName in class TypeBinding
    • debugName

      public String debugName()
      Overrides:
      debugName in class ReferenceBinding
      See Also:
      • invalid reference
        org.eclipse.jdt.internal.compiler.lookup.TypeBinding#debugName()
    • erasure

      public TypeBinding erasure()
      Overrides:
      erasure in class TypeBinding
    • genericSignature

      public char[] genericSignature()
      
       T::Ljava/util/Map;:Ljava/io/Serializable;
       T:LY<TT;>
       
    • genericTypeSignature

      public char[] genericTypeSignature()
      
       T::Ljava/util/Map;:Ljava/io/Serializable;
       T:LY<TT;>
       
      Overrides:
      genericTypeSignature in class TypeBinding
    • hasTypeBit

      public boolean hasTypeBit(int bit)
      Description copied from class: TypeBinding
      Answer an additional bit characterizing this type, like TypeIds.BitAutoCloseable.
      Overrides:
      hasTypeBit in class TypeBinding
    • isErasureBoundTo

      public boolean isErasureBoundTo(TypeBinding type)
      Returns true if the type variable is directly bound to a given type
    • isHierarchyConnected

      public boolean isHierarchyConnected()
      Description copied from class: ReferenceBinding
      Returns true if the type hierarchy is connected
      Overrides:
      isHierarchyConnected in class ReferenceBinding
    • isInterchangeableWith

      public boolean isInterchangeableWith(TypeVariableBinding otherVariable, Substitution substitute)
      Returns true if the 2 variables are playing exact same role: they have the same bounds, providing one is substituted with the other: <T1 extends List<T1>> is interchangeable with <T2 extends List<T2>>.
    • isSubtypeOf

      public boolean isSubtypeOf(TypeBinding other, boolean simulatingBugJDK8026527)
      Overrides:
      isSubtypeOf in class ReferenceBinding
    • enterRecursiveFunction

      public boolean enterRecursiveFunction()
      Description copied from class: TypeBinding
      Call this before descending into type details to prevent infinite recursion.
      Overrides:
      enterRecursiveFunction in class TypeBinding
      Returns:
      true if a recursion was not already started.
    • exitRecursiveFunction

      public void exitRecursiveFunction()
      Description copied from class: TypeBinding
      Exit the context of a potentially recursive function.
      Overrides:
      exitRecursiveFunction in class TypeBinding
    • enterRecursiveProjectionFunction

      public boolean enterRecursiveProjectionFunction()
    • exitRecursiveProjectionFunction

      public void exitRecursiveProjectionFunction()
    • isProperType

      public boolean isProperType(boolean admitCapture18)
      Description copied from class: TypeBinding
      JLS8 Sect 18.1.1
      Overrides:
      isProperType in class ReferenceBinding
      Parameters:
      admitCapture18 - request if CaptureBinding18 shuld be considered as a proper type. If unsure say 'true', only in Scope.greaterLowerBound(TypeBinding[], Scope, LookupEnvironment) CaptureBinding18 has to be excluded to prevent an NPE on a branch that heuristically tries to avoid inconsistent intersections.
    • isTypeVariable

      public boolean isTypeVariable()
      Returns true if the type was declared as a type variable
      Overrides:
      isTypeVariable in class TypeBinding
    • isSealed

      public boolean isSealed()
      Description copied from class: ReferenceBinding
      Answer true if the receiver has sealed modifier
      Overrides:
      isSealed in class ReferenceBinding
    • permittedTypes

      public ReferenceBinding[] permittedTypes()
      Overrides:
      permittedTypes in class TypeBinding
    • kind

      public int kind()
      Overrides:
      kind in class TypeBinding
    • mentionsAny

      public boolean mentionsAny(TypeBinding[] parameters, int idx)
      Description copied from class: TypeBinding
      Does this type mention any of the given type parameters, except the one at position 'idx'?
      Overrides:
      mentionsAny in class TypeBinding
    • otherUpperBounds

      public TypeBinding[] otherUpperBounds()
    • readableName

      public char[] readableName()
      Description copied from class: ReferenceBinding
      Answer the receiver's signature. NOTE: This method should only be used during/after code gen.
      Overrides:
      readableName in class ReferenceBinding
      See Also:
      • invalid reference
        org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding#readableName()
    • setTypeAnnotations

      public void setTypeAnnotations(AnnotationBinding[] annotations, boolean evalNullAnnotations)
      Overrides:
      setTypeAnnotations in class TypeBinding
    • shortReadableName

      public char[] shortReadableName()
      Overrides:
      shortReadableName in class ReferenceBinding
      See Also:
      • invalid reference
        org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding#shortReadableName()
    • superclass

      public ReferenceBinding superclass()
      Overrides:
      superclass in class ReferenceBinding
    • superInterfaces

      public ReferenceBinding[] superInterfaces()
      Overrides:
      superInterfaces in class ReferenceBinding
    • toString

      public String toString()
      Overrides:
      toString in class Object
      See Also:
    • nullAnnotatedReadableName

      public char[] nullAnnotatedReadableName(CompilerOptions options, boolean shortNames)
      Description copied from class: TypeBinding
      Answer a readable name (for error reporting) that includes nullness type annotations.
      Overrides:
      nullAnnotatedReadableName in class ReferenceBinding
      See Also:
      • invalid reference
        org.eclipse.jdt.internal.compiler.lookup.TypeBinding#nullAnnotatedReadableName(CompilerOptions,boolean)
    • appendNullAnnotation

      protected void appendNullAnnotation(StringBuilder nameBuffer, CompilerOptions options)
      Overrides:
      appendNullAnnotation in class ReferenceBinding
    • unannotated

      public TypeBinding unannotated()
      Description copied from class: TypeBinding
      Return this type minus its type annotations
      Overrides:
      unannotated in class TypeBinding
    • withoutToplevelNullAnnotation

      public TypeBinding withoutToplevelNullAnnotation()
      Description copied from class: TypeBinding
      Return this type minus its toplevel null annotations. Any annotations on type arguments or bounds are retained.
      Overrides:
      withoutToplevelNullAnnotation in class TypeBinding
    • upperBound

      public TypeBinding upperBound()
      Upper bound doesn't perform erasure
    • allUpperBounds

      public TypeBinding[] allUpperBounds()
    • evaluateNullAnnotations

      public void evaluateNullAnnotations(Scope scope, TypeParameter parameter)
    • setFirstBound

      public TypeBinding setFirstBound(TypeBinding firstBound)
    • setSuperClass

      public ReferenceBinding setSuperClass(ReferenceBinding superclass)
    • setSuperInterfaces

      public ReferenceBinding[] setSuperInterfaces(ReferenceBinding[] superInterfaces)
    • getDerivedTypesForDeferredInitialization

      protected TypeBinding[] getDerivedTypesForDeferredInitialization()
    • combineTypeAnnotations

      public TypeBinding combineTypeAnnotations(TypeBinding substitute)
    • acceptsNonNullDefault

      public boolean acceptsNonNullDefault()
      Description copied from class: TypeBinding
      Used to implement this sentence from o.e.j.annotation.DefaultLocation: "Wildcards and the use of type variables are always excluded from NonNullByDefault."
      Overrides:
      acceptsNonNullDefault in class ReferenceBinding
    • updateTagBits

      public long updateTagBits()
      Description copied from class: TypeBinding
      Refresh some tagBits from details into the main type. Currently handled: TagBits.HasNullTypeAnnotation
      Overrides:
      updateTagBits in class TypeBinding
    • isFreeTypeVariable

      public boolean isFreeTypeVariable()
      Overrides:
      isFreeTypeVariable in class TypeBinding
    • upwardsProjection

      public TypeBinding upwardsProjection(Scope scope, TypeBinding[] mentionedTypeVariables)
      Description copied from class: ReferenceBinding
      Perform an upwards type projection as per JLS 4.10.5
      Overrides:
      upwardsProjection in class ReferenceBinding
      Parameters:
      scope - Relevant scope for evaluating type projection
      mentionedTypeVariables - Filter for mentioned type variabled
      Returns:
      Upwards type projection of 'this', or null if downwards projection is undefined
    • downwardsProjection

      public TypeBinding downwardsProjection(Scope scope, TypeBinding[] mentionedTypeVariables)
      Description copied from class: ReferenceBinding
      Perform a downwards type projection as per JLS 4.10.5
      Overrides:
      downwardsProjection in class ReferenceBinding
      Parameters:
      scope - Relevant scope for evaluating type projection
      mentionedTypeVariables - Filter for mentioned type variabled
      Returns:
      Downwards type projection of 'this', or null if downwards projection is undefined