Remove accidental override removal optimization.

Accidental override removal is currently implemented in
GenerateJavaScriptAST and not reflected in the AST. In
particular causes CodeSplitter to not account for the
removal and incorrectly place its super method in the
wrong fragment.

This patch limits the optimization to a case that is safe
and necessary. The case in question is an accidental
override that delegates to a JsMember; and its removal is
needed because the compiler does not handle super (static)
dispatch to JsProperties.

An optimization to remove all unnecesary accidental overrides
is possible but needs to be implemented a Java AST
transformation.

Change-Id: I41593d5fc951d3afe705a5c8472ca4252785a424
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java b/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java
index d1e265a..226ec2e 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java
@@ -2551,7 +2551,7 @@
   private static boolean doesNotHaveConcreteImplementation(JMethod method) {
     return method.isAbstract()
         || method.isJsNative()
-        || JjsUtils.isUnnecessarySyntheticAccidentalOverride(method)
+        || JjsUtils.isJsMemberUnnecessaryAccidentalOverride(method)
         || (JProgram.isClinit(method)
             && method.getEnclosingType().getClinitTarget() != method.getEnclosingType());
   }
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/JjsUtils.java b/dev/core/src/com/google/gwt/dev/jjs/impl/JjsUtils.java
index 9098c1c..b9467cb4 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/JjsUtils.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/JjsUtils.java
@@ -18,6 +18,7 @@
 import com.google.gwt.dev.PrecompileTaskOptions;
 import com.google.gwt.dev.jjs.SourceInfo;
 import com.google.gwt.dev.jjs.SourceOrigin;
+import com.google.gwt.dev.jjs.ast.HasJsInfo.JsMemberType;
 import com.google.gwt.dev.jjs.ast.HasName;
 import com.google.gwt.dev.jjs.ast.HasType;
 import com.google.gwt.dev.jjs.ast.JArrayType;
@@ -385,7 +386,7 @@
    * Returns true if the method is a synthetic accidental override that trivially dispatches to its
    * same name super.
    */
-  public static boolean isUnnecessarySyntheticAccidentalOverride(JMethod method) {
+  public static boolean isJsMemberUnnecessaryAccidentalOverride(JMethod method) {
     // Assumptions on synthethic overrides, if any of these change.
     assert !method.isSyntheticAccidentalOverride() || !method.exposesPackagePrivateMethod();
 
@@ -393,16 +394,16 @@
       return false;
     }
 
-    boolean overridesConcreteMethod = Iterables.any(method.getOverriddenMethods(),
+    boolean overridesConcreteJsMethod = Iterables.any(method.getOverriddenMethods(),
         new Predicate<JMethod>() {
           @Override
           public boolean apply(JMethod method) {
-            return !method.isAbstract();
+            return !method.isAbstract() && method.getJsMemberType() != JsMemberType.NONE;
           }
         });
-    // A synthetic accidental  override is unnecessary iff it retains the same property
-    // name (polyname) as the the concrete method it overrides.
-    return overridesConcreteMethod && !method.exposesNonJsMember();
+    // A synthetic accidental override is unnecessary if its due to a JsMethod that does not expose
+    // a non JsMember.
+    return overridesConcreteJsMethod && !method.exposesNonJsMember();
   }
 
   /**
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/JsInteropRestrictionChecker.java b/dev/core/src/com/google/gwt/dev/jjs/impl/JsInteropRestrictionChecker.java
index 0a0139f..81daede 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/JsInteropRestrictionChecker.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/JsInteropRestrictionChecker.java
@@ -584,7 +584,7 @@
       @Override
       public boolean visit(JMethod x, Context ctx) {
         // Skip unnecessary synthetic override, as they will not be generated.
-        return !JjsUtils.isUnnecessarySyntheticAccidentalOverride(x);
+        return !JjsUtils.isJsMemberUnnecessaryAccidentalOverride(x);
       }
 
       @Override