]> source.dussan.org Git - aspectj.git/commitdiff
222648: when setting off to resolve the superclass, set the type variable lookup...
authoraclement <aclement>
Thu, 21 Aug 2008 05:06:27 +0000 (05:06 +0000)
committeraclement <aclement>
Thu, 21 Aug 2008 05:06:27 +0000 (05:06 +0000)
weaver/src/org/aspectj/weaver/ReferenceType.java
weaver/src/org/aspectj/weaver/ResolvedType.java
weaver/src/org/aspectj/weaver/World.java
weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java

index 644c4528aa00f9fe7d101f84122da16d1f89ac0c..0985966fd109681be4042f61b72a19c709c4091b 100644 (file)
@@ -642,7 +642,13 @@ public class ReferenceType extends ResolvedType {
        }
 
        public ResolvedType getSuperclass() {
-               ResolvedType ret = delegate.getSuperclass();
+               ResolvedType ret = null;
+       try {
+                       world.setTypeVariableLookupScope(this);
+                       ret = delegate.getSuperclass();
+       } finally {
+               world.setTypeVariableLookupScope(null);
+       }
                if (this.isParameterizedType() && ret.isParameterizedType()) {
                        ret = ret.parameterize(getMemberParameterizationMap()).resolve(getWorld());
                }
index 8bf8b117d25547ec9522c174a16c74e9667e7d2c..81b6b8d499654aea292358bed10723b7315b039c 100644 (file)
@@ -2120,34 +2120,41 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
                throw new RuntimeException("Cannot ask this type "+this+" for a generic sig attribute");
        }
        
-       private FuzzyBoolean parameterizedWithAMemberTypeVariable = FuzzyBoolean.MAYBE;
+       private FuzzyBoolean parameterizedWithTypeVariable = FuzzyBoolean.MAYBE;
        
        /**
         * return true if the parameterization of this type includes a member type variable.  Member
         * type variables occur in generic methods/ctors.
         */
