Inside my InvokeBinder implementation, I want to examine metadata and conditionally return an ET that either does "real work" or is a simple no-op (Expression.Empty()). In the no-op scenario, I prefer not to return Expression.Default( typeof( object
) ), because I assume the CLR JIT won't necessarily optimize that away like I assume it would with an Expression.Empty().
Since InvokeBinder.ReturnType is hardcoded to return typeof(object), I can't return Expression.Empty() from my InvokeBinder... the call site is always expecting an expression of type object.
1) Why must InvokeBinder always return an ET of type object? I suppose it would make the DLR plumbing a bit cleaner, but it seems arbitrary, from the outside looking in.
2) Are my assumptions correct w.r.t. the CLR JIT behavior?
2) Is there some other way to achieve what I'm describing? Maybe use another binder base type?