From 648324e87f393362c2e8ba7bc62c863a5b1ba965 Mon Sep 17 00:00:00 2001 From: Brian Rourke Boll Date: Mon, 29 Jul 2024 09:53:18 -0400 Subject: [PATCH] =?UTF-8?q?Replace=20internal=20option=E2=80=93voption=20c?= =?UTF-8?q?onversions=20with=20FSharp.Core=20funcs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Compiler/Service/IncrementalBuild.fs | 5 ----- src/Compiler/TypedTree/TypedTree.fs | 6 +++--- src/Compiler/TypedTree/TypedTreeOps.fs | 6 +++--- src/Compiler/Utilities/illib.fs | 12 ------------ src/Compiler/Utilities/illib.fsi | 6 ------ .../src/FSharp.Editor/Common/Extensions.fs | 13 ------------- .../CodeFixes/CodeFixTestFramework.fs | 10 ---------- 7 files changed, 6 insertions(+), 52 deletions(-) diff --git a/src/Compiler/Service/IncrementalBuild.fs b/src/Compiler/Service/IncrementalBuild.fs index 872b27fdcd9..0cdc4b9235e 100644 --- a/src/Compiler/Service/IncrementalBuild.fs +++ b/src/Compiler/Service/IncrementalBuild.fs @@ -229,11 +229,6 @@ type TcInfoExtras = member x.TcSymbolUses = x.tcSymbolUses -module ValueOption = - let toOption = function - | ValueSome x -> Some x - | _ -> None - type private SingleFileDiagnostics = (PhasedDiagnostic * FSharpDiagnosticSeverity) array type private TypeCheck = TcInfo * TcResultsSinkImpl * CheckedImplFile option * string * SingleFileDiagnostics diff --git a/src/Compiler/TypedTree/TypedTree.fs b/src/Compiler/TypedTree/TypedTree.fs index 11ff117cc25..d2af320b8de 100644 --- a/src/Compiler/TypedTree/TypedTree.fs +++ b/src/Compiler/TypedTree/TypedTree.fs @@ -2122,7 +2122,7 @@ type ModuleOrNamespaceType(kind: ModuleOrNamespaceKind, vals: QueueList, en |> List.tryFind (fun v -> match key.TypeForLinkage with | None -> true | Some keyTy -> ccu.MemberSignatureEquality(keyTy, v.Type)) - |> ValueOptionInternal.ofOption + |> ValueOption.ofOption /// Get a table of values indexed by logical name member _.AllValsByLogicalName = @@ -4237,7 +4237,7 @@ type UnionCaseRef = /// Try to dereference the reference member x.TryUnionCase = x.TyconRef.TryDeref - |> ValueOptionInternal.bind (fun tcref -> tcref.GetUnionCaseByName x.CaseName |> ValueOptionInternal.ofOption) + |> ValueOption.bind (fun tcref -> tcref.GetUnionCaseByName x.CaseName |> ValueOption.ofOption) /// Get the attributes associated with the union case member x.Attribs = x.UnionCase.Attribs @@ -4300,7 +4300,7 @@ type RecdFieldRef = /// Try to dereference the reference member x.TryRecdField = x.TyconRef.TryDeref - |> ValueOptionInternal.bind (fun tcref -> tcref.GetFieldByName x.FieldName |> ValueOptionInternal.ofOption) + |> ValueOption.bind (fun tcref -> tcref.GetFieldByName x.FieldName |> ValueOption.ofOption) /// Get the attributes associated with the compiled property of the record field member x.PropertyAttribs = x.RecdField.PropertyAttribs diff --git a/src/Compiler/TypedTree/TypedTreeOps.fs b/src/Compiler/TypedTree/TypedTreeOps.fs index d4f58881b19..909d6f437a8 100644 --- a/src/Compiler/TypedTree/TypedTreeOps.fs +++ b/src/Compiler/TypedTree/TypedTreeOps.fs @@ -3526,11 +3526,11 @@ let IsMatchingFSharpAttributeOpt g attrOpt (Attrib(tcref2, _, _, _, _, _, _)) = [] let (|ExtractAttribNamedArg|_|) nm args = - args |> List.tryPick (function AttribNamedArg(nm2, _, _, v) when nm = nm2 -> Some v | _ -> None) |> ValueOptionInternal.ofOption - + args |> List.tryPick (function AttribNamedArg(nm2, _, _, v) when nm = nm2 -> Some v | _ -> None) |> ValueOption.ofOption + [] let (|ExtractILAttributeNamedArg|_|) nm (args: ILAttributeNamedArg list) = - args |> List.tryPick (function nm2, _, _, v when nm = nm2 -> Some v | _ -> None) |> ValueOptionInternal.ofOption + args |> List.tryPick (function nm2, _, _, v when nm = nm2 -> Some v | _ -> None) |> ValueOption.ofOption [] let (|StringExpr|_|) = function Expr.Const (Const.String n, _, _) -> ValueSome n | _ -> ValueNone diff --git a/src/Compiler/Utilities/illib.fs b/src/Compiler/Utilities/illib.fs index e09c650e39b..5e32e3b8699 100644 --- a/src/Compiler/Utilities/illib.fs +++ b/src/Compiler/Utilities/illib.fs @@ -715,18 +715,6 @@ module Span = state -module ValueOptionInternal = - - let inline ofOption x = - match x with - | Some x -> ValueSome x - | None -> ValueNone - - let inline bind ([] f) x = - match x with - | ValueSome x -> f x - | ValueNone -> ValueNone - module String = let make (n: int) (c: char) : string = String(c, n) diff --git a/src/Compiler/Utilities/illib.fsi b/src/Compiler/Utilities/illib.fsi index be4edea38f9..03525593188 100644 --- a/src/Compiler/Utilities/illib.fsi +++ b/src/Compiler/Utilities/illib.fsi @@ -243,12 +243,6 @@ module internal ResizeArray = module internal Span = val inline exists: predicate: ('T -> bool) -> span: Span<'T> -> bool -module internal ValueOptionInternal = - - val inline ofOption: x: 'a option -> 'a voption - - val inline bind: f: ('a -> 'b voption) -> x: 'a voption -> 'b voption - module internal String = val make: n: int -> c: char -> string diff --git a/vsintegration/src/FSharp.Editor/Common/Extensions.fs b/vsintegration/src/FSharp.Editor/Common/Extensions.fs index b0eb7305713..5b154deab73 100644 --- a/vsintegration/src/FSharp.Editor/Common/Extensions.fs +++ b/vsintegration/src/FSharp.Editor/Common/Extensions.fs @@ -327,19 +327,6 @@ module Option = else None -[] -module ValueOption = - - let inline ofOption o = - match o with - | Some v -> ValueSome v - | _ -> ValueNone - - let inline toOption o = - match o with - | ValueSome v -> Some v - | _ -> None - [] module IEnumerator = let chooseV f (e: IEnumerator<'T>) = diff --git a/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/CodeFixTestFramework.fs b/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/CodeFixTestFramework.fs index 55920c294ed..d5f2dbd3988 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/CodeFixTestFramework.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/CodeFixTestFramework.fs @@ -33,16 +33,6 @@ type Mode = | WithSettings of CodeFixesOptions module ValueOption = - let inline toOption o = - match o with - | ValueSome v -> Some v - | _ -> None - - let inline ofOption o = - match o with - | Some v -> ValueSome v - | _ -> ValueNone - let inline either f y o = match o with | ValueSome v -> f v