String name = type.getGenericsTypes()[0].getName();
type = genericsSpec.get(name);
if (type != null && type.isGenericsPlaceHolder() && type.getGenericsTypes() == null) {
ClassNode placeholder = ClassHelper.makeWithoutCaching(type.getUnresolvedName());
placeholder.setGenericsPlaceHolder(true);
type = makeClassSafeWithGenerics(type, new GenericsType(placeholder));
}
}
if (type == null) type = ClassHelper.OBJECT_TYPE;
GenericsType[] oldgTypes = type.getGenericsTypes();
GenericsType[] newgTypes = new GenericsType[0];
if (oldgTypes != null) {
newgTypes = new GenericsType[oldgTypes.length];
for (int i = 0; i < newgTypes.length; i++) {
GenericsType oldgType = oldgTypes[i];
if (oldgType.isPlaceholder() ) {
if (genericsSpec.get(oldgType.getName())!=null) {
newgTypes[i] = new GenericsType(genericsSpec.get(oldgType.getName()));
} else {
newgTypes[i] = new GenericsType(ClassHelper.OBJECT_TYPE);
}
} else if (oldgType.isWildcard()) {
ClassNode oldLower = oldgType.getLowerBound();
ClassNode lower = oldLower!=null?correctToGenericsSpecRecurse(genericsSpec, oldLower):null;
ClassNode[] oldUpper = oldgType.getUpperBounds();
ClassNode[] upper = null;
if (oldUpper!=null) {
upper = new ClassNode[oldUpper.length];
for (int j = 0; j < oldUpper.length; j++) {
upper[j] = correctToGenericsSpecRecurse(genericsSpec,oldUpper[j]);
}
}
GenericsType fixed = new GenericsType(oldgType.getType(), upper, lower);
fixed.setName(oldgType.getName());
fixed.setWildcard(true);
newgTypes[i] = fixed;
} else {
newgTypes[i] = new GenericsType(correctToGenericsSpecRecurse(genericsSpec,correctToGenericsSpec(genericsSpec, oldgType)));
}
}
}
return makeClassSafeWithGenerics(type, newgTypes);
}