]> source.dussan.org Git - aspectj.git/commitdiff
test and fix for 124808
authoraclement <aclement>
Mon, 23 Jan 2006 14:25:06 +0000 (14:25 +0000)
committeraclement <aclement>
Mon, 23 Jan 2006 14:25:06 +0000 (14:25 +0000)
tests/bugs151/pr124808/Test.java [new file with mode: 0644]
tests/bugs151/pr124808/TestAspect.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java
tests/src/org/aspectj/systemtest/ajc151/ajc151.xml
weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java
weaver/src/org/aspectj/weaver/patterns/TypePattern.java

diff --git a/tests/bugs151/pr124808/Test.java b/tests/bugs151/pr124808/Test.java
new file mode 100644 (file)
index 0000000..e0aebc0
--- /dev/null
@@ -0,0 +1,15 @@
+import java.util.*;
+
+public class Test<T extends Integer> {
+       Set<T> ints = new HashSet<T>();
+
+       public Set<T> foo() {
+               return ints;
+       }
+
+
+       public static void main(String[] args) {
+               Test<Integer> t2 = new Test<Integer>();
+               Set<Integer> ints2 = t2.foo();
+       }
+}
diff --git a/tests/bugs151/pr124808/TestAspect.java b/tests/bugs151/pr124808/TestAspect.java
new file mode 100644 (file)
index 0000000..446f444
--- /dev/null
@@ -0,0 +1,10 @@
+import java.util.*;
+
+public privileged aspect TestAspect {
+
+   pointcut gettingMemberCollection() : get(Set<Number+> *);
+
+   after() : gettingMemberCollection() {
+     System.err.println("GO Aspects!  "+thisJoinPoint);
+   }
+}
index 396f2ed855d94b1bf80acdf1c0e146134d31bb21..8b6e385d5232efe4928398cd1a38868fd8afd966 100644 (file)
@@ -24,6 +24,7 @@ public class Ajc151Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
   public void testHasMemberPackageProblem_pr124105() { runTest("hasMember problems with packages");}
   public void testDifferentNumbersofTVars_pr124803() { runTest("generics and different numbers of type variables");}
   public void testDifferentNumbersofTVars_pr124803_2() { runTest("generics and different numbers of type variables - classes");}
+  public void testParameterizedCollectionFieldMatching_pr124808() { runTest("parameterized collection fields matched via pointcut");}
   
   /////////////////////////////////////////
   public static Test suite() {
index 5c578a1d63fa98adfec4afecde98c4b16e82685b..ccb251c10100b84c421ab59297da692724a63b97 100644 (file)
           </stderr>
         </run>
     </ajc-test>
+    
+    <ajc-test dir="bugs151/pr124808" title="parameterized collection fields matched via pointcut">
+        <compile files="Test.java,TestAspect.java" options="-1.5"/>
+        <run class="Test">
+          <stderr>
+             <line text="GO Aspects!  get(Set Test.ints)"/>
+          </stderr>
+        </run>
+    </ajc-test>
 
 </suite>
\ No newline at end of file
index ec6850a0e7aea4f2d5ec8453083a46d9eeccb1b6..d3ae46d982b6ad5dbe8b02e96c815806f887038f 100644 (file)
@@ -110,7 +110,9 @@ public class ExactTypePattern extends TypePattern {
        }
        
        private boolean matchesTypeVariable(TypeVariableReferenceType matchType) {
-               return false;
+           // was this method previously coded to return false *on purpose* ??  pr124808
+               return this.type.equals(((TypeVariableReference)matchType).getTypeVariable().getFirstBound());
+               //return false;
        }
        
        protected boolean matchesExactly(ResolvedType matchType, ResolvedType annotatedType) {
index daaa83421ef4ca9c555ed77768c954354a8bca2c..3098f05de9f1a259889f94f91418a484b2e6b28c 100644 (file)
@@ -25,6 +25,7 @@ import org.aspectj.weaver.BCException;
 import org.aspectj.weaver.ISourceContext;
 import org.aspectj.weaver.IntMap;
 import org.aspectj.weaver.ResolvedType;
+import org.aspectj.weaver.TypeVariableReference;
 import org.aspectj.weaver.UnresolvedType;
 import org.aspectj.weaver.VersionedDataInputStream;
 import org.aspectj.weaver.WeaverMessages;
@@ -152,9 +153,16 @@ public abstract class TypePattern extends PatternNode {
                        //System.out.println("    true");
                        return true;
                }
+               // pr124808
+               Iterator typesIterator = null;
+               if (type.isTypeVariableReference()) {
+                       typesIterator = ((TypeVariableReference)type).getTypeVariable().getFirstBound().resolve(type.getWorld()).getDirectSupertypes();
+               } else {
+                       typesIterator = type.getDirectSupertypes();
+               }
                
                // FuzzyBoolean ret = FuzzyBoolean.NO; // ??? -eh
-               for (Iterator i = type.getDirectSupertypes(); i.hasNext(); ) {
+               for (Iterator i = typesIterator; i.hasNext(); ) {
                        ResolvedType superType = (ResolvedType)i.next();
                        // TODO asc generics, temporary whilst matching isnt aware..
                        //if (superType.isParameterizedType()) superType = superType.getRawType().resolve(superType.getWorld());