Fix regression caused by @JsOverlay and default methods.
Change-Id: I84861c0cd1ee7a7cd780f4d2e6c0101f8ebf9fac
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 979a915..138e336 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
@@ -202,6 +202,10 @@
forwardingMethod.setDefaultMethod();
}
+ if (methodToDelegateTo.isJsOverlay() && type.isJsNative()) {
+ forwardingMethod.isJsOverlay();
+ }
+
// Create the forwarding body.
JMethodBody body = (JMethodBody) forwardingMethod.getBody();
// Invoke methodToDelegate
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 4a15b35..899aaf6 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
@@ -281,11 +281,22 @@
}
JMethod method = (JMethod) member;
- for (JMethod overriddeMethod : method.getOverriddenMethods()) {
- if (overriddeMethod.isJsOverlay()) {
+
+ if (method.isSynthetic()) {
+ // Ignore synthetic methods. These synthetic methods might be accidental overrides or
+ // default method implementations, and they forward to the same implementation so it is
+ // safe to allow them.
+ return;
+ }
+ for (JMethod overriddenMethod : method.getOverriddenMethods()) {
+ if (overriddenMethod.isSynthetic()) {
+ // Ignore synthetic methods for a better error message.
+ continue;
+ }
+ if (overriddenMethod.isJsOverlay()) {
logError(member, "Method '%s' cannot override a JsOverlay method '%s'.",
JjsUtils.getReadableDescription(method),
- JjsUtils.getReadableDescription(overriddeMethod));
+ JjsUtils.getReadableDescription(overriddenMethod));
return;
}
}
diff --git a/user/test-super/com/google/gwt/dev/jjs/super/com/google/gwt/dev/jjs/test/Java8Test.java b/user/test-super/com/google/gwt/dev/jjs/super/com/google/gwt/dev/jjs/test/Java8Test.java
index 6b829f0..91a66f0 100644
--- a/user/test-super/com/google/gwt/dev/jjs/super/com/google/gwt/dev/jjs/test/Java8Test.java
+++ b/user/test-super/com/google/gwt/dev/jjs/super/com/google/gwt/dev/jjs/test/Java8Test.java
@@ -1338,6 +1338,14 @@
Object object = (Integer) (((int) NativeJsTypeInterfaceWithStaticInitialization.object) + 1);
}
+ static class JavaTypeImplementingNativeJsTypeInterceWithDefaultMethod implements
+ NativeJsTypeInterfaceWithStaticInitializationAndInstanceOverlayMethod {
+ @JsProperty
+ public int getA() {
+ return 4;
+ }
+ }
+
public void testNativeJsTypeWithStaticIntializer() {
assertEquals(3, NativeJsTypeInterfaceWithStaticInitializationAndFieldAccess.object);
assertEquals(
@@ -1346,5 +1354,6 @@
createNativeJsTypeInterfaceWithStaticInitializationAndInstanceOverlayMethod()
.getObject());
assertEquals(7, NativeJsTypeInterfaceWithComplexStaticInitialization.object);
+ assertEquals(9, new JavaTypeImplementingNativeJsTypeInterceWithDefaultMethod().getObject());
}
}