Interface JWildcardType

All Superinterfaces:
JTypeMirror, JTypeVisitable

public interface JWildcardType extends JTypeMirror
Represents a wildcard type. Such types are converted to JTypeVar by capture conversion.

This implements JTypeMirror for convenience, however, it may only occur as a type argument, and as such some of the behaviour of JTypeMirror is undefined: subtyping and erasure.

  • Method Details

    • getBound

      @NonNull JTypeMirror getBound()
      Returns the bound. Interpretation is given by isUpperBound().
    • isUnbounded

      default boolean isUnbounded()
      Returns true if this is an "extends" wildcard, with no bound ("?").
    • isUpperBound

      boolean isUpperBound()
      Returns true if this is an "extends" wildcard, the bound is then an upper bound.
    • isLowerBound

      default boolean isLowerBound()
      Returns true if this is a "super" wildcard, the bound is then a lower bound.
    • asLowerBound

      default @NonNull JTypeMirror asLowerBound()
      Returns the lower bound, or the bottom type if this is an "extends" wildcard.
    • asUpperBound

      default @NonNull JTypeMirror asUpperBound()
      Returns the upper bound, or Object if this is a "super" wildcard.
    • getErasure

      default JTypeMirror getErasure()
      This is implemented for convenience. However, the erasure of a wildcard type is undefined and useless. This is because they can only occur in type arguments, which are erased themselves.
      Specified by:
      getErasure in interface JTypeMirror
    • streamMethods

      default Stream<JMethodSig> streamMethods(Predicate<? super JMethodSymbol> prefilter)
      Description copied from interface: JTypeMirror
      Returns a stream of method signatures declared in and inherited by this type. Method signatures are created on-demand by this method, they're not reused between calls. This stream does not include constructors.

      Note: streams are a bit impractical when it comes to configuring the filter. Possibly a specialized API should be introduced. We need to support the use cases of the symbol table, ie filter by name + accessibility + staticity, and also possibly use cases for rules, like getting a method from a known signature. See also JClassType.getDeclaredMethod(JExecutableSymbol), which looks like this. Unifying this API would be nice.

      Specified by:
      streamMethods in interface JTypeMirror
      Parameters:
      prefilter - Filter selecting symbols for which a signature should be created and yielded by the stream
    • subst

      JWildcardType subst(Function<? super SubstVar,? extends @NonNull JTypeMirror> subst)
      Description copied from interface: JTypeVisitable
      Replace the type variables occurring in the given type by their image by the given function. Substitutions are not applied recursively (ie, is not applied on the result of a substitution).
      Specified by:
      subst in interface JTypeMirror
      Specified by:
      subst in interface JTypeVisitable
      Parameters:
      subst - Substitution function, eg a Substitution
    • withAnnotations

      JWildcardType withAnnotations(org.pcollections.PSet<SymbolicValue.SymAnnot> newTypeAnnots)
      Description copied from interface: JTypeMirror
      Returns a type mirror that is equal to this instance but has different type annotations. Note that some types ignore this method and return themselves without changing. Eg the null type or void type cannot be annotated.
      Specified by:
      withAnnotations in interface JTypeMirror
      Parameters:
      newTypeAnnots - New type annotations (not null)
      Returns:
      A new type, maybe this one
    • acceptVisitor

      default <T, P> T acceptVisitor(JTypeVisitor<T,P> visitor, P p)
      Description copied from interface: JTypeVisitable
      Accept a type visitor, dispatching on this object's runtime type to the correct method of the visitor.
      Specified by:
      acceptVisitor in interface JTypeVisitable
      Type Parameters:
      T - Type of result of the visitor
      P - Type of data of the visitor