[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] Just for fun: declare error to prevent use of inheritance?
|
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
<andrew.clement@xxxxxxxxx> 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
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users
--
mailto:matthew@xxxxxxxxxxxxxxx