Skip to content

Commit 8b81788

Browse files
authored
Merge pull request #311 from fsprojects/repo-assist/fix-issue-310-deprecated-refcell-ops-17deacd89a21fb5a
[Repo Assist] Fix deprecated F# refcell operators (! and :=)
2 parents 8d8a18f + 3201a7e commit 8b81788

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

src/FSharp.Control.AsyncSeq/AsyncSeq.fs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -551,31 +551,31 @@ module AsyncSeq =
551551
let state = ref (TryWithState.NotStarted inp)
552552
{ new IAsyncSeqEnumerator<'T> with
553553
member x.MoveNext() =
554-
async { match !state with
554+
async { match state.Value with
555555
| TryWithState.NotStarted inp ->
556556
let res = ref Unchecked.defaultof<_>
557557
try
558-
res := Choice1Of2 (inp.GetEnumerator())
558+
res.Value <- Choice1Of2 (inp.GetEnumerator())
559559
with exn ->
560-
res := Choice2Of2 exn
560+
res.Value <- Choice2Of2 exn
561561
match res.Value with
562562
| Choice1Of2 r ->
563563
return!
564-
(state := TryWithState.HaveBodyEnumerator r
564+
(state.Value <- TryWithState.HaveBodyEnumerator r
565565
x.MoveNext())
566566
| Choice2Of2 exn ->
567567
return!
568568
(x.Dispose()
569569
let enum = (handler exn).GetEnumerator()
570-
state := TryWithState.HaveHandlerEnumerator enum
570+
state.Value <- TryWithState.HaveHandlerEnumerator enum
571571
x.MoveNext())
572572
| TryWithState.HaveBodyEnumerator e ->
573573
let res = ref Unchecked.defaultof<_>
574574
try
575575
let! r = e.MoveNext()
576-
res := Choice1Of2 r
576+
res.Value <- Choice1Of2 r
577577
with exn ->
578-
res := Choice2Of2 exn
578+
res.Value <- Choice2Of2 exn
579579
match res.Value with
580580
| Choice1Of2 res ->
581581
return
@@ -587,7 +587,7 @@ module AsyncSeq =
587587
return!
588588
(x.Dispose()
589589
let e = (handler exn).GetEnumerator()
590-
state := TryWithState.HaveHandlerEnumerator e
590+
state.Value <- TryWithState.HaveHandlerEnumerator e
591591
x.MoveNext())
592592
| TryWithState.HaveHandlerEnumerator e ->
593593
let! res = e.MoveNext()
@@ -597,9 +597,9 @@ module AsyncSeq =
597597
| _ ->
598598
return None }
599599
member x.Dispose() =
600-
match !state with
600+
match state.Value with
601601
| TryWithState.HaveBodyEnumerator e | TryWithState.HaveHandlerEnumerator e ->
602-
state := TryWithState.Finished
602+
state.Value <- TryWithState.Finished
603603
dispose e
604604
| _ -> () }) :> AsyncSeq<'T>
605605

@@ -617,11 +617,11 @@ module AsyncSeq =
617617
let state = ref (TryFinallyState.NotStarted inp)
618618
{ new IAsyncSeqEnumerator<'T> with
619619
member x.MoveNext() =
620-
async { match !state with
620+
async { match state.Value with
621621
| TryFinallyState.NotStarted inp ->
622622
return!
623623
(let e = inp.GetEnumerator()
624-
state := TryFinallyState.HaveBodyEnumerator e
624+
state.Value <- TryFinallyState.HaveBodyEnumerator e
625625
x.MoveNext())
626626
| TryFinallyState.HaveBodyEnumerator e ->
627627
let! res = e.MoveNext()
@@ -633,9 +633,9 @@ module AsyncSeq =
633633
| _ ->
634634
return None }
635635
member x.Dispose() =
636-
match !state with
636+
match state.Value with
637637
| TryFinallyState.HaveBodyEnumerator e->
638-
state := TryFinallyState.Finished
638+
state.Value <- TryFinallyState.Finished
639639
dispose e
640640
compensation()
641641
| _ -> () }) :> AsyncSeq<'T>
@@ -770,10 +770,10 @@ module AsyncSeq =
770770
let state = ref (MapState.NotStarted inp)
771771
{ new IAsyncSeqEnumerator<'T> with
772772
member x.MoveNext() =
773-
async { match !state with
773+
async { match state.Value with
774774
| MapState.NotStarted inp ->
775775
let e = inp.GetEnumerator()
776-
state := MapState.HaveEnumerator e
776+
state.Value <- MapState.HaveEnumerator e
777777
return! x.MoveNext()
778778
| MapState.HaveEnumerator e ->
779779
return
@@ -784,9 +784,9 @@ module AsyncSeq =
784784
None)
785785
| _ -> return None }
786786
member x.Dispose() =
787-
match !state with
787+
match state.Value with
788788
| MapState.HaveEnumerator e ->
789-
state := MapState.Finished
789+
state.Value <- MapState.Finished
790790
dispose e
791791
| _ -> () }) :> AsyncSeq<'T>
792792

