Bug 120015 - [generics-itds]Better Generic Aspect Concretization
Summary: [generics-itds]Better Generic Aspect Concretization
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: PC All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-08 17:09 EST by david.pearce CLA
Modified: 2013-06-24 11:01 EDT (History)
0 users

See Also:


Attachments
More complete example based on ParentChildRelationship (1.25 KB, application/x-compressed-tar)
2005-12-08 17:14 EST, david.pearce CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description david.pearce CLA 2005-12-08 17:09:33 EST
Hi,

The problem I have is motivated by the following:

> class Course {}
> class Student {}
>
> abstract aspect A<X,Y> {
> interface FROM<T> {}
> interface TO<T> {}
>
> declare parents: X extends FROM<Y>;
> declare parents: Y extends TO<X>;
>
> private List<T> FROM.Rel;
> private List<T> TO.Rel;
>}
>
> aspect B extends A<Student,Course> {}
> aspect C extends A<Student,Student> {}

In the current version of ajc, this gives the following error:

> [error] Cannot declare parent A$FROM<Student> onto type Student 
> since it already has A$FROM<Course> in its hierarchy
> declare parents: X extends I<Y>;
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

But, if we expand the generic aspect by hand it works fine:

> aspect B {
> interface FROM {}
> interface TO {}
>
> declare parents: Student extends FROM;
> declare parents: Course extends TO;
>
> private List<Student> FROM.Rel;
> private List<Course> TO.Rel;
>}
>
> aspect C {
> interface FROM {}
> interface TO {}
>
> declare parents: Student extends FROM;
> declare parents: Student extends TO;
>
> private List<Student> FROM.Rel;
> private List<Student> TO.Rel;
>}

This is OK because the interfaces FROM and TO are really B.FROM, B.TO and C.FROM and C.TO which don't clash.  

My example is essentially the ParentChildRelationship example from the website.   Currently, we are limited to declaring one ParentChildRelationship per class (rather than potentially many as is done above).  It would be very beneficial to allow many different relationships to be implemented for a given class (e.g. student->student, student->course etc).

Therefore, I believe it makes sense to treat generic aspects more like C++ templates.  That is, we regard the concretization of a generic aspects as though the aspect were "inlined" into the concreting aspect with type parameters substituted as appropriate.  This would give the desired functionality and would also provide a nice and clear way of reasoning about how generic aspects behave.

Thanks,

David J. Pearce
Comment 1 david.pearce CLA 2005-12-08 17:14:30 EST
Created attachment 31428 [details]
More complete example based on ParentChildRelationship

Just added code for a more complete example based on the ParentChildRelationship.
Comment 2 Andrew Clement CLA 2013-06-24 11:01:33 EDT
unsetting the target field which is currently set for something already released