Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-dev] Declare parents extends quirk ? Comments?


Here is a simple set of types I have in a source file:

=========================
class X { }

class SubX extends X { }

aspect A {
 declare parents: X+ extends java.util.Observable;
}
=========================

(Note the inclusion of the + on the type pattern).

if I compile it, it succeeds and X now extends Observable (SubX does not because X does)

Now, if I switch it to this (order of types switched):

=========================
class SubX extends X { }

class X { }

aspect A {
 declare parents: X+ extends java.util.Observable;
}
=========================

And compile it, I get:

============
C:\ajbugs\p\A.java:6 error can only insert a class into hierarchy, but java.util.Observable is not a  subtype of X
declare parents: X+ extends java.util.Observable;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1 error
============

It is because this time the compiler encountered 'SubX' first, which matched 'X+' - it then barfed because we could not insert Observable into the hierarchy, as Observable does not extend X.  

This made me think that specifying a '+' on the type pattern in the case of 'extends <class>' should be regarded as an error ?  Is there any case when it would actually make sense?

Andy.

Back to the top