From 81228854e0cd74f3a771aafbffb06b264fdac59f Mon Sep 17 00:00:00 2001 From: aclement Date: Wed, 15 Feb 2006 11:10:19 +0000 Subject: [PATCH] test and fix for 120527 --- .../compiler/problem/AjProblemReporter.java | 27 +++++++++++++++++-- tests/bugs151/pr120527/Bugs.aj | 11 ++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 tests/bugs151/pr120527/Bugs.aj diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java index 02b2fe6b6..c66247514 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java @@ -42,6 +42,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; import org.aspectj.org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.aspectj.org.eclipse.jdt.internal.compiler.impl.ReferenceContext; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ArrayBinding; +import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MemberTypeBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding; @@ -54,8 +55,11 @@ import org.aspectj.weaver.ConcreteTypeMunger; import org.aspectj.weaver.ResolvedMember; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.Shadow; +import org.aspectj.weaver.UnresolvedType; import org.aspectj.weaver.patterns.DeclareAnnotation; +import org.aspectj.weaver.patterns.DeclareParents; import org.aspectj.weaver.patterns.DeclareSoft; +import org.aspectj.weaver.patterns.TypePattern; /** * Extends problem reporter to support compiler-side implementation of declare soft. @@ -415,8 +419,27 @@ public class AjProblemReporter extends ProblemReporter { public void unusedPrivateType(TypeDeclaration typeDecl) { // don't output unused type warnings for aspects! - if (!(typeDecl instanceof AspectDeclaration)) - super.unusedPrivateType(typeDecl); + if (typeDecl instanceof AspectDeclaration) return; + if (typeDecl.enclosingType!=null && (typeDecl.enclosingType instanceof AspectDeclaration)) { + AspectDeclaration ad = (AspectDeclaration)typeDecl.enclosingType; + if (ad.concreteName!=null) { + List declares = ad.concreteName.declares; + for (Iterator iter = declares.iterator(); iter.hasNext();) { + Object dec = (Object) iter.next(); + if (dec instanceof DeclareParents) { + DeclareParents decp = (DeclareParents)dec; + TypePattern[] newparents = decp.getParents().getTypePatterns(); + for (int i = 0; i < newparents.length; i++) { + TypePattern pattern = newparents[i]; + UnresolvedType ut = pattern.getExactType(); + if (ut==null) continue; + if (CharOperation.compareWith(typeDecl.binding.signature(),ut.getSignature().toCharArray())==0) return; + } + } + } + } + } + super.unusedPrivateType(typeDecl); } public void unusedPrivateMethod(AbstractMethodDeclaration methodDecl) { diff --git a/tests/bugs151/pr120527/Bugs.aj b/tests/bugs151/pr120527/Bugs.aj new file mode 100644 index 000000000..83ade6779 --- /dev/null +++ b/tests/bugs151/pr120527/Bugs.aj @@ -0,0 +1,11 @@ +public class Bugs { + public static void main(String[] args) { + System.out.println("" + (new C())); // + instanceof A.I)); + } + static class C{} + + static aspect A { + private interface I {} + declare parents : C implements I; + } +} -- 2.39.5