Summary: | [Generics + ITD] Strange 'return types don't match' error when trying to override | ||||||
---|---|---|---|---|---|---|---|
Product: | [Tools] AspectJ | Reporter: | Michael Esser <MikeEA> | ||||
Component: | Compiler | Assignee: | aspectj inbox <aspectj-inbox> | ||||
Status: | RESOLVED FIXED | QA Contact: | |||||
Severity: | normal | ||||||
Priority: | P2 | CC: | aclement, MikeEA | ||||
Version: | 1.5.4 | ||||||
Target Milestone: | 1.6.2 | ||||||
Hardware: | PC | ||||||
OS: | Windows XP | ||||||
Whiteboard: | |||||||
Attachments: |
|
Description
Michael Esser
2008-03-13 15:42:21 EDT
> I don't understand why it says:
> ' ... override ... with java.lang.Object Marker.getContent()'
> since it should be
> ' ... override ... with CONTENT Marker<CONTENT>.getContent()'
> !?
I have seen similar bugs - it is usually because the type variable has been inadvertently collapsed/erased to its bound, so you see Object instead of the type var CONTENT.
fix committed, thanks for the testcase.
Problem here is type caching - when we encounter:
abstract public class Foo <CONTENT extends Resource<CONTENT>, DATA extends
DataInterface<CONTENT>
> extends FooBase<DATA>
{ }
we record an entry in the cache for signature DataInterface<CONTENT> that points to DataInterface<Content extends Resource>
later when we are walking up the Marker hierarchy we lookup DataInterface<CONTENT> and find that variant - which is the wrong one (the type variable bounds are different in the second use of DataInterface, although the type variable has the same name). And because the ITD doesn't match a variant where the signature of getContent is
<CONTENT extends Resource> getContent()
then we fail with the overrides error.
The solution is to stop caching those things as it can get us into trouble. that is the fix I've implemented - but i need to keep an eye on things to make sure it hasn't affected performance too much. if it has I will need to change the caching key in some way (likely include the bounds in the key).
|