Skip to content

Commit

Permalink
Fix a crash with circular import * statements.
Browse files Browse the repository at this point in the history
Closes #3322

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=246237043
  • Loading branch information
johnplaisted authored and brad4d committed May 2, 2019
1 parent 43b142c commit 92541e5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/com/google/javascript/jscomp/modules/Binding.java
Expand Up @@ -123,13 +123,14 @@ static Binding from(
}

/** Binding for an entire module namespace created by an <code>import *</code>. */
static Binding from(Module namespaceBoundModule, Node sourceNode) {
static Binding from(
ModuleMetadata metadataOfBoundModule, @Nullable String closureNamespace, Node sourceNode) {
return new AutoValue_Binding(
namespaceBoundModule.metadata(),
metadataOfBoundModule,
sourceNode,
/* originatingExport= */ null,
/* isModuleNamespace= */ true,
namespaceBoundModule.closureNamespace(),
closureNamespace,
CreatedBy.IMPORT);
}

Expand Down
Expand Up @@ -410,9 +410,12 @@ private ResolveExportResult resolveImportImpl(
i.moduleRequest()));
return ResolveExportResult.ERROR;
}
String closureNamespace =
GoogEsImports.isGoogImportSpecifier(i.moduleRequest())
? GoogEsImports.getClosureIdFromGoogImportSpecifier(i.moduleRequest())
: null;
return ResolveExportResult.of(
Binding.from(
requested.resolve(moduleRequestResolver, i.moduleRequest()), i.nameNode()));
Binding.from(requested.metadata(), closureNamespace, i.nameNode()));
} else {
ResolveExportResult result =
requested.resolveExport(
Expand Down

0 comments on commit 92541e5

Please sign in to comment.