summaryrefslogtreecommitdiffstats
path: root/weaver
diff options
context:
space:
mode:
authoracolyer <acolyer>2005-08-09 13:04:18 +0000
committeracolyer <acolyer>2005-08-09 13:04:18 +0000
commit4a9396dc60a8ffd6e1864b1c0e3122f13ebbd529 (patch)
treebf5cb66dc6597977a043254684353735b1fc1f6b /weaver
parent9dbbc1daa92358bfd63900696c4043f4912b8d56 (diff)
downloadaspectj-4a9396dc60a8ffd6e1864b1c0e3122f13ebbd529.tar.gz
aspectj-4a9396dc60a8ffd6e1864b1c0e3122f13ebbd529.zip
now handles resolving of generic wildcards in type patterns
Diffstat (limited to 'weaver')
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java41
1 files changed, 32 insertions, 9 deletions
diff --git a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java
index 01983f3f7..e2f99c0fa 100644
--- a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java
@@ -26,6 +26,7 @@ import org.aspectj.util.FuzzyBoolean;
import org.aspectj.weaver.AjAttribute;
import org.aspectj.weaver.BCException;
import org.aspectj.weaver.BoundedReferenceType;
+import org.aspectj.weaver.IHasPosition;
import org.aspectj.weaver.ISourceContext;
import org.aspectj.weaver.ReferenceType;
import org.aspectj.weaver.ResolvedType;
@@ -36,6 +37,7 @@ import org.aspectj.weaver.UnresolvedType;
import org.aspectj.weaver.UnresolvedTypeVariableReferenceType;
import org.aspectj.weaver.VersionedDataInputStream;
import org.aspectj.weaver.WeaverMessages;
+import org.aspectj.weaver.World;
/**
* The PatternParser always creates WildTypePatterns for type patterns in pointcut
@@ -625,13 +627,11 @@ public class WildTypePattern extends TypePattern {
//System.out.println("resolve: " + cleanName);
//??? this loop has too many inefficiencies to count
- resolvedTypeInTheWorld = scope.getWorld().resolve(UnresolvedType.forName(fullyQualifiedName),true);
- while ((type = scope.lookupType(fullyQualifiedName, this)) == ResolvedType.MISSING) {
- int lastDot = fullyQualifiedName.lastIndexOf('.');
- if (lastDot == -1) break;
- fullyQualifiedName = fullyQualifiedName.substring(0, lastDot) + '$' + fullyQualifiedName.substring(lastDot+1);
- if (resolvedTypeInTheWorld == ResolvedType.MISSING)
- resolvedTypeInTheWorld = scope.getWorld().resolve(UnresolvedType.forName(fullyQualifiedName),true);
+ resolvedTypeInTheWorld = lookupTypeInWorld(scope.getWorld(), fullyQualifiedName);
+ if (resolvedTypeInTheWorld.isGenericWildcard()) {
+ type = resolvedTypeInTheWorld;
+ } else {
+ type = lookupTypeInScope(scope, fullyQualifiedName, this);
}
if (type == ResolvedType.MISSING) {
return resolveBindingsForMissingType(resolvedTypeInTheWorld, originalName, scope, bindings, allowBinding, requireExactType);
@@ -640,6 +640,29 @@ public class WildTypePattern extends TypePattern {
}
}
+
+
+ private UnresolvedType lookupTypeInScope(IScope scope, String typeName, IHasPosition location) {
+ UnresolvedType type = null;
+ while ((type = scope.lookupType(typeName, location)) == ResolvedType.MISSING) {
+ int lastDot = typeName.lastIndexOf('.');
+ if (lastDot == -1) break;
+ typeName = typeName.substring(0, lastDot) + '$' + typeName.substring(lastDot+1);
+ }
+ return type;
+ }
+
+ private ResolvedType lookupTypeInWorld(World world, String typeName) {
+ ResolvedType ret = world.resolve(UnresolvedType.forName(typeName),true);
+ while (ret == ResolvedType.MISSING) {
+ int lastDot = typeName.lastIndexOf('.');
+ if (lastDot == -1) break;
+ typeName = typeName.substring(0, lastDot) + '$' + typeName.substring(lastDot+1);
+ ret = world.resolve(UnresolvedType.forName(typeName),true);
+ }
+ return ret;
+ }
+
private TypePattern resolveBindingsForExactType(IScope scope, UnresolvedType aType, String fullyQualifiedName,boolean requireExactType) {
TypePattern ret = null;
if (aType.isTypeVariableReference()) {
@@ -698,7 +721,7 @@ public class WildTypePattern extends TypePattern {
if (!verifyTypeParameters(aType.resolve(scope.getWorld()),scope,requireExactType)) return TypePattern.NO; // messages already isued
// Only if the type is exact *and* the type parameters are exact should we create an
// ExactTypePattern for this WildTypePattern
- if (typeParameters.areAllExact()) {
+ if (typeParameters.areAllExactWithNoSubtypesAllowed()) {
TypePattern[] typePats = typeParameters.getTypePatterns();
UnresolvedType[] typeParameterTypes = new UnresolvedType[typePats.length];
for (int i = 0; i < typeParameterTypes.length; i++) {
@@ -843,7 +866,7 @@ public class WildTypePattern extends TypePattern {
// now check that each typeParameter pattern, if exact, matches the bounds
// of the type variable.
- if (typeParameters.areAllExact()) {
+ if (typeParameters.areAllExactWithNoSubtypesAllowed()) {
for (int i = 0; i < tvs.length; i++) {
UnresolvedType ut = typeParamPatterns[i].getExactType();
if (!tvs[i].canBeBoundTo(ut.resolve(scope.getWorld()))) {