Class IntersectionSourceType

  • All Implemented Interfaces:
    ASTNode, SourceType

    public final class IntersectionSourceType
    extends Object
    implements SourceType
    An intersection type such as "A & B", as written in a type parameter bound; it lowers to its first bound.
    • Constructor Detail

      • IntersectionSourceType

        public IntersectionSourceType​(List<SourceType> bounds)
        Creates an intersection over a copied, unmodifiable bound list.
        Parameters:
        bounds - the intersected types, at least two
        Throws:
        IllegalArgumentException - if fewer than two bounds are given
      • IntersectionSourceType

        public IntersectionSourceType​(SourceType... bounds)
        Creates an intersection from a bound array.
        Parameters:
        bounds - the intersected types, at least two and none null
        Throws:
        IllegalArgumentException - if fewer than two bounds are given
        NullPointerException - if the array or any bound is null
    • Method Detail

      • getBoundCount

        public int getBoundCount()
        Returns:
        the number of intersected types
      • getBound

        public SourceType getBound​(int index)
        Parameters:
        index - the position in the bound list
        Returns:
        the bound at a position
        Throws:
        IndexOutOfBoundsException - if the position is out of range
      • getFirstBound

        public SourceType getFirstBound()
        Returns:
        the leading bound, which the type erases to
      • toJavaSource

        public String toJavaSource()
        Description copied from interface: SourceType
        Converts this source type to Java source code representation.
        Specified by:
        toJavaSource in interface SourceType
        Returns:
        the Java source representation (e.g., "int", "String", "int[]")
      • toIRType

        public IRType toIRType()
        Description copied from interface: SourceType
        Converts this source type to the equivalent IR type.
        Specified by:
        toIRType in interface SourceType
        Returns:
        the corresponding IRType
      • accept

        public <T> T accept​(SourceVisitor<T> visitor)
        Description copied from interface: ASTNode
        Accepts a visitor for this node.
        Specified by:
        accept in interface ASTNode
        Type Parameters:
        T - the return type of the visitor
        Parameters:
        visitor - the visitor to accept
        Returns:
        the result from the visitor
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object