Partial roll-back of r1793 and r1799.  The fix I made to Pruner caused back side effects in that some truly dead items (instance methods on uninstantiable types that implemented interface methods on live types) would live until GenerateJavaScriptAST and cause problems.  I rolled Pruner back to its prior behavior and fixed the original problem in MakeCallsStatic.

Review by: spoon, bobv (TBR)


git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@1808 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/MakeCallsStatic.java b/dev/core/src/com/google/gwt/dev/jjs/impl/MakeCallsStatic.java
index 85b56af..e17dc6c 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/MakeCallsStatic.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/MakeCallsStatic.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007 Google Inc.
+ * Copyright 2008 Google Inc.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
@@ -236,7 +236,10 @@
         return;
       }
 
-      assert (method.getEnclosingType().methods.indexOf(method) > 0);
+      if (!method.getEnclosingType().methods.contains(method)) {
+        // The target method was already pruned (TypeTightener will fix this).
+        return;
+      }
 
       // Let's do it!
       toBeMadeStatic.add(method);
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/Pruner.java b/dev/core/src/com/google/gwt/dev/jjs/impl/Pruner.java
index c4fe6fe..043de05 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/Pruner.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/Pruner.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2008 Google Inc.
+ * Copyright 2007 Google Inc.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
@@ -15,6 +15,7 @@
  */
 package com.google.gwt.dev.jjs.impl;
 
+import com.google.gwt.dev.jjs.ast.CanBeStatic;
 import com.google.gwt.dev.jjs.ast.Context;
 import com.google.gwt.dev.jjs.ast.JAbsentArrayDimension;
 import com.google.gwt.dev.jjs.ast.JArrayType;
@@ -206,11 +207,14 @@
 
     @Override
     public boolean visit(JClassType type, Context ctx) {
+
       assert (referencedTypes.contains(type));
+      boolean isInstantiated = program.typeOracle.isInstantiatedType(type);
 
       for (Iterator<JField> it = type.fields.iterator(); it.hasNext();) {
         JField field = it.next();
-        if (!referencedNonTypes.contains(field)) {
+        if (!referencedNonTypes.contains(field)
+            || pruneViaNoninstantiability(isInstantiated, field)) {
           it.remove();
           didChange = true;
         }
@@ -218,7 +222,8 @@
 
       for (Iterator<JMethod> it = type.methods.iterator(); it.hasNext();) {
         JMethod method = it.next();
-        if (!methodIsReferenced(method)) {
+        if (!methodIsReferenced(method)
+            || pruneViaNoninstantiability(isInstantiated, method)) {
           it.remove();
           didChange = true;
         } else {
@@ -366,6 +371,11 @@
       }
       return false;
     }
+
+    private boolean pruneViaNoninstantiability(boolean isInstantiated,
+        CanBeStatic it) {
+      return (!isInstantiated && !it.isStatic());
+    }
   }
 
   /**