final ParameterExpression pex = parameters.get(i);
final ParameterInfo pi = methodParameters.get(i);
verifyCanRead(pex, "parameters");
final Type pType = pi.getParameterType();
if (!TypeUtils.areEquivalent(pex.getType(), pType)) {
if (!pType.isGenericParameter() || !pType.isAssignableFrom(pex.getType())) {
throw Error.parameterExpressionNotValidForDelegate(pex.getType(), pType);
}
}
if (set.contains(pex)) {
throw Error.duplicateVariable(pex);
}
set.add(pex);
}
}
else if (parameters.size() > 0) {
throw Error.incorrectNumberOfLambdaDeclarationParameters();
}
final Type returnType = method.getReturnType();
if (returnType != PrimitiveTypes.Void &&
!TypeUtils.areEquivalent(returnType, body.getType())) {
if (/*!returnType.isGenericParameter() ||*/ !returnType.isAssignableFrom(body.getType())) {
throw Error.expressionTypeDoesNotMatchReturn(body.getType(), returnType);
}
}
}