From 797ec4d2ade426e40ada04881fdc83f799fd4cc9 Mon Sep 17 00:00:00 2001 From: aclement Date: Thu, 18 Oct 2007 11:03:05 +0000 Subject: [PATCH] 206732: fix to check for clashing ITDs, test already added. --- .../src/org/aspectj/weaver/ResolvedType.java | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/weaver/src/org/aspectj/weaver/ResolvedType.java b/weaver/src/org/aspectj/weaver/ResolvedType.java index c60a24f7f..7d0bf1faf 100644 --- a/weaver/src/org/aspectj/weaver/ResolvedType.java +++ b/weaver/src/org/aspectj/weaver/ResolvedType.java @@ -1508,12 +1508,34 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl // FIXME this whole method seems very hokey - unaware of covariance/varargs/bridging - it // could do with a rewrite ! boolean sameReturnTypes = (existingMember.getReturnType().equals(sig.getReturnType())); - if (sameReturnTypes) - getWorld().getMessageHandler().handleMessage( - MessageUtil.error(WeaverMessages.format(WeaverMessages.ITD_MEMBER_CONFLICT,munger.getAspectType().getName(), - existingMember), - munger.getSourceLocation()) - ); + if (sameReturnTypes) { + // pr206732 - if the existingMember is due to a previous application of this same ITD (which can + // happen if this is a binary type being brought in from the aspectpath). The 'better' fix is + // to recognize it is from the aspectpath at a higher level and dont do this, but that is rather + // more work. + boolean isDuplicateOfPreviousITD = false; + ResolvedType declaringRt = existingMember.getDeclaringType().resolve(world); + WeaverStateInfo wsi = declaringRt.getWeaverState(); + if (wsi!=null) { + List mungersAffectingThisType = wsi.getTypeMungers(declaringRt); + if (mungersAffectingThisType!=null) { + for (Iterator iterator = mungersAffectingThisType.iterator(); iterator.hasNext() && !isDuplicateOfPreviousITD;) { + ConcreteTypeMunger ctMunger = (ConcreteTypeMunger) iterator.next(); + // relatively crude check - is the ITD for the same as the existingmember and does it come from the same aspect + if (ctMunger.getSignature().equals(existingMember) && ctMunger.aspectType.equals(munger.getAspectType())) { + isDuplicateOfPreviousITD=true; + } + } + } + } + if (!isDuplicateOfPreviousITD) { + getWorld().getMessageHandler().handleMessage( + MessageUtil.error(WeaverMessages.format(WeaverMessages.ITD_MEMBER_CONFLICT,munger.getAspectType().getName(), + existingMember), + munger.getSourceLocation()) + ); + } + } } } else if (isDuplicateMemberWithinTargetType(existingMember,this,sig)) { getWorld().getMessageHandler().handleMessage( -- 2.39.5