Interesting.  I like all of the suggestions.  I entered an issue to track
this:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=387499

Thanks!

On Thu, Aug 16, 2012 at 3:05 PM, Andy Clement <[email protected]>wrote:

> I haven't spent toooo long thinking about it, but I don't think you
> can at the moment. We don't really have the capabilities to introspect
> the class hierarchy to that level of detail.
>
> Some made up syntaxes:
>
> If 'Object+' indicates subtypes, let's add a numeric to indicate distance:
> declare error:  within(Object+2): "Type does not directly extend
> object"; // maybe add the type category type pattern too:
> within(is(ClassType) && Object+2)
> declare error: within(Object+>2):   "Type does not directly extend object";
>
> More direct:
> declare error within(!extends(Object)): "Type does not directly extend
> object"; // if 'extends' is strictly looking at the declared type and
> not the inheritance chain.
>
> You could probably cause an error if you tried to use declare parents
> extends with a simple type because extends will report an error if the
> new type doesn't have the same parent as the existing type:
>
> class Foo1 {}
> class Foo2 extends ArrayList {}
>
> class Marker {}
>
> aspect X {
>   declare parents: Foo* extends Marker;
> }
>
> will give an error ... but it isn't as simple as a nice message saying
> 'type Foo2 doesn't directly extend Object.'
>
> cheers,
> Andy
>
> On 16 August 2012 08:40, Matthew Adams <[email protected]> wrote:
> > Just for fun, I was trying to think of how to use declare error to
> prevent
> > the use of class inheritance in user code, but I can't think of how to do
> > that.
> >
> > Basically, if you wanted to disallow the declaration of classes that
> extend
> > anything other than Object, is there a "declare error" form that would
> work?
> >
> > -matthew
> >
> > --
> > mailto:[email protected]
> > skype:matthewadams12
> > googletalk:[email protected]
> > http://matthewadams.me
> > http://www.linkedin.com/in/matthewadams
> >
> >
> > _______________________________________________
> > aspectj-users mailing list
> > [email protected]
> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>



-- 
mailto:[email protected] <[email protected]>
skype:matthewadams12
googletalk:[email protected]
http://matthewadams.me
http://www.linkedin.com/in/matthewadams
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to