          if (global) {
            reserveName(name);
          } else {
-@@ -421,9 +392,8 @@ class MakeDeclaredNamesUnique
+@@ -421,9 +398,8 @@ class MakeDeclaredNamesUnique
              String newName = null;
              if (id != 0) {
                newName = getUniqueName(name, id);

      */
-    public void exitScope(NodeTraversal t) {
-      if (t.inGlobalScope()) {
-        return;
-      }
+    @Override
+    public void visit(NodeTraversal t, Node node, Node parent) {
+      if (node.getType() == Token.NAME) {
+        String oldName = node.getString();
+        if (oldName.indexOf(ContextualRenamer.UNIQUE_ID_SEPARATOR) != -1) {
+          Scope scope = t.getScope();
+          Var var = t.getScope().getVar(oldName);
+          if (var == null || var.isGlobal()) {
+            return;
+          }
 
-      for (Iterator<Var> it = t.getScope().getVars(); it.hasNext();) {
-        Var v = it.next();

diff --git a/src/com/google/javascript/jscomp/MakeDeclaredNamesUnique.java b/src/com/google/javascript/jscomp/MakeDeclaredNamesUnique.java
index d88520cb..51f440c2 100644
--- a/src/com/google/javascript/jscomp/MakeDeclaredNamesUnique.java
+++ b/src/com/google/javascript/jscomp/MakeDeclaredNamesUnique.java
@@ -23,7 +23,7 @@ import com.google.common.collect.Lists;
