void ProcessTypeInvocation(MethodInvocationExpression node)
{
var type = (IType)node.Target.Entity;
var callableType = type as ICallableType;
if (callableType != null)
{
ProcessCallableTypeInvocation(node, callableType);
return;
}
if (!AssertCanCreateInstance(node.Target, type))
{
Error(node);
return;
}
ResolveNamedArguments(type, node.NamedArguments);
if (type.IsValueType && node.Arguments.Count == 0)
{
ProcessValueTypeInstantiation(type, node);
return;
}
var ctor = GetCorrectConstructor(node, type, node.Arguments);
if (ctor != null)
{
BindConstructorInvocation(node, ctor);
if (node.NamedArguments.Count > 0)
ReplaceTypeInvocationByEval(type, node);
return;
}
Error(node);
}