Skip to content

Commit

Permalink
Fix a spot where we were calling cloneNode instead of cloneTree on a …
Browse files Browse the repository at this point in the history
…GETPROP node.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168624053
  • Loading branch information
tbreisacher authored and lauraharker committed Sep 14, 2017
1 parent 0f83d45 commit 52f72d3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Expand Up @@ -97,7 +97,7 @@ private static void addExtern(Node node) {
Node rhs = NodeUtil.getRValueOfLValue(node); Node rhs = NodeUtil.getRValueOfLValue(node);
// Type-aliasing definition // Type-aliasing definition
if (oldJSDocInfo.hasConstAnnotation() && rhs != null && rhs.isQualifiedName()) { if (oldJSDocInfo.hasConstAnnotation() && rhs != null && rhs.isQualifiedName()) {
newNode = IR.assign(getprop, rhs.cloneNode()); newNode = IR.assign(getprop, rhs.cloneTree());
} }
} }
builder = JSDocInfoBuilder.copyFrom(oldJSDocInfo); builder = JSDocInfoBuilder.copyFrom(oldJSDocInfo);
Expand Down
Expand Up @@ -101,7 +101,7 @@ public void testWindowProperty7() {
"/** @suppress {const,duplicate} @const */ window.ns = ns;")); "/** @suppress {const,duplicate} @const */ window.ns = ns;"));
} }


public void testNamespaceAliasing() { public void testNameAliasing() {
testExternChanges( testExternChanges(
LINE_JOINER.join( LINE_JOINER.join(
"var window;", "var window;",
Expand All @@ -122,6 +122,31 @@ public void testNamespaceAliasing() {
"window.ns2 = ns;")); "window.ns2 = ns;"));
} }


public void testQualifiedNameAliasing() {
testExternChanges(
LINE_JOINER.join(
"var window;",
"/** @const */",
"var ns = {};",
"/** @type {number} A very important constant */",
"ns.THE_NUMBER;",
"/** @const */",
"var num = ns.THE_NUMBER;"),
"",
LINE_JOINER.join(
"var window;",
"/** @const */",
"var ns = {};",
"/** @type {number} A very important constant */",
"ns.THE_NUMBER;",
"/** @const */",
"var num = ns.THE_NUMBER;",
"/** @suppress {const,duplicate} @const */",
"window.ns=ns;",
"/** @suppress {const,duplicate} @const */",
"window.num = ns.THE_NUMBER;"));
}

public void testWindowProperty8() { public void testWindowProperty8() {
testExternChanges("var window; /** @constructor */ function Foo() {}", "", testExternChanges("var window; /** @constructor */ function Foo() {}", "",
LINE_JOINER.join( LINE_JOINER.join(
Expand Down

0 comments on commit 52f72d3

Please sign in to comment.