From 782ade25e6d68caf361f51a1e040edbd6855842b Mon Sep 17 00:00:00 2001 From: aclement Date: Tue, 3 Oct 2006 15:00:34 +0000 Subject: test and fix for 156904: missing type warning then it matches anyway --- .../aspectj/weaver/patterns/WildTypePattern.java | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'weaver') diff --git a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java index 8eb3cdf2c..48f429274 100644 --- a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java @@ -687,7 +687,8 @@ public class WildTypePattern extends TypePattern { //System.out.println("resolve: " + cleanName); //??? this loop has too many inefficiencies to count - resolvedTypeInTheWorld = lookupTypeInWorld(scope.getWorld(), fullyQualifiedName); + resolvedTypeInTheWorld = lookupTypeInWorldIncludingPrefixes(scope.getWorld(), fullyQualifiedName, scope.getImportedPrefixes()); + if (resolvedTypeInTheWorld.isGenericWildcard()) { type = resolvedTypeInTheWorld; } else { @@ -712,6 +713,27 @@ public class WildTypePattern extends TypePattern { return type; } + /** + * Searches the world for the ResolvedType with the given typeName. If one + * isn't found then for each of the supplied prefixes, it prepends the typeName + * with the prefix and searches the world for the ResolvedType with this new name. + * If one still isn't found then a MissingResolvedTypeWithKnownSignature is + * returned with the originally requested typeName (this ensures the typeName + * makes sense). + */ + private ResolvedType lookupTypeInWorldIncludingPrefixes(World world, String typeName, String[] prefixes) { + ResolvedType ret = lookupTypeInWorld(world, typeName); + if (!ret.isMissing()) return ret; + ResolvedType retWithPrefix = ret; + int counter = 0; + while (retWithPrefix.isMissing() && (counter < prefixes.length)) { + retWithPrefix = lookupTypeInWorld(world,prefixes[counter] + typeName); + counter++; + } + if (!retWithPrefix.isMissing()) return retWithPrefix; + return ret; + } + private ResolvedType lookupTypeInWorld(World world, String typeName) { ResolvedType ret = world.resolve(UnresolvedType.forName(typeName),true); while (ret.isMissing()) { -- cgit v1.2.3