]> source.dussan.org Git - aspectj.git/commitdiff
proper error checks for around advice return type compatibility with join points
authorjhugunin <jhugunin>
Wed, 8 Jan 2003 02:15:21 +0000 (02:15 +0000)
committerjhugunin <jhugunin>
Wed, 8 Jan 2003 02:15:21 +0000 (02:15 +0000)
weaver/src/org/aspectj/weaver/Advice.java

index cb6a4d5bc80579d3270c80a238edf2256f3681f0..b0b1023bd0d44290784c1816af3821a61cb2e79f 100644 (file)
@@ -112,13 +112,21 @@ public abstract class Advice extends ShadowMunger {
                                        getSourceLocation(), shadow.getSourceLocation());
                                        return false;
                        } else {
-                               if (!getSignature().getReturnType().isConvertableFrom(shadow.getReturnType(), world)) {
+                               //System.err.println(getSignature().getReturnType() + " from " + shadow.getReturnType());
+                               if (getSignature().getReturnType() == ResolvedTypeX.VOID) {
+                                       if (shadow.getReturnType() != ResolvedTypeX.VOID) {
+                                               world.showMessage(IMessage.ERROR, 
+                                                       "applying to join point that doesn't return void: " + shadow,
+                                                       getSourceLocation(), shadow.getSourceLocation());
+                                               return false;
+                                       }
+                               } else if (getSignature().getReturnType().equals(TypeX.OBJECT)) {
+                                       return true;
+                               } else if(!shadow.getReturnType().isAssignableFrom(getSignature().getReturnType(), world)) {
                                        //System.err.println(this + ", " + sourceContext + ", " + start);
-                                       
-                                       world.getMessageHandler().handleMessage(
-                                       MessageUtil.error("incompatible return type applying to " + shadow,
-                                               getSourceLocation()));
-                                       //XXX need a crosscutting error message here
+                                               world.showMessage(IMessage.ERROR, 
+                                                               "incompatible return type applying to " + shadow,
+                                                               getSourceLocation(), shadow.getSourceLocation());
                                        return false;
                                }
                        }