diff options
author | Andy Clement <aclement@pivotal.io> | 2016-07-29 10:05:50 -0700 |
---|---|---|
committer | Andy Clement <aclement@pivotal.io> | 2016-07-29 10:05:50 -0700 |
commit | 87856659869b9dbf72e1b329986fb2d727cfad18 (patch) | |
tree | be703a38baedd823689b7279e7641c19abb2dee6 /tests/bugs1810 | |
parent | 784906d2ee0cb1b432a9aff6973c12cfd865db6e (diff) | |
download | aspectj-87856659869b9dbf72e1b329986fb2d727cfad18.tar.gz aspectj-87856659869b9dbf72e1b329986fb2d727cfad18.zip |
Fix ambiguous binding problem on anonymous types
If an anonymous class calls a method ITD'd onto one of its own
supertypes (e.g. new A() { xx(null); }) then it can be reported
as an ambiguous method invocation on Java8. There is different
handling for Java8 that is revealing an issue. The intertype
method declarations are recorded in a member finder attached to the
target type (A in this case). When the local type binding is
built it gets all the methods from supertypes added to it - this
unfortunately includes the ITD method. Then later when something
asks for all 'xx' methods on A, it finds the ITD method from when
A was constructed and an additional copy from the member finder.
The quick fix is for the member finder to use a set rather than
list when answering 'what are the xx methods'. If this proves
a problem down the line the deeper fix would be to avoid including
ITDs when the local type binding is built.
Diffstat (limited to 'tests/bugs1810')
-rw-r--r-- | tests/bugs1810/ambig/Code.java | 8 | ||||
-rw-r--r-- | tests/bugs1810/ambig/X.java | 13 |
2 files changed, 21 insertions, 0 deletions
diff --git a/tests/bugs1810/ambig/Code.java b/tests/bugs1810/ambig/Code.java new file mode 100644 index 000000000..dab8d6f09 --- /dev/null +++ b/tests/bugs1810/ambig/Code.java @@ -0,0 +1,8 @@ +import java.util.List; + +aspect F { void A.xx(List<String> x) { xx(null);this.xx(null);};} +class A {} +class B extends A { void xx(List<String> x) { xx(null); this.xx(null); super.xx(null); }} +class C implements D { public void xx(List<String> x) { xx(null); new A().xx(null); new B().xx(null); }} +interface D { void xx(List<String> x); } +class E { void foo() { new B().xx(null); new A() {}.xx(null); } } diff --git a/tests/bugs1810/ambig/X.java b/tests/bugs1810/ambig/X.java new file mode 100644 index 000000000..6f0a73d97 --- /dev/null +++ b/tests/bugs1810/ambig/X.java @@ -0,0 +1,13 @@ +import java.util.List; + +aspect F { + void A.xx(List<String> x) { } +} +class A { + //void xx(List<String> x) {} +} +class E { + void foo() { + new A() {}.xx(null); + } +} |