Incorporated Scott's comments. 

Patch by: amitmanjhi



git-svn-id: https://google-web-toolkit.googlecode.com/svn/releases/1.6@4463 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java b/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java
index f5a77bd..e2653a1 100644
--- a/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java
+++ b/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java
@@ -48,7 +48,7 @@
 
   static class AnonymousClassVisitor extends EmptyVisitor {
     /*
-     * array of classNames of inner clases that aren't synthetic.
+     * array of classNames of inner clases that aren't synthetic classes.
      */
     List<String> classNames = new ArrayList<String>();
 
diff --git a/dev/core/src/com/google/gwt/dev/javac/GeneratedClassnameComparator.java b/dev/core/src/com/google/gwt/dev/javac/GeneratedClassnameComparator.java
index e7280b2..bdd642f 100644
--- a/dev/core/src/com/google/gwt/dev/javac/GeneratedClassnameComparator.java
+++ b/dev/core/src/com/google/gwt/dev/javac/GeneratedClassnameComparator.java
@@ -17,6 +17,16 @@
 
 import java.util.Comparator;
 
+/**
+ * Comparator to sort the compiler-generated classNames so that they can be
+ * correlated. Examples of sorting orders by the comparator:
+ * 
+ * <pre>
+ * <ul>
+ * <li> Foo$1 < Foo$2 < Foo$3 < ... < Foo$10
+ * <li> Foo$1 < Foo$2 < Foo$1$1 < Foo$1$2 < Foo$2$1 < Foo$2$2 < Foo$2$Baz
+ * </pre>
+ */
 class GeneratedClassnameComparator implements Comparator<String> {
 
   public int compare(String arg0, String arg1) {
diff --git a/dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java b/dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java
index 1b75d8a..143a3c3 100644
--- a/dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java
+++ b/dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java
@@ -383,6 +383,7 @@
     }
     emmaStrategy = EmmaStrategy.get(emmaAvailable);
   }
+
   /**
    * Checks if the class names is generated. Accepts any classes whose names
    * match .+$\d+($.*)? (handling named classes within anonymous classes).
@@ -716,7 +717,7 @@
        * find it on disk. Typically this is a synthetic class added by the
        * compiler.
        */
-      if (shouldLoadClassFromDisk(className)) {
+      if (typeHasCompilationUnit(className) && isClassnameGenerated(className)) {
         /*
          * modification time = 0 ensures that whatever is on the disk is always
          * loaded.
@@ -755,9 +756,8 @@
   }
 
   /**
-   * Returns the compilationUnit corresponding to the className.
-   * <p>
-   * Not considering classnames where a $ sign appears.
+   * Returns the compilationUnit corresponding to the className. For nested
+   * classes, the unit corresponding to the top level type is returned.
    */
   private CompilationUnit getUnitForClassName(String className) {
     String mainTypeName = className;
@@ -786,14 +786,10 @@
     }
   }
 
-  private boolean isBaseClassInGwt(String className) {
+  private boolean typeHasCompilationUnit(String className) {
     return getUnitForClassName(className) != null;
   }
 
-  private boolean shouldLoadClassFromDisk(String className) {
-    return isBaseClassInGwt(className) && isClassnameGenerated(className);
-  }
-
   /**
    * Tricky one, this. Reaches over into this modules's JavaScriptHost class and
    * sets its static 'host' field to our module space.