// System.err.println("start: " + searchStart);
// ResolvedType[] parameterTypes = searchStart.getWorld().resolve(pointcutDec.getParameterTypes());
TypePatternList arguments = this.arguments.resolveReferences(bindings);
IntMap newBindings = new IntMap();
for (int i = 0, len = arguments.size(); i < len; i++) {
TypePattern p = arguments.get(i);
if (p == TypePattern.NO) {
continue;
}
// we are allowed to bind to pointcuts which use subtypes as this is type safe
// this will be checked in ReferencePointcut.resolveBindings(). Can't check it here
// as we don't know about any new parents added via decp.
if (p instanceof BindingTypePattern) {
newBindings.put(i, ((BindingTypePattern) p).getFormalIndex());
}
}
if (searchStart.isParameterizedType()) {
// build a type map mapping type variable names in the generic type to
// the type parameters presented
typeVariableMap = new HashMap();
ResolvedType underlyingGenericType = searchStart.getGenericType();
TypeVariable[] tVars = underlyingGenericType.getTypeVariables();
ResolvedType[] typeParams = searchStart.getResolvedTypeParameters();
for (int i = 0; i < tVars.length; i++) {
typeVariableMap.put(tVars[i].getName(), typeParams[i]);
}
}
newBindings.copyContext(bindings);
newBindings.pushEnclosingDefinition(pointcutDec);
try {
Pointcut ret = pointcutDec.getPointcut();
if (typeVariableMap != null && !hasBeenParameterized) {
ret = ret.parameterizeWith(typeVariableMap, searchStart.getWorld());
ret.hasBeenParameterized = true;
}
return ret.concretize(searchStart, declaringType, newBindings);
} finally {
newBindings.popEnclosingDefinitition();
}
} finally {
concretizing = false;
}