Class NoResolvedType


public final class NoResolvedType extends ObjectType
An unresolved type that was forward declared. So we know it exists, but that it wasn't pulled into this binary.

In most cases, it behaves like a sibling of the top object type.

Why have this class at all, and not just use the top object type or `*`?

Clutz relies on this class to emit .d.ts typings for JS files without having to see all their dependencies: Clutz expects unresolved types to be available when it runs, so that it can map them back to the corresponding goog.required import.

Clutz also sets a special JSCompiler flag so that all unresolved types are treated as forward declared. (In most non-Clutz cases, this class is only rarely used, and only if there's actually an explicit `goog.forwardDeclare` call.)

To address this, we would need to significantly refactor Clutz.

  • Method Details

    • getReferenceName

      public @Nullable String getReferenceName()
      Description copied from class: ObjectType
      Gets the reference name for this object. This includes named types like constructors, prototypes, and enums. It notably does not include literal types like strings and booleans and structural types.

      Returning an empty string means something different than returning null. An empty string may indicate an anonymous constructor, which we treat differently than a literal type without a reference name. e.g. in InstanceObjectType.appendTo(TypeStringBuilder)

      Specified by:
      getReferenceName in class ObjectType
      Returns:
      the object's name or null if this is an anonymous object
    • getTemplateTypes

      public @Nullable com.google.common.collect.ImmutableList<JSType> getTemplateTypes()
      Description copied from class: ObjectType
      Gets the declared default element type.
      Overrides:
      getTemplateTypes in class ObjectType
      See Also:
    • isNoResolvedType

      public boolean isNoResolvedType()
      Overrides:
      isNoResolvedType in class JSType
    • getPossibleToBooleanOutcomes

      public BooleanLiteralSet getPossibleToBooleanOutcomes()
      Description copied from class: JSType
      Computes the set of possible outcomes of the ToBoolean predicate for this type. The ToBoolean predicate is defined by the ECMA-262 standard, 3rd edition. Its behavior for simple types can be summarized by the following table:
      ToBoolean results by input type
      typeresult
      undefined{false}
      null{false}
      boolean{true, false}
      number{true, false}
      string{true, false}
      Object{true}
      Overrides:
      getPossibleToBooleanOutcomes in class ObjectType
      Returns:
      the set of boolean literals for this type
    • testForEquality

      public Tri testForEquality(JSType that)
      Description copied from class: JSType
      Compares this and that.
      Overrides:
      testForEquality in class ObjectType
      Returns:
      • Tri.TRUE if the comparison of values of this type and that always succeed (such as undefined compared to null)
      • Tri.FALSE if the comparison of values of this type and that always fails (such as undefined compared to number)
      • Tri.UNKNOWN if the comparison can succeed or fail depending on the concrete values
    • getConstructor

      public @Nullable FunctionType getConstructor()
      Description copied from class: ObjectType
      Gets this object's constructor.
      Specified by:
      getConstructor in class ObjectType
      Returns:
      this object's constructor or null if it is a native object (constructed natively v.s. by instantiation of a function)
    • getImplicitPrototype

      public final @Nullable ObjectType getImplicitPrototype()
      Description copied from class: ObjectType
      Gets the implicit prototype (a.k.a. the [[Prototype]] property).
      Specified by:
      getImplicitPrototype in class ObjectType
    • defineProperty

      public boolean defineProperty(Property.Key propertyName, JSType type, boolean inferred, Node propertyNode)