Allow name conflicts in native properties.
A native property is allowed to have the same name as a native method.
A property is considered native if both setter and getter are native
if they exist.
Bug: #9327
Bug-Link: http://github.com/gwtproject/gwt/issues/9327
Change-Id: I047fae52e344453eb1222c5a8e594f5f4cf53bff
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 1519ca6..8da4fc4 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
@@ -533,7 +533,7 @@
return;
}
- if (oldJsMember.isNativeMethod() && newJsMember.isNativeMethod()) {
+ if (oldJsMember.isJsNative() && newJsMember.isJsNative()) {
return;
}
@@ -799,8 +799,8 @@
this.getter = getter;
}
- public boolean isNativeMethod() {
- return member instanceof JMethod && member.isJsNative() && !isPropertyAccessor();
+ public boolean isJsNative() {
+ return member.isJsNative();
}
public boolean isPropertyAccessor() {
diff --git a/dev/core/test/com/google/gwt/dev/jjs/impl/JsInteropRestrictionCheckerTest.java b/dev/core/test/com/google/gwt/dev/jjs/impl/JsInteropRestrictionCheckerTest.java
index ae5835a..529583e 100644
--- a/dev/core/test/com/google/gwt/dev/jjs/impl/JsInteropRestrictionCheckerTest.java
+++ b/dev/core/test/com/google/gwt/dev/jjs/impl/JsInteropRestrictionCheckerTest.java
@@ -262,6 +262,30 @@
+ "cannot both use the same JavaScript name 'x'.");
}
+ public void testCollidingNativeJsPropertiesSucceeds() throws Exception {
+ addSnippetImport("jsinterop.annotations.JsType");
+ addSnippetImport("jsinterop.annotations.JsMethod");
+ addSnippetImport("jsinterop.annotations.JsProperty");
+ addSnippetClassDecl(
+ "@JsType(isNative=true)",
+ "public static class Buggy {",
+ " @JsMethod",
+ " public native int now();",
+ " @JsProperty",
+ " public native Object getNow();",
+ " @JsMethod",
+ " public static native int other();",
+ " @JsProperty",
+ " public static native Object getOther();",
+ " @JsMethod",
+ " public static native int another();",
+ " @JsProperty",
+ " public static Object another;",
+ "}");
+
+ assertBuggySucceeds();
+ }
+
public void testCollidingJsPropertiesTwoSettersFails() throws Exception {
addSnippetImport("jsinterop.annotations.JsType");
addSnippetImport("jsinterop.annotations.JsProperty");