private IMethod InferGenericMethodInvocation(MethodInvocationExpression node, IMethod targetMethod)
{
if (targetMethod.GenericInfo == null) return targetMethod;
GenericParameterInferrer inferrer = new GenericParameterInferrer(Context, targetMethod, node.Arguments);
inferrer.ResolveClosure += ProcessClosureInMethodInvocation;
if (!inferrer.Run())
{
CannotInferGenericMethodArguments(node, targetMethod);
return null;
}
IType[] inferredTypeArguments = inferrer.GetInferredTypes();
if (!_genericServices.Instance.CheckGenericConstruction(node, targetMethod, inferredTypeArguments, true))
{
Error(node);
return null;
}
IMethod constructedMethod = targetMethod.GenericInfo.ConstructMethod(inferredTypeArguments);
Bind(node.Target, constructedMethod);
BindExpressionType(node, GetInferredType(constructedMethod));
return constructedMethod;
}