]> source.dussan.org Git - aspectj.git/commitdiff
better errors for dominates circularities
authorjhugunin <jhugunin>
Wed, 1 Jan 2003 01:32:00 +0000 (01:32 +0000)
committerjhugunin <jhugunin>
Wed, 1 Jan 2003 01:32:00 +0000 (01:32 +0000)
weaver/src/org/aspectj/weaver/patterns/DeclareDominates.java

index 87eed741dc157e33233b762fde9dd6b9aba59d2d..35d9e071c129edec09929acbae609a524183e0d9 100644 (file)
@@ -64,7 +64,24 @@ public class DeclareDominates extends Declare {
        }
        
     public void resolve(IScope scope) {
-       patterns = patterns.resolveBindings(scope, Bindings.NONE, false, false);        
+       patterns = patterns.resolveBindings(scope, Bindings.NONE, false, false); 
+       
+       for (int i=0; i < patterns.size(); i++) {
+               TypePattern pi = patterns.get(i);
+               if (pi.isStar()) continue;
+               ResolvedTypeX exactType = pi.getExactType().resolve(scope.getWorld());
+               if (exactType == ResolvedTypeX.MISSING) continue;
+               for (int j=0; j < patterns.size(); j++) {
+                       if (j == i) continue;
+                       TypePattern pj = patterns.get(j);
+                       if (pj.isStar()) continue;
+                       if (pj.matchesStatically(exactType)) {
+                               scope.getWorld().showMessage(IMessage.ERROR,
+                                       "circularity in declare dominates, '" + exactType.getName() + 
+                                               "' matches two patterns", pi.getSourceLocation(), pj.getSourceLocation());
+                       }
+               }
+       }       
     }
 
        public TypePatternList getPatterns() {