]> source.dussan.org Git - aspectj.git/commitdiff
Fix for Bugzilla Bug 62073
authoraclement <aclement>
Fri, 14 May 2004 09:26:03 +0000 (09:26 +0000)
committeraclement <aclement>
Fri, 14 May 2004 09:26:03 +0000 (09:26 +0000)
   false ambigous binding error (introduced in 1.2rc2)

org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/WeaverMessageHandler.java
weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java
weaver/src/org/aspectj/weaver/patterns/NameBindingPointcut.java

index 5f2f49f720d270d2a7a6bf7b5b340a4d500a39a5..71017a6c398ff954c2973403221ee53c17145445 100644 (file)
@@ -49,6 +49,19 @@ public class WeaverMessageHandler implements IMessageHandler {
                if (! (message.isError() || message.isWarning()) ) return sink.handleMessage(message);
                // we only care about warnings and errors here...
                ISourceLocation sLoc = message.getSourceLocation();
+               
+               // See bug 62073.  We should assert that the caller pass the correct primary source location.
+               // But for AJ1.2 final we will simply do less processing of the locations if that is not the
+               // case (By calling sink.handleMessage()) - this ensures we don't put out bogus source context info.
+               if (sLoc instanceof EclipseSourceLocation) {
+                       EclipseSourceLocation esLoc = (EclipseSourceLocation)sLoc;
+                       if (currentlyWeaving!=null && esLoc.getCompilationResult()!=null) {
+                         if (!currentlyWeaving.equals(((EclipseSourceLocation)sLoc).getCompilationResult()))
+                         return sink.handleMessage(message);
+                         //  throw new RuntimeException("Primary source location must match the file we are currently processing!");
+                       }
+               }
+               
                CompilationResult problemSource = currentlyWeaving;
                if (problemSource == null) {
                        // must be a problem found during completeTypeBindings phase of begin to compile
index 86c55b920595c20006e45cda39c7c47df40ef2de..a8c6b0bb3e137d4ee242201f68ca6332ee7931eb 100644 (file)
@@ -18,6 +18,8 @@ import java.io.DataOutputStream;
 import java.io.IOException;
 
 import org.aspectj.bridge.IMessage;
+import org.aspectj.bridge.ISourceLocation;
+import org.aspectj.bridge.Message;
 import org.aspectj.util.FuzzyBoolean;
 import org.aspectj.weaver.BetaException;
 import org.aspectj.weaver.ISourceContext;
@@ -118,6 +120,17 @@ public class ArgsPointcut extends NameBindingPointcut {
                                if (type.matchesInstanceof(shadow.getIWorld().resolve(argType)).alwaysTrue()) {
                                        continue;
                                }
+                       } else {
+                         BindingTypePattern btp = (BindingTypePattern)type;
+                         // Check if we have already bound something to this formal
+                         if (state.get(btp.getFormalIndex())!=null) {
+                               ISourceLocation isl = getSourceLocation();
+                               Message errorMessage = new Message(
+                    "Ambiguous binding of type "+type.getExactType().toString()+
+                    " using args(..) at this line.  Use one args(..) per matched join point,"+"" +\r                    " see secondary source location for location of extraneous args(..)",
+                                       shadow.getSourceLocation(),true,new ISourceLocation[]{getSourceLocation()});
+                               shadow.getIWorld().getMessageHandler().handleMessage(errorMessage);
+                         }
                        }
                        ret = Test.makeAnd(ret,
                                exposeStateForVar(shadow.getArgVar(i), type, state,shadow.getIWorld()));
index 593555d9fb182cb7f31d884f724155b32d826ddd..5bef982af3e5004811e44cab9fbb9282c5781f05 100644 (file)
@@ -34,13 +34,7 @@ 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;
-                       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);
-                       }
+                       state.set(b.getFormalIndex(), var);
                }
                TypeX myType = type.getExactType(); //should have failed earlier