Summary: | Generics problem with Set - does not compile with AspectJ 5 | ||||||
---|---|---|---|---|---|---|---|
Product: | [Tools] AspectJ | Reporter: | Oliver <boehm> | ||||
Component: | Compiler | Assignee: | Adrian Colyer <adrian.colyer> | ||||
Status: | RESOLVED FIXED | QA Contact: | |||||
Severity: | normal | ||||||
Priority: | P3 | ||||||
Version: | 1.5.0M2 | ||||||
Target Milestone: | 1.5.0 M3 | ||||||
Hardware: | PC | ||||||
OS: | Linux | ||||||
Whiteboard: | |||||||
Attachments: |
|
Description
Oliver
2005-04-11 17:15:13 EDT
Created attachment 19782 [details]
the problematic source code
sources where the error occurs (about 180 LOC including comments)
as compressed tar file (2 KB)
I've fixed this - a smaller program that shows the problem is: import java.util.*; aspect X { private Set PR91053.aSet = new HashSet(); public void PR91053.add(String s) { aSet.add(s); } } public class PR91053 { public static void main(String[]argv) { new PR91053().add("hello"); } } The problem is that when the intertype field declaration is captured we lose the fact that the Set is a raw type binding (i.e. a parameterized type where no bounds have been specified for any of the parameters) - and when we recover the binding later we create an ordinary type binding for it. Losing that information means later on when resolving the receiver of the MessageSend (Set.add) we end up in BinaryTypeBinding.getExactMethod() rather than ParameterizedTypeBinding.getExactMethod(). The former of these doesn't look at whether methods are parameterized and so thinks add(E) doesn't match add(SubjectObserver). The fix is to preserve that it is a raw type binding. I have done this by saying if the typex is parameterized but has no typeparameters then it is considered raw. That seems good enough for now but may break with some case I haven't come across yet... fix checked in, waiting on build... Fix available in latest AspectJ Dev build, see AJ downloads page: http://eclipse.org/aspectj/downloads.php |