From b187712e592887ab56f1a1712de72ebce44ee475 Mon Sep 17 00:00:00 2001 From: aclement Date: Tue, 5 May 2009 23:41:12 +0000 Subject: [PATCH] 275032: test and fix: itd of no-arg constructor should overwrite a generated default constructor --- .../aspectj/weaver/JoinPointSignature.java | 4 ++ .../org/aspectj/weaver/ResolvedMember.java | 2 + .../aspectj/weaver/ResolvedMemberImpl.java | 63 +++++++++---------- .../src/org/aspectj/weaver/ResolvedType.java | 10 ++- 4 files changed, 43 insertions(+), 36 deletions(-) diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/JoinPointSignature.java b/org.aspectj.matcher/src/org/aspectj/weaver/JoinPointSignature.java index 8c52005a1..8cc690e77 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/JoinPointSignature.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/JoinPointSignature.java @@ -397,4 +397,8 @@ public class JoinPointSignature implements ResolvedMember { public String getSignatureErased() { return realMember.getSignatureErased(); } + + public boolean isDefaultConstructor() { + return realMember.isDefaultConstructor(); + } } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMember.java b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMember.java index 68ff1878e..84679cce0 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMember.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMember.java @@ -182,4 +182,6 @@ public interface ResolvedMember extends Member, AnnotatedElement, TypeVariableDe public ResolvedMember parameterizedWith(Map m, World w); + public boolean isDefaultConstructor(); + } \ No newline at end of file diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMemberImpl.java b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMemberImpl.java index 71b562d31..66e8e8fb1 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMemberImpl.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMemberImpl.java @@ -927,40 +927,33 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno return false; } boolean b = false; - /* if (ignoreGenerics) { - String myParameterSignature = getParameterSigWithBoundsRemoved(); - String candidateParameterSignature = candidateMatchImpl.getParameterSigWithBoundsRemoved(); - if (myParameterSignature.equals(candidateParameterSignature)) { - b = true; - } else { - myParameterSignature = (hasBackingGenericMember() ? backingGenericMember.getParameterSignatureErased() - : getParameterSignatureErased()); - candidateParameterSignature = (candidateMatchImpl.hasBackingGenericMember() ? candidateMatchImpl.backingGenericMember - .getParameterSignatureErased() - : candidateMatchImpl.getParameterSignatureErased()); - // System.out.println("my psig = " + myParameterSignature); - // System.out.println("can psig = " + candidateParameterSignature); - b = myParameterSignature.equals(candidateParameterSignature); - } + /* + * if (ignoreGenerics) { String myParameterSignature = getParameterSigWithBoundsRemoved(); String + * candidateParameterSignature = candidateMatchImpl.getParameterSigWithBoundsRemoved(); if + * (myParameterSignature.equals(candidateParameterSignature)) { b = true; } else { myParameterSignature = + * (hasBackingGenericMember() ? backingGenericMember.getParameterSignatureErased() : getParameterSignatureErased()); + * candidateParameterSignature = (candidateMatchImpl.hasBackingGenericMember() ? candidateMatchImpl.backingGenericMember + * .getParameterSignatureErased() : candidateMatchImpl.getParameterSignatureErased()); // System.out.println("my psig = " + + * myParameterSignature); // System.out.println("can psig = " + candidateParameterSignature); b = + * myParameterSignature.equals(candidateParameterSignature); } } else { + */ + String myParameterSignature = getParameterSigWithBoundsRemoved(); + String candidateParameterSignature = candidateMatchImpl.getParameterSigWithBoundsRemoved(); + if (myParameterSignature.equals(candidateParameterSignature)) { + b = true; } else { -*/ - String myParameterSignature = getParameterSigWithBoundsRemoved(); - String candidateParameterSignature = candidateMatchImpl.getParameterSigWithBoundsRemoved(); - if (myParameterSignature.equals(candidateParameterSignature)) { - b = true; - } else { - // try erasure - myParameterSignature = getParameterSignatureErased(); - candidateParameterSignature = candidateMatchImpl.getParameterSignatureErased(); - // myParameterSignature = (hasBackingGenericMember() ? backingGenericMember.getParameterSignatureErased() - // : getParameterSignatureErased()); - // candidateParameterSignature = (candidateMatchImpl.hasBackingGenericMember() ? - // candidateMatchImpl.backingGenericMember - // .getParameterSignatureErased() : candidateMatchImpl.getParameterSignatureErased()); - // System.out.println("my psig = " + myParameterSignature); - // System.out.println("can psig = " + candidateParameterSignature); - b = myParameterSignature.equals(candidateParameterSignature); -// } + // try erasure + myParameterSignature = getParameterSignatureErased(); + candidateParameterSignature = candidateMatchImpl.getParameterSignatureErased(); + // myParameterSignature = (hasBackingGenericMember() ? backingGenericMember.getParameterSignatureErased() + // : getParameterSignatureErased()); + // candidateParameterSignature = (candidateMatchImpl.hasBackingGenericMember() ? + // candidateMatchImpl.backingGenericMember + // .getParameterSignatureErased() : candidateMatchImpl.getParameterSignatureErased()); + // System.out.println("my psig = " + myParameterSignature); + // System.out.println("can psig = " + candidateParameterSignature); + b = myParameterSignature.equals(candidateParameterSignature); + // } } // System.out.println("Checking param signatures: " + b); return b; @@ -1182,4 +1175,8 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno public boolean isEquivalentTo(Object other) { return this.equals(other); } + + public boolean isDefaultConstructor() { + return false; + } } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java index af7523a11..503476ff3 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java @@ -1609,9 +1609,13 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl } } if (!isDuplicateOfPreviousITD) { - getWorld().getMessageHandler().handleMessage( - MessageUtil.error(WeaverMessages.format(WeaverMessages.ITD_MEMBER_CONFLICT, munger - .getAspectType().getName(), existingMember), munger.getSourceLocation())); + // b275032 - this is OK if it is the default ctor and that default ctor was generated + // at compile time, otherwise we cannot overwrite it + if (!(munger.getSignature().getName().equals("") && existingMember.isDefaultConstructor())) { + getWorld().getMessageHandler().handleMessage( + MessageUtil.error(WeaverMessages.format(WeaverMessages.ITD_MEMBER_CONFLICT, munger + .getAspectType().getName(), existingMember), munger.getSourceLocation())); + } } } } -- 2.39.5