Class TypedVar

All Implemented Interfaces:
StaticTypedRef, StaticTypedSlot, StaticRef, StaticSlot, Serializable

public class TypedVar extends AbstractVar<TypedScope,TypedVar> implements StaticTypedSlot, StaticTypedRef
AbstractVar subclass for use with TypedScope.

Note that this class inherits its Object.equals(java.lang.Object) and Object.hashCode() implementations from ScopedName, which does not include any type information. This is necessary because Var-keyed maps are used across multiple top scopes, but it comes with the caveat that if TypedVar instances are stored in a set, the type information is at risk of disappearing if an untyped (or differently typed) var is added for the same symbol.

See Also:
  • Method Details

    • getType

      public JSType getType()
      Gets this variable's type. To know whether this type has been inferred, see #isTypeInferred().
      Specified by:
      getType in interface StaticTypedSlot
      Returns:
      The type or null if no type is declared for it.
    • isTypeInferred

      public boolean isTypeInferred()
      Returns whether this variable's type is inferred. To get the variable's type, see getType().
      Specified by:
      isTypeInferred in interface StaticTypedSlot
    • getInputName

      public String getInputName()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public final boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object