Small cleanup in GenerateJavaScriptAST.
Change-Id: I516d9ee15e157f61fa8d7e304057fce4517c8c69
diff --git a/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java b/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java
index 7798bc2..e250f9d 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java
@@ -501,8 +501,7 @@
}
}
- private void optimizeJs(Set<JsNode> inlinableJsFunctions)
- throws InterruptedException, UnableToCompleteException {
+ private void optimizeJs(Set<JsNode> inlinableJsFunctions) throws InterruptedException {
if (shouldOptimize()) {
optimizeJsLoop(inlinableJsFunctions);
JsDuplicateCaseFolder.exec(jsProgram);
@@ -999,8 +998,7 @@
return new BufferedInputStream(new GZIPInputStream(artifact.getContents(TreeLogger.NULL)));
}
- private void optimizeJsLoop(Collection<JsNode> toInline)
- throws InterruptedException, UnableToCompleteException {
+ private void optimizeJsLoop(Collection<JsNode> toInline) throws InterruptedException {
int optimizationLevel = options.getOptimizationLevel();
List<OptimizerStats> allOptimizerStats = Lists.newArrayList();
int counter = 0;
diff --git a/dev/core/src/com/google/gwt/dev/jjs/ast/JTypeOracle.java b/dev/core/src/com/google/gwt/dev/jjs/ast/JTypeOracle.java
index 75bb924..3c8a3bd 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/ast/JTypeOracle.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/ast/JTypeOracle.java
@@ -884,25 +884,6 @@
}
/**
- * Returns the method definition where {@code method} is first defined in a class.
- */
- public JMethod getTopMostDefinition(JMethod method) {
- if (method.getEnclosingType() instanceof JInterfaceType) {
- return null;
- }
- JMethod currentMethod = method;
- for (JMethod overriddenMethod : method.getOverriddenMethods()) {
- if (overriddenMethod.getEnclosingType() instanceof JInterfaceType) {
- continue;
- }
- if (isSuperClass(currentMethod.getEnclosingType(), overriddenMethod.getEnclosingType())) {
- currentMethod = overriddenMethod;
- }
- }
- return currentMethod;
- }
-
- /**
* True if either a JSO, or is an interface that is ONLY implemented by a JSO.
*/
public boolean isEffectivelyJavaScriptObject(JType type) {
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 4722805..f208011 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
@@ -561,10 +561,6 @@
polyName = interfaceScope.declareName(mangleNameForPrivatePoly(x), name);
} else if (x.isPackagePrivate()) {
polyName = interfaceScope.declareName(mangleNameForPackagePrivatePoly(x), name);
- // Also add the mapping from the top of the package private overriding chain, so
- // so that it can be referred when generating the vtable of a subclass that
- // increases the visibility of this method.
- polymorphicNames.put(typeOracle.getTopMostDefinition(x), polyName);
} else if (x.isOrOverridesJsMethod() && !typeOracle.needsJsInteropBridgeMethod(x)) {
if (x.isOrOverridesJsPropertyAccessor()) {
// Prevent JsProperty functions like x() from colliding with intended JS native
@@ -2777,8 +2773,7 @@
generateVTableAssignment(globalStmts, method, exportedName,
createBridgeMethodOrReturnAlias(method, polyJsName));
}
- if (method.exposesOverriddenPackagePrivateMethod() &&
- getPackagePrivateName(method) != null) {
+ if (method.exposesOverriddenPackagePrivateMethod()) {
// This method exposes a package private method that is actually live, hence it needs
// to make the package private name and the public name to be the same implementation at
// runtime. This is done by an assignment of the form.
@@ -2926,7 +2921,15 @@
* Returns the package private JsName for {@code method}.
*/
private JsName getPackagePrivateName(JMethod method) {
- return polymorphicNames.get(typeOracle.getTopMostDefinition(method));
+ for (JMethod overridenMethod : method.getOverriddenMethods()) {
+ if (overridenMethod.isPackagePrivate()) {
+ JsName name = polymorphicNames.get(overridenMethod);
+ assert name != null;
+ return name;
+ }
+ }
+ throw new AssertionError(
+ method.toString() + " overrides a package private method but was not found.");
}
private void handleClinit(JsFunction clinitFunc, JsFunction superClinit) {
@@ -3464,15 +3467,14 @@
String mangleNameForPackagePrivatePoly(JMethod x) {
assert x.isPackagePrivate() && !x.isStatic();
- JMethod topDefinition = typeOracle.getTopMostDefinition(x);
/*
- * Package private instance methods in different classes should not override each
+ * Package private instance methods in different package should not override each
* other, so they must have distinct polymorphic names. Therefore, add the
- * class name of where the method is first defined to the mangled name.
+ * package to the mangled name.
*/
String mangledName = Joiner.on("$").join(
"package_private",
- JjsUtils.mangledNameString(topDefinition.getEnclosingType()),
+ JjsUtils.mangledNameString(x.getEnclosingType().getPackageName()),
JjsUtils.mangledNameString(x));
return StringInterner.get().intern(JjsUtils.constructManglingSignature(x, mangledName));
}