From cc0db993ec79c94e4d04a6cf785517eaaa80711f Mon Sep 17 00:00:00 2001 From: aclement Date: Mon, 4 Jul 2005 15:00:52 +0000 Subject: [PATCH] generics: First simple change to ensure the pattern I results in an ExactTypePattern that remembers the parameterization. --- .../weaver/patterns/WildTypePattern.java | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java index 31df81d09..edd2213e3 100644 --- a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java @@ -454,7 +454,19 @@ public class WildTypePattern extends TypePattern { } } + // Only if the type is exact *and* the type parameters are exact should we create an + // ExactTypePattern for this WildTypePattern + + // resolve any type parameters + if (typeParameters!=null && typeParameters.size()>0) { + typeParameters.resolveBindings(scope,bindings,allowBinding,requireExactType); + } + String cleanName = maybeGetCleanName(); + String[] typeParamCleanNames = typeParameters.maybeGetCleanNames(); + + // TODO asc generics - do we need to duplicate all this logic that gets done on cleanName + // for the typeParamCleanNames? String originalName = cleanName; // if we discover it is 'MISSING' when searching via the scope, this next local var will // tell us if it is really missing or if it does exist in the world and we just can't @@ -489,8 +501,21 @@ public class WildTypePattern extends TypePattern { scope.getWorld().getLint().invalidAbsoluteTypeName.signal(originalName, getSourceLocation()); } } else { - if (dim != 0) type = TypeX.makeArray(type, dim); - TypePattern ret = new ExactTypePattern(type, includeSubtypes,isVarArgs); + TypePattern ret = null; + if (typeParameters.size()>0) { + if (typeParameters.areAllExact()) { + TypeX tx = TypeX.forParameterizedTypeNames(cleanName,typeParamCleanNames); + type = scope.getWorld().resolve(tx,true); + if (dim != 0) type = TypeX.makeArray(type, dim); + ret = new ExactTypePattern(type,includeSubtypes,isVarArgs); + } else { + // TODO generics not written yet - when the type parameters are not exact + throw new RuntimeException("Type parameters are not exact"); + } + } else { + if (dim != 0) type = TypeX.makeArray(type, dim); + ret = new ExactTypePattern(type,includeSubtypes,isVarArgs); + } ret.setAnnotationTypePattern(annotationPattern); ret.copyLocationFrom(this); return ret; @@ -611,6 +636,11 @@ public class WildTypePattern extends TypePattern { buf.append(name.toString()); } } + if (typeParameters!=null && typeParameters.size()!=0) { + buf.append("<"); + buf.append(typeParameters.toString()); + buf.append(">"); + } if (includeSubtypes) buf.append('+'); if (isVarArgs) buf.append("..."); if (annotationPattern != AnnotationTypePattern.ANY) { -- 2.39.5