Bug 265042 - Around advice don't support covariance
Summary: Around advice don't support covariance
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.6.3   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-16 12:31 EST by Martin Probst CLA
Modified: 2010-01-12 19:56 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Probst CLA 2009-02-16 12:31:49 EST
If I have these classes:

class A {
  Number foo();
}
class B extends A {
  Integer foo();
}

and I now have this aspect:

aspect X {
  Number around(A a): call(Number A.foo()) && target(a) {
    Number num = proceed();
    return num;
  }
}

I'm going to get an error trying to weave the code. The problem is that there is (apparently) no way to express that the around advice is going to return a different type, depending on the type foo() returns. I.e. in pseudosyntax:

  <T extends Number> T around(A a): call(T A.foo()) && target(a) { ... }
Comment 1 Andrew Clement CLA 2009-02-16 13:04:25 EST
You can generalize the advice to just Object return and it will successfully advise both.  But that is just a workaround.