@@ -396,7 +396,7 @@ module LeafExpressionConverter =
396396 | NullableGreaterEqNullableQ _ -> transBinOp inp env false args false Expression.GreaterThanOrEqual
397397 | NullableLessNullableQ _ -> transBinOp inp env false args false Expression.LessThan
398398 | NullableLessEqNullableQ _ -> transBinOp inp env false args false Expression.LessThanOrEqual
399-
399+
400400 // Detect the F# quotation encoding of decimal literals
401401 | MakeDecimalQ (_, _, [ Int32 lo; Int32 med; Int32 hi; Bool isNegative; Byte scale]) ->
402402 Expression.Constant ( new System.Decimal( lo, med, hi, isNegative, scale)) |> asExpr
@@ -414,33 +414,33 @@ module LeafExpressionConverter =
414414 | BitwiseOrQ _ -> transBinOp inp env false args false Expression.Or
415415 | BitwiseXorQ _ -> transBinOp inp env false args false Expression.ExclusiveOr
416416 | BitwiseNotQ (_, _, [ x1]) -> Expression.Not( ConvExprToLinqInContext env x1) |> asExpr
417-
418- | CheckedNeg (_, _, [ x1]) -> Expression.NegateChecked( ConvExprToLinqInContext env x1) |> asExpr
417+
418+ | CheckedNeg (_, _, [ x1]) -> Expression.NegateChecked( ConvExprToLinqInContext env x1) |> asExpr
419419 | CheckedPlusQ _ -> transBinOp inp env false args false Expression.AddChecked
420420 | CheckedMinusQ _ -> transBinOp inp env false args false Expression.SubtractChecked
421421 | CheckedMultiplyQ _ -> transBinOp inp env false args false Expression.MultiplyChecked
422-
422+
423423 | NullablePlusQ _ -> transBinOp inp env false args true Expression.Add
424424 | PlusNullableQ _ -> transBinOp inp env true args false Expression.Add
425425 | NullablePlusNullableQ _ -> transBinOp inp env false args false Expression.Add
426-
426+
427427 | NullableMinusQ _ -> transBinOp inp env false args true Expression.Subtract
428428 | MinusNullableQ _ -> transBinOp inp env true args false Expression.Subtract
429429 | NullableMinusNullableQ _ -> transBinOp inp env false args false Expression.Subtract
430-
430+
431431 | NullableMultiplyQ _ -> transBinOp inp env false args true Expression.Multiply
432432 | MultiplyNullableQ _ -> transBinOp inp env true args false Expression.Multiply
433433 | NullableMultiplyNullableQ _ -> transBinOp inp env false args false Expression.Multiply
434-
434+
435435 | NullableDivideQ _ -> transBinOp inp env false args true Expression.Divide
436436 | DivideNullableQ _ -> transBinOp inp env true args false Expression.Divide
437437 | NullableDivideNullableQ _ -> transBinOp inp env false args false Expression.Divide
438-
438+
439439 | NullableModuloQ _ -> transBinOp inp env false args true Expression.Modulo
440440 | ModuloNullableQ _ -> transBinOp inp env true args false Expression.Modulo
441441 | NullableModuloNullableQ _ -> transBinOp inp env false args false Expression.Modulo
442442
443- | ConvNullableCharQ (_, _, [ x1]) -> Expression.Convert( ConvExprToLinqInContext env x1, typeof< Nullable< char>>) |> asExpr
443+ | ConvNullableCharQ (_, _, [ x1]) -> Expression.Convert( ConvExprToLinqInContext env x1, typeof< Nullable< char>>) |> asExpr
444444 | ConvNullableDecimalQ (_, _, [ x1]) -> Expression.Convert( ConvExprToLinqInContext env x1, typeof< Nullable< decimal>>) |> asExpr
445445 | ConvNullableFloatQ (_, _, [ x1]) -> Expression.Convert( ConvExprToLinqInContext env x1, typeof< Nullable< float>>) |> asExpr
446446 | ConvNullableDoubleQ (_, _, [ x1]) -> Expression.Convert( ConvExprToLinqInContext env x1, typeof< Nullable< double>>) |> asExpr
@@ -496,10 +496,19 @@ module LeafExpressionConverter =
496496 // Throw away markers inserted to satisfy C#'s design where they pass an argument
497497 // or type T to an argument expecting Expression<T>.
498498 | ImplicitExpressionConversionHelperQ (_, [_], [ x1]) -> ConvExprToLinqInContext env x1
499-
500- | _ ->
501- let argsP = ConvExprsToLinq env args
502- Expression.Call( ConvObjArg env objOpt None, minfo, argsP) |> asExpr
499+
500+ /// Use witnesses if they are available
501+ | CallWithWitnesses ( objArgOpt, _, minfo2, witnessArgs, args) ->
502+ let fullArgs = witnessArgs @ args
503+ let replacementExpr =
504+ match objArgOpt with
505+ | None -> Expr.Call( minfo2, fullArgs)
506+ | Some objArg -> Expr.Call( objArg, minfo2, fullArgs)
507+ ConvExprToLinqInContext env replacementExpr
508+
509+ | _ ->
510+ let argsP = ConvExprsToLinq env args
511+ Expression.Call( ConvObjArg env objOpt None, minfo, argsP) |> asExpr
503512
504513#if ! NO_ CURRIED_ FUNCTION_ OPTIMIZATIONS
505514 // f x1 x2 x3 x4 --> InvokeFast4
@@ -650,12 +659,11 @@ module LeafExpressionConverter =
650659 let convType = lambdaTy.MakeGenericType tyargs
651660 let convDelegate = Expression.Lambda( convType, bodyP, [| vP |]) |> asExpr
652661 Expression.Call( typeof< FuncConvert>, " ToFSharpFunc" , tyargs, [| convDelegate |]) |> asExpr
653-
654662 | _ ->
655663 failConvert inp
656664
657665 and failConvert inp =
658- raise ( new NotSupportedException( Printf.sprintf " Could not convert the following F# Quotation to a LINQ Expression Tree\n --------\n %A \n -------------\n " inp))
666+ raise ( new NotSupportedException( Printf.sprintf " Could not convert the following F# Quotation to a LINQ Expression Tree\n --------\n %A \n -------------\n " inp))
659667
660668 and transBinOp inp env addConvertLeft args addConvertRight ( exprErasedConstructor : _ * _ -> _ ) =
661669 match args with
0 commit comments