@@ -2167,7 +2167,7 @@ module AsyncSeq =
21672167
while cur.Value.IsSome do
21682168
yield cur.Value.Value
21692169
let! next = ie.MoveNext()
2170-
cur := next
2170+
cur.Value <- next
21712171
finally
21722172
ie.Dispose() }
21732173
return first, rest }
@@ -2500,7 +2500,7 @@ module AsyncSeq =
25002500
| None ->
25012501
let t = System.Threading.Tasks.TaskCompletionSource()
25022502
tasks.[i] <- t.Task // result never gets set
2503-
fin := fin.Value - 1
2503+
fin.Value <- fin.Value - 1
25042504
}
25052505

25062506
let combineLatestWithAsync (f:'a -> 'b -> Async<'c>) (source1:AsyncSeq<'a>) (source2:AsyncSeq<'b>) : AsyncSeq<'c> =

tests/fable/FSharp.Control.AsyncSeq.Tests/AsyncSeq.test.fs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ Jest.describe("AsyncSeq.try", fun () ->
454454
let s =
455455
asyncSeq {
456456
try yield 1
457-
finally x := x.Value + 3
457+
finally x.Value <- x.Value + 3
458458
}
459459

460460
Jest.expect(x.Value).toBe(0)
@@ -476,8 +476,8 @@ Jest.describe("AsyncSeq.try", fun () ->
476476
try
477477
yield 1
478478
failwith "fffail"
479-
finally x := x.Value + 1
480-
finally x := x.Value + 2
479+
finally x.Value <- x.Value + 1
480+
finally x.Value <- x.Value + 2
481481
}
482482

483483
Jest.expect(x.Value).toBe(0)
@@ -498,7 +498,7 @@ Jest.describe("AsyncSeq.try", fun () ->
498498
let s =
499499
asyncSeq {
500500
try failwith "ffail"
501-
with _ -> x := x.Value + 3
501+
with _ -> x.Value <- x.Value + 3
502502
}
503503

504504
Jest.expect(x.Value).toBe(0)
@@ -517,7 +517,7 @@ Jest.describe("AsyncSeq.try", fun () ->
517517
let s =
518518
asyncSeq {
519519
try yield 1
520-
with _ -> x := x.Value + 3
520+
with _ -> x.Value <- x.Value + 3
521521
}
522522

523523
Jest.expect(x.Value).toBe(0)
@@ -857,7 +857,7 @@ Jest.test("AsyncSeq.while should allow do at end", async {
857857
asyncSeq {
858858
while false do
859859
yield 1
860-
do! async { x := x.Value + 3 }
860+
do! async { x.Value <- x.Value + 3 }
861861
}
862862
|> AsyncSeq.toArrayAsync
863863

@@ -915,7 +915,7 @@ Jest.describe("AsyncSeq.intervalMs", fun () ->
915915
while actual.Value.Length < 10 do
916916
do! Async.Sleep 10
917917
let! timestamp = interval |> AsyncSeq.take 1 |> AsyncSeq.toArrayAsync
918-
actual := (timestamp |> Array.map (fun d -> d.Ticks)) |> Array.append actual.Value
918+
actual.Value <- (timestamp |> Array.map (fun d -> d.Ticks)) |> Array.append actual.Value
919919
}
920920
|> Async.StartImmediate
921921

@@ -962,7 +962,7 @@ let observe vs err =
962962
if err then
963963
observer.OnError (Failure "fail")
964964
observer.OnCompleted()
965-
{ new IDisposable with member __.Dispose() = discarded := true } },
965+
{ new IDisposable with member __.Dispose() = discarded.Value <- true } },
966966
(fun _ -> discarded.Value)
967967

968968
Jest.describe("AsyncSeq.ofObservableBuffered", fun () ->

0 commit comments

Comments
 (0)