Skip to content

Commit 26007c5

Browse files
committed
fixed build (crazy bug with nullables)
1 parent 9e59a9e commit 26007c5

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/CSharp.Data.Adaptive/HashMap.fs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,17 @@ type HashMapBuilder<'Key, 'Value>() =
2121
member x.ToHashMap() =
2222
HashMap<'Key, 'Value>.OfArrayRange(array, 0, cnt)
2323

24+
[<AutoOpen>]
25+
module private CrazyNullableHelpers =
26+
27+
let funcInvoker<'a when 'a : struct and 'a : (new : unit -> 'a) and 'a :> ValueType> (n : Func<Nullable<'a>, Nullable<'a>>) (value : Nullable<'a>) : Nullable<'a> =
28+
(n.Invoke : Nullable<'a> -> Nullable<'a>) value
29+
30+
31+
2432
[<AbstractClass; Sealed; Extension; CompiledName("FSharpHashMap")>]
2533
type HashMap private() =
34+
2635
[<MethodImpl(MethodImplOptions.AggressiveInlining)>]
2736
static member Empty<'K, 'V>() = HashMap.empty<'K, 'V>
2837

@@ -106,11 +115,11 @@ type HashMap private() =
106115
this |> HashMap.alter key (fun o ->
107116
match o with
108117
| Some o ->
109-
let n = update.Invoke (Nullable o)
118+
let n = funcInvoker<'Value> update (Nullable o)
110119
if n.HasValue then Some n.Value
111120
else None
112121
| None ->
113-
let n = update.Invoke Unchecked.defaultof<_>
122+
let n = funcInvoker<'Value> update Unchecked.defaultof<_>
114123
if n.HasValue then Some n.Value
115124
else None
116125
)

0 commit comments

Comments
 (0)