code: @Override
    JSType resolveInternal(ErrorReporter reporter) {
      if (!getReferencedType().isUnknownType()) {
        // 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.
        return super.resolveInternal(reporter);
      }
  
      // 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. Now, resolution via registry is first in order to
      // avoid triggering the warnings built into the resolution via properties.
      boolean resolved = resolveViaRegistry(reporter);
      if (!resolved) {
        resolveViaProperties(reporter);
      }
  
      if (detectInheritanceCycle()) {
        handleTypeCycle(reporter);
      }
      super.resolveInternal(reporter);
      finishPropertyContinuations();
  
      JSType result = getReferencedType();
      if (isSuccessfullyResolved()) {
        int numKeys = result.getTemplateTypeMap().numUnfilledTemplateKeys();
        if (result.isObjectType()
            && (templateTypes != null && !templateTypes.isEmpty())
            && numKeys > 0) {
          ImmutableList<JSType> typeArgs = this.templateTypes;
  
          // Ignore any extraneous type args
          // TODO(johnlenz): report an error
          if (numKeys < this.templateTypes.size()) {
            typeArgs = typeArgs.subList(0, numKeys);
          }
  
          result = registry.createTemplatizedType(result.toMaybeObjectType(), typeArgs);
          setReferencedType(result);
        }
  
        resolutionScope = null;
      }
      return result;
    }
docs: Resolve the referenced type within the enclosing scope.