// Collapse the parameterized reference to its generic type
if (onType instanceof ParameterizedSingleTypeReference) {
ParameterizedSingleTypeReference pref = (ParameterizedSingleTypeReference) onType;
long pos = (((long)pref.sourceStart) << 32) | pref.sourceEnd;
onType = new SingleTypeReference(pref.token,pos);
} else {
ParameterizedQualifiedTypeReference pref = (ParameterizedQualifiedTypeReference) onType;
long pos = (((long)pref.sourceStart) << 32) | pref.sourceEnd;
onType = new QualifiedTypeReference(pref.tokens,new long[]{pos});
}
onTypeBinding = (ReferenceBinding)onType.getTypeBindingPublic(classScope);
if (!onTypeBinding.isValidBinding()) {
classScope.problemReporter().invalidType(onType, onTypeBinding);
ignoreFurtherInvestigation = true;
}
if (onTypeBinding.isRawType()) {
onTypeBinding = ((RawTypeBinding)onTypeBinding).type;
}
int aliasCount = (typeVariableAliases==null?0:typeVariableAliases.size());
// Cannot specify a parameterized target type for the ITD if the target
// type is not generic.
if (aliasCount!=0 && !onTypeBinding.isGenericType()) {
scope.problemReporter().signalError(sourceStart,sourceEnd,
"Type parameters can not be specified in the ITD target type - the target type "+onTypeBinding.debugName()+" is not generic.");
ignoreFurtherInvestigation = true;
return;
}
// Check they have supplied the right number of type parameters on the ITD target type
if (aliasCount>0) {
if (onTypeBinding.typeVariables().length != aliasCount) { // typeParameters.length) { phantom contains the fake ones from the ontype, typeparameters will also include extra things if it is a generic method
scope.problemReporter().signalError(sourceStart, sourceEnd,
"Incorrect number of type parameters supplied. The generic type "+onTypeBinding.debugName()+" has "+
onTypeBinding.typeVariables().length+" type parameters, not "+aliasCount+".");
ignoreFurtherInvestigation = true;
return;
}
}
// check if they used stupid names for type variables
if (aliasCount>0) {
for (int i = 0; i < aliasCount; i++) {
String array_element = (String)typeVariableAliases.get(i);
SingleTypeReference str = new SingleTypeReference(array_element.toCharArray(),0);
TypeBinding tb = str.getTypeBindingPublic(classScope);
if (tb!=null && !(tb instanceof ProblemReferenceBinding)) {// && !(tb instanceof TypeVariableBinding)) {
scope.problemReporter().signalError(sourceStart,sourceEnd,
"Intertype declarations can only be made on the generic type, not on a parameterized type. The name '"+
array_element+"' cannot be used as a type parameter, since it refers to a real type.");
ignoreFurtherInvestigation = true;