Class TypeVar

  • All Implemented Interfaces:
    Type

    public class TypeVar
    extends Object
    implements Type
    Type variable (e.g. 'a).
    • Field Detail

      • ALPHAS

        private static final char[] ALPHAS
      • NAME_CACHE

        private static final com.google.common.cache.LoadingCache<Integer,​String> NAME_CACHE
      • ordinal

        final int ordinal
      • name

        private final String name
    • Constructor Detail

      • TypeVar

        public TypeVar​(int ordinal)
        Creates a type variable with a given ordinal.

        TypeVar.of(0) returns "'a"; TypeVar.of(1) returns "'b", etc.

    • Method Detail

      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • toString

        public String toString()
        Returns a string for debugging.
        Overrides:
        toString in class Object
      • name

        static String name​(int i)
        Generates a name for a type variable.

        0 → 'a, 1 → 'b, 26 → 'z, 27 → 'ba, 28 → 'bb, 675 → 'zz, 676 → 'baa, etc. (Think of it is a base 26 number, with "a" as 0, "z" as 25.)

      • key

        public Type.Key key()
        Description copied from interface: Type
        Description of the type, e.g. "int", "int -> int", "NONE | SOME of 'a".
        Specified by:
        key in interface Type
      • op

        public Op op()
        Description copied from interface: Type
        Type operator.
        Specified by:
        op in interface Type
      • copy

        public Type copy​(TypeSystem typeSystem,
                         UnaryOperator<Type> transform)
        Description copied from interface: Type
        Copies this type, applying a given transform to component types, and returning the original type if the component types are unchanged.
        Specified by:
        copy in interface Type