Skip to content

Commit

Permalink
Fix regression caused by @JsOverlay and default methods.
Browse files Browse the repository at this point in the history
Change-Id: I84861c0cd1ee7a7cd780f4d2e6c0101f8ebf9fac
  • Loading branch information
rluble committed Dec 11, 2015
1 parent 848af07 commit 514862d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
4 changes: 4 additions & 0 deletions dev/core/src/com/google/gwt/dev/jjs/impl/JjsUtils.java
Expand Up @@ -202,6 +202,10 @@ public static JMethod createForwardingMethod(JDeclaredType type,
forwardingMethod.setDefaultMethod(); forwardingMethod.setDefaultMethod();
} }


if (methodToDelegateTo.isJsOverlay() && type.isJsNative()) {
forwardingMethod.isJsOverlay();
}

// Create the forwarding body. // Create the forwarding body.
JMethodBody body = (JMethodBody) forwardingMethod.getBody(); JMethodBody body = (JMethodBody) forwardingMethod.getBody();
// Invoke methodToDelegate // Invoke methodToDelegate
Expand Down
Expand Up @@ -281,11 +281,22 @@ private void checkIllegalOverrides(JMember member) {
} }


JMethod method = (JMethod) member; 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'.", logError(member, "Method '%s' cannot override a JsOverlay method '%s'.",
JjsUtils.getReadableDescription(method), JjsUtils.getReadableDescription(method),
JjsUtils.getReadableDescription(overriddeMethod)); JjsUtils.getReadableDescription(overriddenMethod));
return; return;
} }
} }
Expand Down
Expand Up @@ -1338,6 +1338,14 @@ interface NativeJsTypeInterfaceWithComplexStaticInitialization {
Object object = (Integer) (((int) NativeJsTypeInterfaceWithStaticInitialization.object) + 1); Object object = (Integer) (((int) NativeJsTypeInterfaceWithStaticInitialization.object) + 1);
} }


static class JavaTypeImplementingNativeJsTypeInterceWithDefaultMethod implements
NativeJsTypeInterfaceWithStaticInitializationAndInstanceOverlayMethod {
@JsProperty
public int getA() {
return 4;
}
}

public void testNativeJsTypeWithStaticIntializer() { public void testNativeJsTypeWithStaticIntializer() {
assertEquals(3, NativeJsTypeInterfaceWithStaticInitializationAndFieldAccess.object); assertEquals(3, NativeJsTypeInterfaceWithStaticInitializationAndFieldAccess.object);
assertEquals( assertEquals(
Expand All @@ -1346,5 +1354,6 @@ public void testNativeJsTypeWithStaticIntializer() {
createNativeJsTypeInterfaceWithStaticInitializationAndInstanceOverlayMethod() createNativeJsTypeInterfaceWithStaticInitializationAndInstanceOverlayMethod()
.getObject()); .getObject());
assertEquals(7, NativeJsTypeInterfaceWithComplexStaticInitialization.object); assertEquals(7, NativeJsTypeInterfaceWithComplexStaticInitialization.object);
assertEquals(9, new JavaTypeImplementingNativeJsTypeInterceWithDefaultMethod().getObject());
} }
} }

0 comments on commit 514862d

Please sign in to comment.