diff --git a/src/Compiler/Utilities/illib.fs b/src/Compiler/Utilities/illib.fs index fe091c640b3..4ed4cf57e50 100644 --- a/src/Compiler/Utilities/illib.fs +++ b/src/Compiler/Utilities/illib.fs @@ -15,8 +15,6 @@ open FSharp.Compiler.Caches [] type InterruptibleLazy<'T> private (value, valueFactory: unit -> 'T) = - let syncObj = obj () - [] // TODO nullness - this is boxed to obj because of an attribute targets bug fixed in main, but not yet shipped (needs shipped 8.0.400) let mutable valueFactory: objnull = valueFactory @@ -34,7 +32,7 @@ type InterruptibleLazy<'T> private (value, valueFactory: unit -> 'T) = match valueFactory with | null -> value | _ -> - Monitor.Enter(syncObj) + Monitor.Enter(this) try match valueFactory with @@ -44,7 +42,7 @@ type InterruptibleLazy<'T> private (value, valueFactory: unit -> 'T) = value <- (valueFactory |> unbox 'T>) () valueFactory <- Unchecked.defaultof<_> finally - Monitor.Exit(syncObj) + Monitor.Exit(this) value @@ -153,8 +151,6 @@ module internal PervasiveAutoOpens = [] type DelayInitArrayMap<'T, 'TDictKey, 'TDictValue>(f: unit -> 'T[]) = - let syncObj = obj () - let mutable arrayStore: (_ array | null) = null let mutable dictStore: (_ | null) = null @@ -164,7 +160,7 @@ type DelayInitArrayMap<'T, 'TDictKey, 'TDictValue>(f: unit -> 'T[]) = match arrayStore with | NonNull value -> value | _ -> - Monitor.Enter(syncObj) + Monitor.Enter(this) try match arrayStore with @@ -176,14 +172,14 @@ type DelayInitArrayMap<'T, 'TDictKey, 'TDictValue>(f: unit -> 'T[]) = func <- Unchecked.defaultof<_> freshArray finally - Monitor.Exit(syncObj) + Monitor.Exit(this) member this.GetDictionary() = match dictStore with | NonNull value -> value | _ -> let array = this.GetArray() - Monitor.Enter(syncObj) + Monitor.Enter(this) try match dictStore with @@ -193,7 +189,7 @@ type DelayInitArrayMap<'T, 'TDictKey, 'TDictValue>(f: unit -> 'T[]) = dictStore <- dict dict finally - Monitor.Exit(syncObj) + Monitor.Exit(this) abstract CreateDictionary: 'T[] -> IDictionary<'TDictKey, 'TDictValue>