third_party/closure-compiler/src/src/com/google/javascript/rhino/jstype/NamedType.java
/**
   * Resolve the referenced type within the enclosing scope.
   */
Resolve the referenced type within the enclosing scope.
Resolve the referenced type within the enclosing scope .
@Override
  JSType resolveInternal(ErrorReporter reporter) {
    if (!getReferencedType().isUnknownType()) {
      return super.resolveInternal(reporter);
    }
    boolean resolved = false;
    if (reference.startsWith("typeof ")) {
      resolveTypeof(reporter);
      resolved = true;
    }
    resolved =
        resolved
            || resolveViaClosureNamespace(reporter)
            || resolveViaRegistry(reporter);
    if (!resolved) {
      resolveViaProperties(reporter);
    }
    if (detectInheritanceCycle()) {
      handleTypeCycle(reporter);
    }
    super.resolveInternal(reporter);
    finishPropertyContinuations();
    JSType result = getReferencedType();
    if (isSuccessfullyResolved()) {
      this.resolutionScope = null;
      int numKeys = result.getTemplateParamCount();
      if (!result.isObjectType() || templateTypes == null || templateTypes.isEmpty()) {
        return result;
      }
      ImmutableList<JSType> resolvedTypeArgs =
          JSTypeIterations.mapTypes((t) -> t.resolve(reporter), this.templateTypes);
      if (numKeys < this.templateTypes.size()) {
        resolvedTypeArgs = resolvedTypeArgs.subList(0, numKeys);
      }
      result = registry.createTemplatizedType(result.toMaybeObjectType(), resolvedTypeArgs);
      setReferencedType(result.resolve(reporter));
    }
    return result;
  }
@ Override JSType resolveInternal ( ErrorReporter reporter ) { if ( ! getReferencedType ( ) . isUnknownType ( ) ) { return super . resolveInternal ( reporter ) ; } boolean resolved = false ; if ( reference . startsWith ( "typeof " ) ) { resolveTypeof ( reporter ) ; resolved = true ; } resolved = resolved || resolveViaClosureNamespace ( reporter ) || resolveViaRegistry ( reporter ) ; if ( ! resolved ) { resolveViaProperties ( reporter ) ; } if ( detectInheritanceCycle ( ) ) { handleTypeCycle ( reporter ) ; } super . resolveInternal ( reporter ) ; finishPropertyContinuations ( ) ; JSType result = getReferencedType ( ) ; if ( isSuccessfullyResolved ( ) ) { this . resolutionScope = null ; int numKeys = result . getTemplateParamCount ( ) ; if ( ! result . isObjectType ( ) || templateTypes == null || templateTypes . isEmpty ( ) ) { return result ; } ImmutableList < JSType > resolvedTypeArgs = JSTypeIterations . mapTypes ( ( t ) -> t . resolve ( reporter ) , this . templateTypes ) ; if ( numKeys < this . templateTypes . size ( ) ) { resolvedTypeArgs = resolvedTypeArgs . subList ( 0 , numKeys ) ; } result = registry . createTemplatizedType ( result . toMaybeObjectType ( ) , resolvedTypeArgs ) ; setReferencedType ( result . resolve ( reporter ) ) ; } return result ; }
Resolve the referenced type within the enclosing scope.
Resolve the referenced type within the enclosing scope .
// In some cases (e.g. typeof(ns) when the actual type is just a literal object), a NamedType // is created solely for the purpose of naming an already-known type. When that happens, // there's nothing to look up, so just resolve the referenced type. // TODO(user): Investigate whether it is really necessary to keep two // different mechanisms for resolving named types, and if so, which order // makes more sense. // The `resolveViaClosureNamespace` mechanism can probably be deleted (or reworked) once the // compiler supports type annotations via path. The `resolveViaProperties` and // `resolveViaRegistry` are, unfortunately, both needed now with no migration plan. // Ignore any extraneous type args (but only after resolving them!) // TODO(johnlenz): report an error