From d10d611c2ffcfe98285e89052c72887d2f148a14 Mon Sep 17 00:00:00 2001 From: aclement Date: Mon, 21 Nov 2005 15:54:49 +0000 Subject: [PATCH] pr115250: changed parameterizeWith() signature for shadowmungers. --- weaver/src/org/aspectj/weaver/Checker.java | 2 +- .../src/org/aspectj/weaver/ResolvedType.java | 2 +- .../src/org/aspectj/weaver/ShadowMunger.java | 2 +- .../org/aspectj/weaver/bcel/BcelAdvice.java | 22 ++++++++++++++++--- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/weaver/src/org/aspectj/weaver/Checker.java b/weaver/src/org/aspectj/weaver/Checker.java index c064c2610..f123ad36d 100644 --- a/weaver/src/org/aspectj/weaver/Checker.java +++ b/weaver/src/org/aspectj/weaver/Checker.java @@ -48,7 +48,7 @@ public class Checker extends ShadowMunger { throw new RuntimeException("illegal state"); } - public ShadowMunger parameterizeWith(Map typeVariableMap) { + public ShadowMunger parameterizeWith(ResolvedType declaringType,Map typeVariableMap) { Checker ret = new Checker( getPointcut().parameterizeWith(typeVariableMap), getStart(), diff --git a/weaver/src/org/aspectj/weaver/ResolvedType.java b/weaver/src/org/aspectj/weaver/ResolvedType.java index a590b7440..1c3f5a637 100644 --- a/weaver/src/org/aspectj/weaver/ResolvedType.java +++ b/weaver/src/org/aspectj/weaver/ResolvedType.java @@ -684,7 +684,7 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl if (munger != null) { if (this.isParameterizedType()) { //munger.setPointcut(munger.getPointcut().parameterizeWith(typeVariableMap)); - munger = munger.parameterizeWith(typeVariableMap); + munger = munger.parameterizeWith(this,typeVariableMap); if (munger instanceof Advice) { Advice advice = (Advice) munger; // update to use the parameterized signature... diff --git a/weaver/src/org/aspectj/weaver/ShadowMunger.java b/weaver/src/org/aspectj/weaver/ShadowMunger.java index 3ff34bd8d..3204a9625 100644 --- a/weaver/src/org/aspectj/weaver/ShadowMunger.java +++ b/weaver/src/org/aspectj/weaver/ShadowMunger.java @@ -64,7 +64,7 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH return pointcut.match(shadow).maybeTrue(); } - public abstract ShadowMunger parameterizeWith(Map typeVariableMap); + public abstract ShadowMunger parameterizeWith(ResolvedType declaringType,Map typeVariableMap); public int fallbackCompareTo(Object other) { return toString().compareTo(toString()); diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java b/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java index f8618e303..a27e3270a 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java @@ -87,9 +87,16 @@ public class BcelAdvice extends Advice { return ret; } - public ShadowMunger parameterizeWith(Map typeVariableMap) { + public ShadowMunger parameterizeWith(ResolvedType declaringType,Map typeVariableMap) { Pointcut pc = getPointcut().parameterizeWith(typeVariableMap); - BcelAdvice ret = new BcelAdvice(this.attribute,pc,this.signature,this.concreteAspect); + + BcelAdvice ret = null; + Member adviceSignature = signature; + // allows for around advice where the return value is a type variable (see pr115250) + if (signature instanceof ResolvedMember) { + adviceSignature = ((ResolvedMember)signature).parameterizedWith(declaringType.getTypeParameters(),declaringType,declaringType.isParameterizedType()); + } + ret = new BcelAdvice(this.attribute,pc,adviceSignature,this.concreteAspect); return ret; } @@ -503,7 +510,16 @@ public class BcelAdvice extends Advice { public InstructionList getNonTestAdviceInstructions(BcelShadow shadow) { return new InstructionList( - Utility.createInvoke(shadow.getFactory(), shadow.getWorld(), getSignature())); + Utility.createInvoke(shadow.getFactory(), shadow.getWorld(), getOriginalSignature())); + } + + public Member getOriginalSignature() { + Member sig = getSignature(); + if (sig instanceof ResolvedMember) { + ResolvedMember rsig = (ResolvedMember)sig; + if (rsig.hasBackingGenericMember()) return rsig.getBackingGenericMember(); + } + return sig; } public InstructionList getTestInstructions( -- 2.39.5