From 4b5e76347445be5180616f5008e52328948b6cf5 Mon Sep 17 00:00:00 2001 From: aclement Date: Thu, 3 Nov 2005 10:31:03 +0000 Subject: fix for latest variant of 114343 (see comment #5): around advice on method returning type variable. --- weaver/src/org/aspectj/weaver/ReferenceType.java | 5 +++++ weaver/src/org/aspectj/weaver/ResolvedType.java | 9 ++++++--- weaver/src/org/aspectj/weaver/TypeFactory.java | 6 ++++++ weaver/src/org/aspectj/weaver/World.java | 12 ++++++++---- 4 files changed, 25 insertions(+), 7 deletions(-) (limited to 'weaver') diff --git a/weaver/src/org/aspectj/weaver/ReferenceType.java b/weaver/src/org/aspectj/weaver/ReferenceType.java index 111762cf2..f31cf2e96 100644 --- a/weaver/src/org/aspectj/weaver/ReferenceType.java +++ b/weaver/src/org/aspectj/weaver/ReferenceType.java @@ -288,6 +288,11 @@ public class ReferenceType extends ResolvedType { } } + if (isTypeVariableReference() && !other.isTypeVariableReference()) { // eg. this=T other=Ljava/lang/Object; + TypeVariable aVar = ((TypeVariableReference)this).getTypeVariable(); + return aVar.getFirstBound().resolve(world).isAssignableFrom(other); + } + if (other.isTypeVariableReference()) { TypeVariableReferenceType otherType = (TypeVariableReferenceType) other; if (this instanceof TypeVariableReference) { diff --git a/weaver/src/org/aspectj/weaver/ResolvedType.java b/weaver/src/org/aspectj/weaver/ResolvedType.java index b6683f724..464c1675c 100644 --- a/weaver/src/org/aspectj/weaver/ResolvedType.java +++ b/weaver/src/org/aspectj/weaver/ResolvedType.java @@ -744,14 +744,17 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl // ---- types public static ResolvedType makeArray(ResolvedType type, int dim) { if (dim == 0) return type; - ResolvedType array = new Array("[" + type.getSignature(),type.getWorld(),type); + ResolvedType array = new Array("[" + type.getSignature(),"["+type.getErasureSignature(),type.getWorld(),type); return makeArray(array,dim-1); } static class Array extends ResolvedType { ResolvedType componentType; - Array(String s, World world, ResolvedType componentType) { - super(s, world); + + + // Sometimes the erasure is different, eg. [TT; and [Ljava/lang/Object; + Array(String sig, String erasureSig,World world, ResolvedType componentType) { + super(sig,erasureSig, world); this.componentType = componentType; } public final ResolvedMember[] getDeclaredFields() { diff --git a/weaver/src/org/aspectj/weaver/TypeFactory.java b/weaver/src/org/aspectj/weaver/TypeFactory.java index b921d0aad..eb6350b33 100644 --- a/weaver/src/org/aspectj/weaver/TypeFactory.java +++ b/weaver/src/org/aspectj/weaver/TypeFactory.java @@ -110,6 +110,12 @@ public class TypeFactory { typeVariableName = typeVariableName.substring(0, typeVariableName.length() -1); } return new UnresolvedTypeVariableReferenceType(new TypeVariable(typeVariableName)); + } else if (signature.startsWith("[")) { + int dims = 0; + while (signature.charAt(dims)=='[') dims++; + UnresolvedType componentType = createTypeFromSignature(signature.substring(dims)); + return new UnresolvedType(signature, + signature.substring(0,dims)+componentType.getErasureSignature()); } return new UnresolvedType(signature); } diff --git a/weaver/src/org/aspectj/weaver/World.java b/weaver/src/org/aspectj/weaver/World.java index 423898524..29810f984 100644 --- a/weaver/src/org/aspectj/weaver/World.java +++ b/weaver/src/org/aspectj/weaver/World.java @@ -204,10 +204,11 @@ public abstract class World implements Dump.INode { // no existing resolved type, create one if (ty.isArray()) { - ret = new ResolvedType.Array(signature, + ResolvedType componentType = resolve(ty.getComponentType(),allowMissing); + String brackets = signature.substring(0,signature.lastIndexOf("[")+1); + ret = new ResolvedType.Array(signature, brackets+componentType.getErasureSignature(), this, - resolve(ty.getComponentType(), - allowMissing)); + componentType); } else { ret = resolveToReferenceType(ty); if (!allowMissing && ret == ResolvedType.MISSING) { @@ -264,7 +265,8 @@ public abstract class World implements Dump.INode { return resolve(UnresolvedType.forName(name),allowMissing); } - + private ResolvedType currentlyResolvingBaseType; + /** * Resolve to a ReferenceType - simple, raw, parameterized, or generic. * Raw, parameterized, and generic versions of a type share a delegate. @@ -273,8 +275,10 @@ public abstract class World implements Dump.INode { if (ty.isParameterizedType()) { // ======= parameterized types ================ ReferenceType genericType = (ReferenceType)resolveGenericTypeFor(ty,false); + currentlyResolvingBaseType = genericType; ReferenceType parameterizedType = TypeFactory.createParameterizedType(genericType, ty.typeParameters, this); + currentlyResolvingBaseType = null; return parameterizedType; } else if (ty.isGenericType()) { -- cgit v1.2.3