rsdn/nemerle — Issue #232: Linq.Expression in generic method
Author: igor-tkachev
Created: 2012-01-06 20:22:18+00:00
State: open

The following code:

module TestGen[TFrom,TTo]
{
public GetExpr() : System.Linq.Expressions.Expression[System.Func[TFrom,TTo]]
{
Nemerle.Linq.ToExpression((o : TFrom) => System.Convert.ChangeType(o, typeof(TFrom)) :> TTo)
}
}

public Test() : void
{
TestGen[int,string].GetExpr().Compile()(1)
}

results st run-time

System.ArgumentException : Expression of type 'System.Int32' cannot be used for parameter of type 'System.Object' of method 'System.Object ChangeType(System.Object, System.Type)'