]> source.dussan.org Git - aspectj.git/commitdiff
test and fix for 120527
authoraclement <aclement>
Wed, 15 Feb 2006 11:10:19 +0000 (11:10 +0000)
committeraclement <aclement>
Wed, 15 Feb 2006 11:10:19 +0000 (11:10 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java
tests/bugs151/pr120527/Bugs.aj [new file with mode: 0644]

index 02b2fe6b65a13a3a3ebbc051b084053054d3161b..c662475141c1d2ed7dbf187e10dc0842f20a3069 100644 (file)
@@ -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 (file)
index 0000000..83ade67
--- /dev/null
@@ -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;       
+        }
+}