| Urk.   > 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? 
 A use-case for      declare parents: T+ extends C;   is an opt-in tag interface, as in "declare that your class implements 
 interface T and everything will be handled for you"   More generally, hierarchy-dependent semantics seem 
to conflict with per-class  weaving.  Does the same problem not exist when declaring a member 
of an interface,  and we encounter a subclass before the superclass?   We could weave supertypes before subtypes, but that wouldn't handle 
situations  where the subtype is in an earlier weave process (not that we provide 
any guarantees when doing separate weaves of related classes).  Does 
that solve this?   Wes   
  ------------Original Message------------ From: Andrew Clement <CLEMAS@xxxxxxxxxx> To: aspectj-dev@xxxxxxxxxxx Date: Tue, Aug-24-2004 8:15 AM Subject: [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.
 |