From 8a240a42a10248f9e0922a91e17c57b250685e17 Mon Sep 17 00:00:00 2001 From: aclement Date: Mon, 11 Jul 2005 10:48:28 +0000 Subject: [PATCH] generics: now promotes simple types to raw types if we discover they are generic during resolution. --- weaver/src/org/aspectj/weaver/World.java | 25 ++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/weaver/src/org/aspectj/weaver/World.java b/weaver/src/org/aspectj/weaver/World.java index cf6dbe13f..2bfda6c54 100644 --- a/weaver/src/org/aspectj/weaver/World.java +++ b/weaver/src/org/aspectj/weaver/World.java @@ -142,7 +142,7 @@ public abstract class World implements Dump.INode { // Does the raw type know its generic form? (It will if we created the // raw type from a source type, it won't if its been created just through // being referenced, e.g. java.util.List - ResolvedTypeX generic = ((ReferenceType)ret).genericType; + ResolvedTypeX generic = ret.getGenericType(); if (generic != null) { generic.world = this; return generic; } // Fault in the generic that underpins the raw type ;) @@ -209,11 +209,24 @@ public abstract class World implements Dump.INode { return genericType; } else { String signature = ty.getRawTypeSignature(); - ReferenceType name = new ReferenceType(signature/*was ty.getSignature()*/, this); + ReferenceType name = new ReferenceType(signature/*was ty.getSignature()*/, this); ReferenceTypeDelegate concreteName = resolveObjectType(name); if (concreteName == null) return ResolvedTypeX.MISSING; - name.setDelegate(concreteName); - return name; + if (concreteName.isGeneric()) { + // During resolution we have discovered that the underlying type is in fact generic, + // so the thing we thought was a simple type is in fact a raw type. + + ReferenceType genericRefType = new ReferenceType( + TypeX.forGenericTypeSignature(signature,concreteName.getDeclaredGenericSignature()),this); + // name = ReferenceType.fromTypeX(TypeX.forRawTypeNames(ty.getName()),this); + name.setDelegate(concreteName); + genericRefType.setDelegate(concreteName); + name.setGenericType(genericRefType); + return name; + } else { + name.setDelegate(concreteName); + return name; + } } } @@ -533,7 +546,7 @@ public abstract class World implements Dump.INode { String signature = ty.getSignature(); ReferenceType ret = (ReferenceType)typeMap.get(signature); if (ret == null) { - ret = new ReferenceType(signature, this); + ret = ReferenceType.fromTypeX(ty, this); typeMap.put(signature, ret); } return ret; @@ -582,7 +595,7 @@ public abstract class World implements Dump.INode { private Map tMap = new HashMap(); private Map expendableMap = new WeakHashMap(); - public ResolvedTypeX put(String key, ResolvedTypeX type) { + public ResolvedTypeX put(String key, ResolvedTypeX type) { if (isExpendable(type)) { return (ResolvedTypeX) expendableMap.put(key,type); } else { -- 2.39.5