From: aclement Date: Mon, 23 Jan 2006 14:25:06 +0000 (+0000) Subject: test and fix for 124808 X-Git-Tag: POST_MEMORY_CHANGES~160 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=01a8b2eb36e1a34c80697c2034f9657b74dc281a;p=aspectj.git test and fix for 124808 --- diff --git a/tests/bugs151/pr124808/Test.java b/tests/bugs151/pr124808/Test.java new file mode 100644 index 000000000..e0aebc012 --- /dev/null +++ b/tests/bugs151/pr124808/Test.java @@ -0,0 +1,15 @@ +import java.util.*; + +public class Test { + Set ints = new HashSet(); + + public Set foo() { + return ints; + } + + + public static void main(String[] args) { + Test t2 = new Test(); + Set ints2 = t2.foo(); + } +} diff --git a/tests/bugs151/pr124808/TestAspect.java b/tests/bugs151/pr124808/TestAspect.java new file mode 100644 index 000000000..446f444de --- /dev/null +++ b/tests/bugs151/pr124808/TestAspect.java @@ -0,0 +1,10 @@ +import java.util.*; + +public privileged aspect TestAspect { + + pointcut gettingMemberCollection() : get(Set *); + + after() : gettingMemberCollection() { + System.err.println("GO Aspects! "+thisJoinPoint); + } +} diff --git a/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java b/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java index 396f2ed85..8b6e385d5 100644 --- a/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java @@ -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() { diff --git a/tests/src/org/aspectj/systemtest/ajc151/ajc151.xml b/tests/src/org/aspectj/systemtest/ajc151/ajc151.xml index 5c578a1d6..ccb251c10 100644 --- a/tests/src/org/aspectj/systemtest/ajc151/ajc151.xml +++ b/tests/src/org/aspectj/systemtest/ajc151/ajc151.xml @@ -44,5 +44,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java index ec6850a0e..d3ae46d98 100644 --- a/weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java @@ -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) { diff --git a/weaver/src/org/aspectj/weaver/patterns/TypePattern.java b/weaver/src/org/aspectj/weaver/patterns/TypePattern.java index daaa83421..3098f05de 100644 --- a/weaver/src/org/aspectj/weaver/patterns/TypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/TypePattern.java @@ -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());