When making a static implementation method, set the original parameter types
of the new method based on the *original* parameter types of the old method,
not the *current* ones.
Review by: scottb (desk check)
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@2974 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/jjs/ast/JMethod.java b/dev/core/src/com/google/gwt/dev/jjs/ast/JMethod.java
index 6de20e5..3beb6a6 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/ast/JMethod.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/ast/JMethod.java
@@ -53,7 +53,7 @@
private final boolean isPrivate;
private final boolean isStatic;
private final String name;
- private ArrayList<JType> originalParamTypes;
+ private List<JType> originalParamTypes;
private JType returnType;
private boolean trace = false;
private boolean traceFirst = true;
@@ -75,34 +75,13 @@
}
public void freezeParamTypes() {
- if (originalParamTypes != null) {
- throw new InternalCompilerException("Param types already frozen");
+ List<JType> paramTypes = new ArrayList<JType>();
+ for (JParameter param : params) {
+ paramTypes.add(param.getType());
}
- originalParamTypes = new ArrayList<JType>();
- for (int i = 0; i < params.size(); ++i) {
- JParameter param = params.get(i);
- originalParamTypes.add(param.getType());
- }
-
- // Determine if we should trace this method.
- if (enclosingType != null) {
- String jsniSig = JProgram.getJsniSig(this);
- Set<String> set = JProgram.traceMethods.get(enclosingType.getName());
- if (set != null
- && (set.contains(name) || set.contains(jsniSig) || set.contains(TRACE_METHOD_WILDCARD))) {
- trace = true;
- }
- // Try the short name.
- if (!trace && enclosingType != null) {
- set = JProgram.traceMethods.get(enclosingType.getShortName());
- if (set != null
- && (set.contains(name) || set.contains(jsniSig) || set.contains(TRACE_METHOD_WILDCARD))) {
- trace = true;
- }
- }
- }
+ setOriginalParamTypes(paramTypes);
}
-
+
public JAbstractMethodBody getBody() {
return body;
}
@@ -166,6 +145,32 @@
isFinal = true;
}
+ public void setOriginalParamTypes(List<JType> paramTypes) {
+ if (originalParamTypes != null) {
+ throw new InternalCompilerException("Param types already frozen");
+ }
+ originalParamTypes = paramTypes;
+
+
+ // Determine if we should trace this method.
+ if (enclosingType != null) {
+ String jsniSig = JProgram.getJsniSig(this);
+ Set<String> set = JProgram.traceMethods.get(enclosingType.getName());
+ if (set != null
+ && (set.contains(name) || set.contains(jsniSig) || set.contains(TRACE_METHOD_WILDCARD))) {
+ trace = true;
+ }
+ // Try the short name.
+ if (!trace && enclosingType != null) {
+ set = JProgram.traceMethods.get(enclosingType.getShortName());
+ if (set != null
+ && (set.contains(name) || set.contains(jsniSig) || set.contains(TRACE_METHOD_WILDCARD))) {
+ trace = true;
+ }
+ }
+ }
+ }
+
public void setTrace() {
this.trace = true;
}
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 4ee80f6..a5df81d 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
@@ -40,8 +40,10 @@
import com.google.gwt.dev.js.ast.JsParameter;
import com.google.gwt.dev.js.ast.JsThisRef;
+import java.util.ArrayList;
import java.util.HashSet;
import java.util.IdentityHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -154,7 +156,12 @@
false, newMethod);
varMap.put(oldVar, newVar);
}
- newMethod.freezeParamTypes();
+
+ // Set the new original param types based on the old original param types
+ List<JType> originalParamTypes = new ArrayList<JType>();
+ originalParamTypes.add(enclosingType);
+ originalParamTypes.addAll(x.getOriginalParamTypes());
+ newMethod.setOriginalParamTypes(originalParamTypes);
// Move the body of the instance method to the static method
JAbstractMethodBody movedBody = x.getBody();
diff --git a/user/test/com/google/gwt/dev/jjs/test/JsoTest.java b/user/test/com/google/gwt/dev/jjs/test/JsoTest.java
index 685b120..43e68ce 100644
--- a/user/test/com/google/gwt/dev/jjs/test/JsoTest.java
+++ b/user/test/com/google/gwt/dev/jjs/test/JsoTest.java
@@ -121,6 +121,8 @@
}
private static class Overloads {
+ private static volatile boolean FALSE = false;
+
@SuppressWarnings("unused")
private static String sFunc(Bar b) {
return "sFunc Bar";
@@ -159,21 +161,37 @@
@SuppressWarnings("unused")
private String func(Bar b) {
+ if (FALSE) {
+ // prevent inlining
+ return func(b);
+ }
return "func Bar";
}
@SuppressWarnings("unused")
private String func(Bar[][] b) {
+ if (FALSE) {
+ // prevent inlining
+ return func(b);
+ }
return "func Bar[][]";
}
@SuppressWarnings("unused")
private String func(Foo f) {
+ if (FALSE) {
+ // prevent inlining
+ return func(f);
+ }
return "func Foo";
}
@SuppressWarnings("unused")
private String func(Foo[][] f) {
+ if (FALSE) {
+ // prevent inlining
+ return func(f);
+ }
return "func Foo[][]";
}
}