http://gwt-code-reviews.appspot.com/126817/diff/2006/2007#newcode234
Line 234: JMethod res = (JMethod) lookup("test.Bar::foo(*)", errors);
It seems weird that this should work. If Bar didn't declare foo() (and
the lookup went up to the supertype Foo), this would fail to compile.
It breaks the otherwise-Java style of name lookups used by JSNI to care
about where the method is declared. It also rewards the unnecessary
(and ugly) practice of re-defining a method overload just to make it the
"default".
It's simplest to explain to users that the @class::method(*) wildcard
syntax selects the one method out of the entire supertype/superinterface
hierarchy whose name is "method" without having to get into discussions
about which type a method is declared on.
Also, on that vein, add test code for looking up wildcards on
interfaces.
http://gwt-code-reviews.appspot.com/126817/diff/2006/2007
File dev/core/test/com/google/gwt/dev/jjs/impl/JsniRefLookupTest.java
(right):
http://gwt-code-reviews.appspot.com/126817/diff/2006/2007#newcode234
Line 234: JMethod res = (JMethod) lookup("test.Bar::foo(*)", errors);
It seems weird that this should work. If Bar didn't declare foo() (and
the lookup went up to the supertype Foo), this would fail to compile.
It breaks the otherwise-Java style of name lookups used by JSNI to care
about where the method is declared. It also rewards the unnecessary
(and ugly) practice of re-defining a method overload just to make it the
"default".
It's simplest to explain to users that the @class::method(*) wildcard
syntax selects the one method out of the entire supertype/superinterface
hierarchy whose name is "method" without having to get into discussions
about which type a method is declared on.
Also, on that vein, add test code for looking up wildcards on
interfaces.
For a given type, collect all method signatures that could conceivably
be invoked via that type (and its superclasses or superinterfaces) and
succeed only if there is exactly one unique signature with the given
method name.
As an implementation optimization, lookups on a concrete class can
just crawl the supertype chain, but lookups on abstract type would
have to consider all superinterfaces as well.
--
Bob Vawter
Google Web Toolkit Team
I haven't looked at this, but should JsniCheckerTest get a new case as
well?
> I'm not in love with the current algorithm, but what precisely shall we do?For a given type, collect all method signatures that could conceivably
be invoked via that type (and its superclasses or superinterfaces) and
succeed only if there is exactly one unique signature with the given
method name.
The main trick is in dealing with bridge methods. I believe they should be ignored, because you can't normally call them in Java. However, we unfortunately currently allow them. So, as a compromise, the latest patch allows *direct* access to bridge methods, but it ignores them when resolving a wildcard.
http://gwt-code-reviews.appspot.com/126817/diff/2024/2038
File dev/core/src/com/google/gwt/dev/jjs/impl/JsniRefLookup.java
(right):
http://gwt-code-reviews.appspot.com/126817/diff/2024/2038#newcode118
Line 118: // Backward compatibility: allow accessing bridge methods with
full
Use block quote.
http://gwt-code-reviews.appspot.com/126817/diff/2024/2040
File dev/core/src/com/google/gwt/dev/js/rhino/TokenStream.java (right):
http://gwt-code-reviews.appspot.com/126817/diff/2024/2040#newcode1377
Line 1377: // First check for the special case of ?? as the parameter
list, indicating
Update the comment with *
http://gwt-code-reviews.appspot.com/126817/diff/2024/2039
File dev/core/src/com/google/gwt/dev/shell/DispatchClassInfo.java
(right):
http://gwt-code-reviews.appspot.com/126817/diff/2024/2039#newcode236
Line 236: private List<Member> removeSyntheticMembers(Collection<Member>
members) {
Since this doesn't mutate the input collection, rename it to "filter"
http://gwt-code-reviews.appspot.com/126817/diff/2024/2041
File dev/core/src/com/google/gwt/dev/util/JsniRef.java (right):
http://gwt-code-reviews.appspot.com/126817/diff/2024/2041#newcode128
Line 128:
Unnecessary blank lines.
http://gwt-code-reviews.appspot.com/126817/diff/2024/2026
File dev/core/test/com/google/gwt/dev/jjs/impl/JsniRefLookupTest.java
(right):
http://gwt-code-reviews.appspot.com/126817/diff/2024/2026#newcode50
Line 50: public void testConstructors() {
Sort order.
It's committed at r7368.
http://gwt-code-reviews.appspot.com/126817/diff/2024/2038
File dev/core/src/com/google/gwt/dev/jjs/impl/JsniRefLookup.java
(right):
http://gwt-code-reviews.appspot.com/126817/diff/2024/2038#newcode118
Line 118: // Backward compatibility: allow accessing bridge methods with
full
On 2010/01/06 23:02:41, bobv wrote:
> Use block quote.
Done.
http://gwt-code-reviews.appspot.com/126817/diff/2024/2040
File dev/core/src/com/google/gwt/dev/js/rhino/TokenStream.java (right):
http://gwt-code-reviews.appspot.com/126817/diff/2024/2040#newcode1377
Line 1377: // First check for the special case of ?? as the parameter
list, indicating
On 2010/01/06 23:02:41, bobv wrote:
> Update the comment with *
Done.
http://gwt-code-reviews.appspot.com/126817/diff/2024/2039
File dev/core/src/com/google/gwt/dev/shell/DispatchClassInfo.java
(right):
http://gwt-code-reviews.appspot.com/126817/diff/2024/2039#newcode236
Line 236: private List<Member> removeSyntheticMembers(Collection<Member>
members) {
Done. "filterOutSyntheticMembers".
http://gwt-code-reviews.appspot.com/126817/diff/2024/2041
File dev/core/src/com/google/gwt/dev/util/JsniRef.java (right):
http://gwt-code-reviews.appspot.com/126817/diff/2024/2041#newcode128
Line 128:
Done. Auto-sorting must have produced them.