Skip to content

Commit 0680331

Browse files
committed
fixing the type of ValueConstantExpression arg from object to T
1 parent 80a02de commit 0680331

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/FastExpressionCompiler.LightExpression/Expression.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,9 @@ public sealed class ValueRef<T>
199199
public static Expression ConstantRef<T>(T value, out ValueRef<T> valueRef)
200200
{
201201
valueRef = new ValueRef<T>(value);
202-
return new InstanceFieldExpression(new ValueConstantExpression<T>(valueRef), ValueRef<T>.ValueField);
202+
203+
// todo: @perf try the intrinsic?
204+
return new InstanceFieldExpression(new ValueConstantExpression<ValueRef<T>>(valueRef), ValueRef<T>.ValueField);
203205
}
204206

205207
/// <summary>Avoids the boxing for all (two) bool values</summary>
@@ -3879,7 +3881,7 @@ public sealed class ValueConstantExpression<T> : ConstantExpression
38793881
// Note: the Value is specifically an object despite possibility of strongly typed T, because this way it will be a single boxing.
38803882
// Otherwise even using the typed `T _value`, it will be boxed multiple times through its `object Value` accessor.
38813883
public override object Value { get; }
3882-
internal ValueConstantExpression(object value) => Value = value;
3884+
internal ValueConstantExpression(T value) => Value = value;
38833885
}
38843886

38853887
public sealed class TypedValueConstantExpression : ConstantExpression

src/FastExpressionCompiler/FastExpressionCompiler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4102,7 +4102,7 @@ private static bool TryEmitArithmeticAndOrAssign(
41024102
var paramIndex = -1;
41034103
var localVarIndex = closure.GetDefinedLocalVarOrDefault(p);
41044104
if (localVarIndex != -1)
4105-
EmitLoadLocalVariable(il, localVarIndex); // todo: @wip #346
4105+
EmitLoadLocalVariable(il, localVarIndex);
41064106
else
41074107
{
41084108
paramIndex = paramExprCount - 1;

0 commit comments

Comments
 (0)