UserFunction newuf = ObjectUtils.deepCopy(func);
List<ParametricVariable> newParams = newuf.getParameters();
final int psize = newParams.size();
for(int i = 0; i < psize; i++) {
ParametricVariable p = newParams.get(i);
Type implicitParamType = p.getType();
XQExpression arg = argv.get(i);
Type argType = arg.getType();
if(implicitParamType != Untyped.UNTYPED && !implicitParamType.accepts(argType)) {
// type promotion is required for arguments
p.setValue(new TypePromotedExpr(arg, implicitParamType));
} else {
p.setValue(arg);