From 6a044f3fc948d2783bd02956bdcfeba530e20ad9 Mon Sep 17 00:00:00 2001 From: aclement Date: Thu, 21 Aug 2008 05:06:27 +0000 Subject: [PATCH] 222648: when setting off to resolve the superclass, set the type variable lookup scope to be the type for which we are exploring the type hierarchy --- .../src/org/aspectj/weaver/ReferenceType.java | 8 +++- .../src/org/aspectj/weaver/ResolvedType.java | 39 +++++++++++-------- weaver/src/org/aspectj/weaver/World.java | 2 +- .../aspectj/weaver/bcel/BcelObjectType.java | 5 ++- 4 files changed, 34 insertions(+), 20 deletions(-) diff --git a/weaver/src/org/aspectj/weaver/ReferenceType.java b/weaver/src/org/aspectj/weaver/ReferenceType.java index 644c4528a..0985966fd 100644 --- a/weaver/src/org/aspectj/weaver/ReferenceType.java +++ b/weaver/src/org/aspectj/weaver/ReferenceType.java @@ -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()); } diff --git a/weaver/src/org/aspectj/weaver/ResolvedType.java b/weaver/src/org/aspectj/weaver/ResolvedType.java index 8bf8b117d..81b6b8d49 100644 --- a/weaver/src/org/aspectj/weaver/ResolvedType.java +++ b/weaver/src/org/aspectj/weaver/ResolvedType.java @@ -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() { diff --git a/weaver/src/org/aspectj/weaver/World.java b/weaver/src/org/aspectj/weaver/World.java index f0aec8ad6..04cfa5286 100644 --- a/weaver/src/org/aspectj/weaver/World.java +++ b/weaver/src/org/aspectj/weaver/World.java @@ -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; diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java b/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java index 16507a8c1..e5a7ef6ed 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java @@ -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() { -- 2.39.5