Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit b2efe9e

Browse files
committed
Merge pull request #2361 from VSadov/Update
Restoring the return type of the Expression<TDelegate>.Update
2 parents 6d8a7b5 + 9203354 commit b2efe9e

File tree

7 files changed

+26
-34
lines changed

7 files changed

+26
-34
lines changed

src/System.Linq.Expressions/src/System/Linq/Expressions/DebugViewWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ protected internal override Expression VisitParameter(ParameterExpression node)
430430
return node;
431431
}
432432

433-
protected internal override Expression VisitLambda(LambdaExpression node)
433+
protected internal override Expression VisitLambda<T>(Expression<T> node)
434434
{
435435
Out(
436436
String.Format(CultureInfo.CurrentCulture,

src/System.Linq.Expressions/src/System/Linq/Expressions/ExpressionStringBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ protected internal override Expression VisitParameter(ParameterExpression node)
326326
return node;
327327
}
328328

329-
protected internal override Expression VisitLambda(LambdaExpression node)
329+
protected internal override Expression VisitLambda<T>(Expression<T> node)
330330
{
331331
if (node.Parameters.Count == 1)
332332
{

src/System.Linq.Expressions/src/System/Linq/Expressions/ExpressionVisitor.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -364,18 +364,6 @@ protected internal virtual Expression VisitLabel(LabelExpression node)
364364
/// <returns>The modified expression, if it or any subexpression was modified;
365365
/// otherwise, returns the original expression.</returns>
366366
protected internal virtual Expression VisitLambda<T>(Expression<T> node)
367-
{
368-
return VisitLambda((LambdaExpression)node);
369-
}
370-
371-
/// <summary>
372-
/// Visits the children of the <see cref="LambdaExpression" />.
373-
/// </summary>
374-
/// <typeparam name="T">The type of the delegate.</typeparam>
375-
/// <param name="node">The expression to visit.</param>
376-
/// <returns>The modified expression, if it or any subexpression was modified;
377-
/// otherwise, returns the original expression.</returns>
378-
protected internal virtual Expression VisitLambda(LambdaExpression node)
379367
{
380368
return node.Update(Visit(node.Body), VisitAndConvert(node.Parameters, "VisitLambda"));
381369
}

src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/LightCompiler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2694,7 +2694,7 @@ protected override CatchBlock VisitCatchBlock(CatchBlock node)
26942694
return node;
26952695
}
26962696

2697-
protected internal override Expression VisitLambda(LambdaExpression node)
2697+
protected internal override Expression VisitLambda<T>(Expression<T> node)
26982698
{
26992699
PushParameters(node.Parameters);
27002700

src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/TypeOperations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2262,7 +2262,7 @@ internal ExpressionQuoter(Dictionary<ParameterExpression, LocalVariable> hoisted
22622262
_frame = frame;
22632263
}
22642264

2265-
protected internal override Expression VisitLambda(LambdaExpression node)
2265+
protected internal override Expression VisitLambda<T>(Expression<T> node)
22662266
{
22672267
_shadowedVars.Push(new Set<ParameterExpression>(node.Parameters));
22682268
Expression b = Visit(node.Body);

src/System.Linq.Expressions/src/System/Linq/Expressions/LambdaExpression.cs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -120,23 +120,6 @@ public Delegate Compile()
120120
#endif
121121
}
122122

123-
/// <summary>
124-
/// Dispatches to the specific visit method for this node type.
125-
/// </summary>
126-
protected internal override Expression Accept(ExpressionVisitor visitor)
127-
{
128-
return visitor.VisitLambda(this);
129-
}
130-
131-
public virtual LambdaExpression Update(Expression body, IEnumerable<ParameterExpression> parameters)
132-
{
133-
if (body == Body && parameters == Parameters)
134-
{
135-
return this;
136-
}
137-
return Expression.Lambda(Type, body, Name, TailCall, parameters);
138-
}
139-
140123
#if FEATURE_CORECLR
141124
internal abstract LambdaExpression Accept(Compiler.StackSpiller spiller);
142125
#endif
@@ -178,7 +161,7 @@ public Expression(Expression body, string name, bool tailCall, ReadOnlyCollectio
178161
/// <param name="body">The <see cref="LambdaExpression.Body">Body</see> property of the result.</param>
179162
/// <param name="parameters">The <see cref="LambdaExpression.Parameters">Parameters</see> property of the result.</param>
180163
/// <returns>This expression if no children changed, or an expression with the updated children.</returns>
181-
public override LambdaExpression Update(Expression body, IEnumerable<ParameterExpression> parameters)
164+
public Expression<TDelegate> Update(Expression body, IEnumerable<ParameterExpression> parameters)
182165
{
183166
if (body == Body && parameters == Parameters)
184167
{

src/System.Linq.Expressions/tests/SequenceTests/SequenceTests.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3870,6 +3870,27 @@ public static void ObjectSwitch1()
38703870
Assert.Equal("null", f(null));
38713871
}
38723872

3873+
static class System_Linq_Expressions_Expression_TDelegate__1
3874+
{
3875+
public static T Default<T>() { return default(T); }
3876+
public static void UseSystem_Linq_Expressions_Expression_TDelegate__1(bool call) // call this passing false
3877+
{
3878+
if (call)
3879+
{
3880+
Default<System.Linq.Expressions.Expression<System.Object>>().Compile();
3881+
Default<System.Linq.Expressions.Expression<System.Object>>().Update(
3882+
Default<System.Linq.Expressions.Expression>(),
3883+
Default<System.Collections.Generic.IEnumerable<System.Linq.Expressions.ParameterExpression>>());
3884+
}
3885+
}
3886+
}
3887+
3888+
[Fact]
3889+
public static void ExprT_Update()
3890+
{
3891+
System_Linq_Expressions_Expression_TDelegate__1.UseSystem_Linq_Expressions_Expression_TDelegate__1(false);
3892+
}
3893+
38733894
public class TestComparers
38743895
{
38753896
public static bool CaseInsensitiveStringCompare(string s1, string s2)

0 commit comments

Comments
 (0)