]> source.dussan.org Git - aspectj.git/commitdiff
Fix for Bugzilla Bug 61568
authoraclement <aclement>
Wed, 12 May 2004 13:00:49 +0000 (13:00 +0000)
committeraclement <aclement>
Wed, 12 May 2004 13:00:49 +0000 (13:00 +0000)
   wrong variable binding in || pointcuts

weaver/src/org/aspectj/weaver/patterns/ExposedState.java
weaver/src/org/aspectj/weaver/patterns/NameBindingPointcut.java

index 8e130c6893e7c2e1b7e3ce5993c4507851eea0b0..063b5608e614b124c42752b709598d083c6a3259 100644 (file)
@@ -35,6 +35,7 @@ public class ExposedState {
 
        public void set(int i, Var var) {
                //XXX add sanity checks
+               // Check (1) added to call of set(), verifies we aren't binding twice to the same formal
                vars[i] = var;
        }
     public Var get(int i) {
index 6fa9af44000dba76dd46768149096a3d9416b886..593555d9fb182cb7f31d884f724155b32d826ddd 100644 (file)
@@ -13,6 +13,7 @@
 
 package org.aspectj.weaver.patterns;
 
+import org.aspectj.bridge.MessageUtil;
 import org.aspectj.weaver.TypeX;
 import org.aspectj.weaver.World;
 import org.aspectj.weaver.ast.Test;
@@ -33,7 +34,13 @@ public abstract class NameBindingPointcut extends Pointcut {
        protected Test exposeStateForVar(Var var,TypePattern type, ExposedState state, World world) {
                if (type instanceof BindingTypePattern) {
                        BindingTypePattern b = (BindingTypePattern)type;
-                       state.set(b.getFormalIndex(), var);
+                       if (state.get(b.getFormalIndex())!=null) {
+                               world.getMessageHandler().handleMessage(MessageUtil.error(
+                  "Ambiguous binding of type "+type.getExactType().toString()+".  Use one args(..) per matched join point",
+                  getSourceLocation()));
+                       } else {
+                               state.set(b.getFormalIndex(), var);
+                       }
                }
                TypeX myType = type.getExactType(); //should have failed earlier