Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MaybeNull wrapper round nullness syntax removed and refactored for src/fsi/console.fs #18201

Merged
merged 3 commits into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading