Skip to content

Commit 07f74a7

Browse files
committed
Use Unbox instead of Coerce
1 parent f53ce2d commit 07f74a7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/FSharpPlus/Extensions/Expr.fs

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@ module Expr =
1515

1616
let [<Literal>] private opSliceName = "SpliceExpression"
1717
let [<Literal>] private opSliceType = "ExtraTopLevelOperators"
18+
let [<Literal>] private ubSliceName = "Unbox"
19+
let [<Literal>] private ubSliceType = "Operators"
1820

1921
let private fsCoreAs = AppDomain.CurrentDomain.GetAssemblies () |> Seq.find (fun a -> a.GetName().Name = "FSharp.Core")
2022
let private miSplice = fsCoreAs.GetType(fsNamespace + "." + opSliceType).GetMethod opSliceName
23+
let private ubSplice = fsCoreAs.GetType(fsNamespace + "." + ubSliceType).GetMethod ubSliceName
2124

2225
let bind (f: 'T -> Expr<'U>) (x: Expr<'T>) : Expr<'U> =
23-
Expr.Coerce (Expr.Call (miSplice.MakeGenericMethod typeof<'U>, [Expr.Application (Expr.Value f, x)]), typeof<'U>)
26+
Expr.Call (ubSplice.MakeGenericMethod typeof<'U>,
27+
[Expr.Call (miSplice.MakeGenericMethod typeof<'U>, [Expr.Application (Expr.Value f, x)])])
2428
|> Expr.Cast
2529

2630
let rec runWithUntyped (eval: Expr -> obj) (exp: Expr) s =

0 commit comments

Comments
 (0)