Skip to content

Commit 013c998

Browse files
Replace internal option–voption conversions with FSharp.Core funcs (#18269)
1 parent a3bf3c9 commit 013c998

File tree

7 files changed

+6
-52
lines changed

7 files changed

+6
-52
lines changed

src/Compiler/Service/IncrementalBuild.fs

-5
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,6 @@ type TcInfoExtras =
229229
member x.TcSymbolUses =
230230
x.tcSymbolUses
231231

232-
module ValueOption =
233-
let toOption = function
234-
| ValueSome x -> Some x
235-
| _ -> None
236-
237232
type private SingleFileDiagnostics = (PhasedDiagnostic * FSharpDiagnosticSeverity) array
238233
type private TypeCheck = TcInfo * TcResultsSinkImpl * CheckedImplFile option * string * SingleFileDiagnostics
239234

src/Compiler/TypedTree/TypedTree.fs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2122,7 +2122,7 @@ type ModuleOrNamespaceType(kind: ModuleOrNamespaceKind, vals: QueueList<Val>, en
21222122
|> List.tryFind (fun v -> match key.TypeForLinkage with
21232123
| None -> true
21242124
| Some keyTy -> ccu.MemberSignatureEquality(keyTy, v.Type))
2125-
|> ValueOptionInternal.ofOption
2125+
|> ValueOption.ofOption
21262126

21272127
/// Get a table of values indexed by logical name
21282128
member _.AllValsByLogicalName =
@@ -4237,7 +4237,7 @@ type UnionCaseRef =
42374237
/// Try to dereference the reference
42384238
member x.TryUnionCase =
42394239
x.TyconRef.TryDeref
4240-
|> ValueOptionInternal.bind (fun tcref -> tcref.GetUnionCaseByName x.CaseName |> ValueOptionInternal.ofOption)
4240+
|> ValueOption.bind (fun tcref -> tcref.GetUnionCaseByName x.CaseName |> ValueOption.ofOption)
42414241

42424242
/// Get the attributes associated with the union case
42434243
member x.Attribs = x.UnionCase.Attribs
@@ -4300,7 +4300,7 @@ type RecdFieldRef =
43004300
/// Try to dereference the reference
43014301
member x.TryRecdField =
43024302
x.TyconRef.TryDeref
4303-
|> ValueOptionInternal.bind (fun tcref -> tcref.GetFieldByName x.FieldName |> ValueOptionInternal.ofOption)
4303+
|> ValueOption.bind (fun tcref -> tcref.GetFieldByName x.FieldName |> ValueOption.ofOption)
43044304

43054305
/// Get the attributes associated with the compiled property of the record field
43064306
member x.PropertyAttribs = x.RecdField.PropertyAttribs

src/Compiler/TypedTree/TypedTreeOps.fs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3526,11 +3526,11 @@ let IsMatchingFSharpAttributeOpt g attrOpt (Attrib(tcref2, _, _, _, _, _, _)) =
35263526

35273527
[<return: Struct>]
35283528
let (|ExtractAttribNamedArg|_|) nm args =
3529-
args |> List.tryPick (function AttribNamedArg(nm2, _, _, v) when nm = nm2 -> Some v | _ -> None) |> ValueOptionInternal.ofOption
3530-
3529+
args |> List.tryPick (function AttribNamedArg(nm2, _, _, v) when nm = nm2 -> Some v | _ -> None) |> ValueOption.ofOption
3530+
35313531
[<return: Struct>]
35323532
let (|ExtractILAttributeNamedArg|_|) nm (args: ILAttributeNamedArg list) =
3533-
args |> List.tryPick (function nm2, _, _, v when nm = nm2 -> Some v | _ -> None) |> ValueOptionInternal.ofOption
3533+
args |> List.tryPick (function nm2, _, _, v when nm = nm2 -> Some v | _ -> None) |> ValueOption.ofOption
35343534

35353535
[<return: Struct>]
35363536
let (|StringExpr|_|) = function Expr.Const (Const.String n, _, _) -> ValueSome n | _ -> ValueNone

src/Compiler/Utilities/illib.fs

-12
Original file line numberDiff line numberDiff line change
@@ -715,18 +715,6 @@ module Span =
715715

716716
state
717717

718-
module ValueOptionInternal =
719-
720-
let inline ofOption x =
721-
match x with
722-
| Some x -> ValueSome x
723-
| None -> ValueNone
724-
725-
let inline bind ([<InlineIfLambda>] f) x =
726-
match x with
727-
| ValueSome x -> f x
728-
| ValueNone -> ValueNone
729-
730718
module String =
731719
let make (n: int) (c: char) : string = String(c, n)
732720

src/Compiler/Utilities/illib.fsi

-6
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,6 @@ module internal ResizeArray =
243243
module internal Span =
244244
val inline exists: predicate: ('T -> bool) -> span: Span<'T> -> bool
245245

246-
module internal ValueOptionInternal =
247-
248-
val inline ofOption: x: 'a option -> 'a voption
249-
250-
val inline bind: f: ('a -> 'b voption) -> x: 'a voption -> 'b voption
251-
252246
module internal String =
253247

254248
val make: n: int -> c: char -> string

vsintegration/src/FSharp.Editor/Common/Extensions.fs

-13
Original file line numberDiff line numberDiff line change
@@ -327,19 +327,6 @@ module Option =
327327
else
328328
None
329329

330-
[<RequireQualifiedAccess>]
331-
module ValueOption =
332-
333-
let inline ofOption o =
334-
match o with
335-
| Some v -> ValueSome v
336-
| _ -> ValueNone
337-
338-
let inline toOption o =
339-
match o with
340-
| ValueSome v -> Some v
341-
| _ -> None
342-
343330
[<RequireQualifiedAccess>]
344331
module IEnumerator =
345332
let chooseV f (e: IEnumerator<'T>) =

vsintegration/tests/FSharp.Editor.Tests/CodeFixes/CodeFixTestFramework.fs

-10
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,6 @@ type Mode =
3333
| WithSettings of CodeFixesOptions
3434

3535
module ValueOption =
36-
let inline toOption o =
37-
match o with
38-
| ValueSome v -> Some v
39-
| _ -> None
40-
41-
let inline ofOption o =
42-
match o with
43-
| Some v -> ValueSome v
44-
| _ -> ValueNone
45-
4636
let inline either f y o =
4737
match o with
4838
| ValueSome v -> f v

0 commit comments

Comments
 (0)