From 7fd50c75ae779195b87922c5ffd839ac7a6910bf Mon Sep 17 00:00:00 2001 From: acolyer Date: Wed, 18 Aug 2004 08:25:46 +0000 Subject: test for Bugzilla Bug 64069 ITD name clashes with private members --- weaver/src/org/aspectj/weaver/ResolvedTypeX.java | 25 ++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'weaver/src') diff --git a/weaver/src/org/aspectj/weaver/ResolvedTypeX.java b/weaver/src/org/aspectj/weaver/ResolvedTypeX.java index c21a5db91..3fbf7d588 100644 --- a/weaver/src/org/aspectj/weaver/ResolvedTypeX.java +++ b/weaver/src/org/aspectj/weaver/ResolvedTypeX.java @@ -1140,8 +1140,12 @@ public abstract class ResolvedTypeX extends TypeX { munger.getSourceLocation()) ); } - } else { - //interTypeMungers.add(munger); + } else if (isDuplicateMemberWithinTargetType(existingMember,this,sig)) { + getWorld().getMessageHandler().handleMessage( + MessageUtil.error(WeaverMessages.format(WeaverMessages.ITD_MEMBER_CONFLICT,munger.getAspectType().getName(), + existingMember), + munger.getSourceLocation()) + );; } //return; } @@ -1149,6 +1153,23 @@ public abstract class ResolvedTypeX extends TypeX { return true; } + // we know that the member signature matches, but that the member in the target type is not visible to the aspect. + // this may still be disallowed if it would result in two members within the same declaring type with the same + // signature AND more than one of them is concrete AND they are both visible within the target type. + private boolean isDuplicateMemberWithinTargetType(ResolvedMember existingMember, ResolvedTypeX targetType,ResolvedMember itdMember) { + if ( (existingMember.isAbstract() || itdMember.isAbstract())) return false; + TypeX declaringType = existingMember.getDeclaringType(); + if (!targetType.equals(declaringType)) return false; + // now have to test that itdMember is visible from targetType + if (itdMember.isPrivate()) return false; + if (itdMember.isPublic()) return true; + // must be in same package to be visible then... + if (!targetType.getPackageName().equals(itdMember.getDeclaringType().getPackageName())) return false; + + // trying to put two members with the same signature into the exact same type..., and both visible in that type. + return true; + } + public boolean checkLegalOverride(ResolvedMember parent, ResolvedMember child) { //System.err.println("check: " + child.getDeclaringType() + " overrides " + parent.getDeclaringType()); if (!parent.getReturnType().equals(child.getReturnType())) { -- cgit v1.2.3