Skip to content

Commit

Permalink
MaybeNull wrapper round nullness syntax removed and refactored for sr…
Browse files Browse the repository at this point in the history
…c/fsi/console.fs (#18201)
  • Loading branch information
progressive-galib authored Jan 6, 2025
1 parent fbdb7cb commit d6393f2
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions src/fsi/console.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,6 @@ open System.Collections.Generic
open System.Runtime.InteropServices
open FSharp.Compiler.DiagnosticsLogger

[<AutoOpen>]
module internal ConsoleHelpers =

#if NO_CHECKNULLS
type MaybeNull<'T when 'T : null> = 'T

// Shim to match nullness checking library support in preview
let inline (|Null|NonNull|) (x: 'T) : Choice<unit,'T> = match x with null -> Null | v -> NonNull v
#else
type MaybeNull<'T when 'T : not null> = 'T | null
#endif

type internal Style =
| Prompt
| Out
Expand All @@ -42,17 +30,17 @@ type internal History() =
list.Clear()
current <- -1

member _.Add (line: string MaybeNull) =
member _.Add (line: string | null) =
match line with
| Null
| null
| "" -> ()
| NonNull line -> list.Add(line)
| _ -> list.Add(line)

member _.AddLast (line: string MaybeNull) =
member _.AddLast (line: string | null) =
match line with
| Null
| null
| "" -> ()
| NonNull line ->
| _ ->
list.Add(line)
current <- list.Count

Expand Down

0 comments on commit d6393f2

Please # to comment.