public ResolvedTypeMunger parameterizedFor(ResolvedType target) {
ResolvedType genericType = target;
if (target.isRawType() || target.isParameterizedType()) genericType = genericType.getGenericType();
- ResolvedMember parameterizedSignature = getSignature().parameterizedWith(target.getTypeParameters(),genericType,target.isParameterizedType());
+ ResolvedMember parameterizedSignature = getSignature().parameterizedWith(target.getTypeParameters(),genericType,target.isParameterizedType(),typeVariableAliases);
return new NewMethodTypeMunger(parameterizedSignature,getSuperMethodsCalled(),typeVariableAliases);
}
import java.io.DataOutputStream;
import java.io.IOException;
+import java.util.List;
import org.aspectj.bridge.ISourceLocation;
UnresolvedType[] typeParameters, ResolvedType newDeclaringType,
boolean isParameterized);
+ // this variant allows for aliases for type variables (i.e. allowing them to have another name)
+ // this is used for processing ITDs that share type variables with their target generic type
+ public ResolvedMemberImpl parameterizedWith(
+ UnresolvedType[] typeParameters, ResolvedType newDeclaringType,
+ boolean isParameterized,List aliases);
+
public void setTypeVariables(TypeVariable[] types);
public TypeVariable[] getTypeVariables();
}
declaringType = declaringType.resolve(world);
if (declaringType.isRawType()) declaringType = ((ReferenceType)declaringType).getGenericType();
+
if (parameterTypes!=null && parameterTypes.length>0) {
for (int i = 0; i < parameterTypes.length; i++) {
- UnresolvedType array_element = parameterTypes[i];
- // parameterTypes[i] = parameterTypes[i].resolve(world);
parameterTypes[i] = parameterTypes[i].resolve(world);
}
}
-
+
returnType = returnType.resolve(world);
+
} finally {
world.setTypeVariableLookupScope(null);
}
return getParameterTypes();
}
+
+ public ResolvedMemberImpl parameterizedWith(UnresolvedType[] typeParameters,ResolvedType newDeclaringType, boolean isParameterized) {
+ return parameterizedWith(typeParameters,newDeclaringType,isParameterized,null);
+ }
+
+
/**
* Return a resolvedmember in which all the type variables in the signature
* have been replaced with the given bindings.
* List<String> (for example) - if (!isParameterized) then List<T> will turn
* into List.
*/
- public ResolvedMemberImpl parameterizedWith(UnresolvedType[] typeParameters,ResolvedType newDeclaringType, boolean isParameterized) {
+ public ResolvedMemberImpl parameterizedWith(UnresolvedType[] typeParameters,ResolvedType newDeclaringType, boolean isParameterized,List aliases) {
if (//isParameterized && <-- might need this bit...
!getDeclaringType().isGenericType()) {
throw new IllegalStateException("Can't ask to parameterize a member of a non-generic type");
throw new IllegalStateException("Wrong number of type parameters supplied");
}
Map typeMap = new HashMap();
+ boolean typeParametersSupplied = typeParameters!=null && typeParameters.length>0;
if (typeVariables!=null) {
// If no 'replacements' were supplied in the typeParameters array then collapse
// type variables to their first bound.
- boolean typeParametersSupplied = typeParameters!=null && typeParameters.length>0;
for (int i = 0; i < typeVariables.length; i++) {
UnresolvedType ut = (!typeParametersSupplied?typeVariables[i].getFirstBound():typeParameters[i]);
typeMap.put(typeVariables[i].getName(),ut);
}
}
+ // For ITDs on generic types that use type variables from the target type, the aliases
+ // record the alternative names used throughout the ITD expression that must map to
+ // the same value as the type variables real name.
+ if (aliases!=null) {
+ int posn = 0;
+ for (Iterator iter = aliases.iterator(); iter.hasNext();) {
+ String typeVariableAlias = (String) iter.next();
+ typeMap.put(typeVariableAlias,(!typeParametersSupplied?typeVariables[posn].getFirstBound():typeParameters[posn]));
+ posn++;
+ }
+ }
UnresolvedType parameterizedReturnType = parameterize(getGenericReturnType(),typeMap,isParameterized);
UnresolvedType[] parameterizedParameterTypes = new UnresolvedType[getGenericParameterTypes().length];