I think you just need a call to Expression.Convert
, and use a ConstantExpression
instead of a ParameterExpression
:
var method = typeof(SomeClass).GetMethod("Create");
var call = Expression.Call(method, Expression.Constant(typeof(T), typeof(Type)));
var conversion = Expression.Convert(call, typeof(T));
var function = Expression.Lambda<Func<T>>(conversion).Compile();
(I haven't tested it, but it looks okay...)