]> source.dussan.org Git - aspectj.git/commitdiff
Fix for Bugzilla Bug 88652: an array type as the last parameter in a signature does...
authoracolyer <acolyer>
Tue, 22 Mar 2005 13:14:44 +0000 (13:14 +0000)
committeracolyer <acolyer>
Tue, 22 Mar 2005 13:14:44 +0000 (13:14 +0000)
tests/java5/varargs/Pr88652.aj [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java
weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java
weaver/src/org/aspectj/weaver/patterns/TypePattern.java
weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java

diff --git a/tests/java5/varargs/Pr88652.aj b/tests/java5/varargs/Pr88652.aj
new file mode 100644 (file)
index 0000000..bd3141c
--- /dev/null
@@ -0,0 +1,20 @@
+public aspect Pr88652 {
+       
+       pointcut p(): call(Touple.new(..));
+       
+       declare warning: p() : "should match";
+       
+       public static void main(String[] args) {
+               Touple t = new Touple(new Object());
+               Touple t2 = new Touple(new Object(),new Object());
+       }
+}
+
+
+class Touple {
+       
+       public Touple(Object formulaHandle, Object... propositions) {
+               ; // empty
+       }
+       
+}
\ No newline at end of file
index 3d75b53c7c26c76e4c193d550accfb1720837d26..bdcc31a410b7d47ec2e9fc92eac6703947e251d0 100644 (file)
@@ -141,6 +141,10 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
          runTest("invalid cons syntax");
   }
   
+  public void testVarargsInConsBug() {
+         runTest("varargs in constructor sig");
+  }
+  
   // helper methods.....
   
   public SyntheticRepository createRepos(File cpentry) {
index 84e1de484280ade4b91a7b054c4a4679f6584956..67370847d8d0ead78ba245a45577991d92df188b 100644 (file)
         <compile files="Rainbow.java" options="-emacssym,-1.5"/>
     </ajc-test>
 
+    <ajc-test dir="java5/varargs" title="varargs in constructor sig" vm="1.5">
+        <compile files="Pr88652.aj" options="-1.5">
+            <message kind="warning" line="8" text="should match"/>
+            <message kind="warning" line="9" text="should match"/>        
+        </compile>
+    </ajc-test>
+
     <ajc-test dir="java5/annotations" title="invalid cons syntax" vm="1.5">
         <compile files="SyntaxError.aj" options="-1.5">
             <message kind="error" line="3" text="Syntax error on token &quot;new&quot;, &quot;method name (not constructor)&quot; expected"/>
index b4e4ea7e3843d168875e81c5f43111fc552c41ab..6776579f32cdfe00a1556409776bbbc0c8447937 100644 (file)
@@ -70,6 +70,10 @@ public class ExactTypePattern extends TypePattern {
                this.type = type;
        }
        
+       public boolean isArray() { 
+               return type.isArray();
+       }
+       
        /* (non-Javadoc)
         * @see org.aspectj.weaver.patterns.TypePattern#couldEverMatchSameTypesAs(org.aspectj.weaver.patterns.TypePattern)
         */
index 126d45e951818dbbd66e772107f8bb93ab952efe..633e15748bdc9a554e7160b75bd3d71a2170f600 100644 (file)
@@ -573,11 +573,12 @@ public class SignaturePattern extends PatternNode {
         * was declared with varargs (Object...).  We shouldn't be matching if this is the case.
         */
        private boolean isNotMatchBecauseOfVarargsIssue(TypePatternList params,int modifiers) {
-               if (params.size()>0 && (modifiers & Constants.ACC_VARARGS)!=0 &&  // XXX Promote this to an isVarargs() on MethodSignature?
-                       !params.get(params.size()-1).isVarArgs) {
-                       return true;
+               if (params.size()>0 && (modifiers & Constants.ACC_VARARGS)!=0) {
+                       // we have at least one parameter in the pattern list, and the method has a varargs signature
+                       TypePattern lastPattern = params.get(params.size()-1);
+                       if (lastPattern.isArray() && !lastPattern.isVarArgs) return true;
                }
-               return false;
+           return false;
        }
        
        public AnnotationTypePattern getAnnotationPattern() {
index 9763cf9e7e83654fddaafb762ef192bcff6e2ef6..dd33ef30ac0fcc778607bf30e478e7b796131a3e 100644 (file)
@@ -64,6 +64,10 @@ public abstract class TypePattern extends PatternNode {
                return annotationPattern == AnnotationTypePattern.ANY;
        }
        
+       public boolean isArray() {
+               return false;
+       }
+       
        protected TypePattern(boolean includeSubtypes) {
                this(includeSubtypes,false);
        }
index 0dff4aaad61570bdfddde11442c81331071c4964..859391bdf698ff72364c8f59a8a49b8c2bb03e81 100644 (file)
@@ -140,6 +140,10 @@ public class WildTypePattern extends TypePattern {
                return dim;
        }
        
+       public boolean isArray() {
+               return dim > 1;
+       }
+       
     /**
         * @param targetTypeName
         * @return