-       public boolean isParameterizedWithAMemberTypeVariable() {
+       public boolean isParameterizedWithTypeVariable() {
                // MAYBE means we haven't worked it out yet...
-               if (parameterizedWithAMemberTypeVariable==FuzzyBoolean.MAYBE) {
+               if (parameterizedWithTypeVariable==FuzzyBoolean.MAYBE) {
                        
                        // if there are no type parameters then we cant be...
                        if (typeParameters==null || typeParameters.length==0) {
-                               parameterizedWithAMemberTypeVariable = FuzzyBoolean.NO;
+                               parameterizedWithTypeVariable = FuzzyBoolean.NO;
                                return false;
                        }
                        
                        for (int i = 0; i < typeParameters.length; i++) {
                                ResolvedType aType = (ResolvedType)typeParameters[i];
-                               if (aType.isTypeVariableReference()  && 
-                               // assume the worst - if its definetly not a type declared one, it could be anything
-                                               ((TypeVariableReference)aType).getTypeVariable().getDeclaringElementKind()!=TypeVariable.TYPE) {
-                                       parameterizedWithAMemberTypeVariable = FuzzyBoolean.YES;
+                               if (aType.isTypeVariableReference()  
+                                       // Changed according to the problems covered in bug 222648
+                                       // Don't care what kind of type variable - the fact that there is one
+                                       // at all means we can't risk caching it against we get confused later
+                                       // by another variation of the parameterization that just happens to
+                                       // use the same type variable name
+                                       
+                                       // assume the worst - if its definetly not a type declared one, it could be anything
+                                       // && ((TypeVariableReference)aType).getTypeVariable().getDeclaringElementKind()!=TypeVariable.TYPE
+                                       ) {
+                                       parameterizedWithTypeVariable = FuzzyBoolean.YES;
                                        return true;
                                }
                                if (aType.isParameterizedType()) {
-                                       boolean b = aType.isParameterizedWithAMemberTypeVariable();
+                                       boolean b = aType.isParameterizedWithTypeVariable();
                                        if (b) {
-                                               parameterizedWithAMemberTypeVariable = FuzzyBoolean.YES;
+                                               parameterizedWithTypeVariable = FuzzyBoolean.YES;
                                                return true;
                                        }
                                }
@@ -2157,12 +2164,12 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
                                                boolean b = false;
                                                UnresolvedType upperBound = boundedRT.getUpperBound();
                                                if (upperBound.isParameterizedType()) {
-                                                       b = ((ResolvedType)upperBound).isParameterizedWithAMemberTypeVariable();
+                                                       b = ((ResolvedType)upperBound).isParameterizedWithTypeVariable();
                                                } else if (upperBound.isTypeVariableReference() && ((TypeVariableReference)upperBound).getTypeVariable().getDeclaringElementKind()==TypeVariable.METHOD) {
                                                        b = true;
                                                }
                                                if (b) {
-                                                       parameterizedWithAMemberTypeVariable = FuzzyBoolean.YES;
+                                                       parameterizedWithTypeVariable = FuzzyBoolean.YES;
                                                        return true;
                                                }
                                                // FIXME asc need to check additional interface bounds
@@ -2171,20 +2178,20 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
                                                boolean b = false;
                                                UnresolvedType lowerBound = boundedRT.getLowerBound();
                                                if (lowerBound.isParameterizedType()) {
-                                                       b = ((ResolvedType)lowerBound).isParameterizedWithAMemberTypeVariable();
+                                                       b = ((ResolvedType)lowerBound).isParameterizedWithTypeVariable();
                                                } else if (lowerBound.isTypeVariableReference() && ((TypeVariableReference)lowerBound).getTypeVariable().getDeclaringElementKind()==TypeVariable.METHOD) {
                                                        b = true;
                                                }
                                                if (b) {
-                                                       parameterizedWithAMemberTypeVariable = FuzzyBoolean.YES;
+                                                       parameterizedWithTypeVariable = FuzzyBoolean.YES;
                                                        return true;
                                                }
                                        }
                                }
                        }
-                       parameterizedWithAMemberTypeVariable=FuzzyBoolean.NO;
+                       parameterizedWithTypeVariable=FuzzyBoolean.NO;
                }
-               return parameterizedWithAMemberTypeVariable.alwaysTrue();
+               return parameterizedWithTypeVariable.alwaysTrue();
        }
 
        protected boolean ajMembersNeedParameterization() {
index f0aec8ad60ca8678d0f313d8433c8271c048ab3d..04cfa52864bda781335c69eb8f3e3f71acff22f3 100644 (file)
@@ -905,7 +905,7 @@ public abstract class World implements Dump.INode {
                 * method/ctor as opposed to those you see declared on a generic type.
                 */
                public ResolvedType put(String key, ResolvedType type) { 
-                       if (type.isParameterizedType() && type.isParameterizedWithAMemberTypeVariable()) {
+                       if (type.isParameterizedType() && type.isParameterizedWithTypeVariable()) {
                                if (debug) 
                                        System.err.println("Not putting a parameterized type that utilises member declared type variables into the typemap: key="+key+" type="+type);
                                return type;
index 16507a8c18eac2d32908c821c56a88c15ec1759e..e5a7ef6ed67360102fc5e89ff0995bbe98976f8c 100644 (file)
@@ -200,8 +200,9 @@ public class BcelObjectType extends AbstractReferenceTypeDelegate {
                if (superclassName==null) superclassName = javaClass.getSuperclassName();
                superclassSignature = getResolvedTypeX().getWorld().resolve(UnresolvedType.forName(superclassName)).getSignature();
        }
-        ResolvedType res =     getResolvedTypeX().getWorld().resolve(UnresolvedType.forSignature(superclassSignature));
-       return res;
+       World world = getResolvedTypeX().getWorld();
+           ResolvedType res =  world.resolve(UnresolvedType.forSignature(superclassSignature));
+           return res;
     }
         
     public World getWorld() {