return Clone (Expr.Clone (clonectx));
}
- public virtual Expression CreateExpressionTree (ResolveContext ec)
+ public virtual Expression CreateExpressionTree (ResolveContext rc)
{
+ if (Type.Kind == MemberKind.ByRef) {
+ rc.Report.Error (8153, Expr.Location, "An expression tree lambda cannot contain a call to a method, property, or indexer that returns by reference");
+ return null;
+ }
+
if (ArgType == AType.Default)
- ec.Report.Error (854, Expr.Location, "An expression tree cannot contain an invocation which uses optional parameter");
+ rc.Report.Error (854, Expr.Location, "An expression tree cannot contain an invocation which uses optional parameter");
- return Expr.CreateExpressionTree (ec);
+ return Expr.CreateExpressionTree (rc);
}
return;
}
+ if (Expr.Type.Kind == MemberKind.ByRef) {
+ Expr.Emit (ec);
+ return;
+ }
+
AddressOp mode = AddressOp.Store;
if (ArgType == AType.Ref)
mode |= AddressOp.Load;
- IMemoryLocation ml = (IMemoryLocation) Expr;
- ml.AddressOf (ec, mode);
+ ((IMemoryLocation)Expr).AddressOf (ec, mode);
}
public Argument EmitToField (EmitContext ec, bool cloneResult)
return all;
}
- public static Arguments CreateForExpressionTree (ResolveContext ec, Arguments args, params Expression[] e)
+ public static Arguments CreateForExpressionTree (ResolveContext rc, Arguments args, params Expression[] e)
{
Arguments all = new Arguments ((args == null ? 0 : args.Count) + e.Length);
for (int i = 0; i < e.Length; ++i) {
- if (e [i] != null)
- all.Add (new Argument (e[i]));
+ var expr = e [i];
+ if (expr != null) {
+ all.Add (new Argument (expr));
+ }
}
if (args != null) {
foreach (Argument a in args.args) {
- Expression tree_arg = a.CreateExpressionTree (ec);
+ Expression tree_arg = a.CreateExpressionTree (rc);
if (tree_arg != null)
all.Add (new Argument (tree_arg));
}