From bcd39872f9b78d6786d4c155a65b246f6f50b89f Mon Sep 17 00:00:00 2001 From: tbreisacher Date: Wed, 20 Sep 2017 12:23:17 -0700 Subject: [PATCH] Use Var.isParam() rather than Var.getParent().isParamList() to check whether a variable is a parameter. With destructuring and default values, the param list may not be the direct parent of the parameter anymore. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=169432059 --- src/com/google/javascript/jscomp/CoalesceVariableNames.java | 2 +- .../google/javascript/jscomp/CoalesceVariableNamesTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/google/javascript/jscomp/CoalesceVariableNames.java b/src/com/google/javascript/jscomp/CoalesceVariableNames.java index 9e8550d90fd..2793e263f0c 100644 --- a/src/com/google/javascript/jscomp/CoalesceVariableNames.java +++ b/src/com/google/javascript/jscomp/CoalesceVariableNames.java @@ -303,7 +303,7 @@ private UndiGraph computeVariableNamesInterferenceGraph( continue NEXT_VAR_PAIR; } - if (v1.getParentNode().isParamList() && v2.getParentNode().isParamList()) { + if (v1.isParam() && v2.isParam()) { interferenceGraph.connectIfNotFound(v1, null, v2); continue NEXT_VAR_PAIR; } diff --git a/test/com/google/javascript/jscomp/CoalesceVariableNamesTest.java b/test/com/google/javascript/jscomp/CoalesceVariableNamesTest.java index 94e72703957..bc1c71c0167 100644 --- a/test/com/google/javascript/jscomp/CoalesceVariableNamesTest.java +++ b/test/com/google/javascript/jscomp/CoalesceVariableNamesTest.java @@ -323,8 +323,8 @@ public void testBug1401831() { // Code inside a class is automatically in strict mode, so duplicated parameter names are not // allowed. - // TODO(b/64898400): Fix and enable this test. - public void disabled_testBug64898400() { + public void testBug64898400() { + testSame("class C { f(a, b, c) {} }"); testSame("class C { f(a, b=0, c=0) {} }"); }