Skip to content

Commit 487df5c

Browse files
auduchinokbaronfel
authored andcommitted
Add FSharpUnionCase.HasFields (#7841)
1 parent 3acf6df commit 487df5c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/fsharp/symbols/Symbols.fs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,9 +781,13 @@ and FSharpUnionCase(cenv, v: UnionCaseRef) =
781781
checkIsResolved()
782782
v.Range
783783

784+
member __.HasFields =
785+
if isUnresolved() then false else
786+
v.UnionCase.RecdFieldsArray.Length <> 0
787+
784788
member __.UnionCaseFields =
785789
if isUnresolved() then makeReadOnlyCollection [] else
786-
v.UnionCase.RecdFields |> List.mapi (fun i _ -> FSharpField(cenv, FSharpFieldData.Union (v, i))) |> makeReadOnlyCollection
790+
v.UnionCase.RecdFieldsArray |> Array.mapi (fun i _ -> FSharpField(cenv, FSharpFieldData.Union (v, i))) |> makeReadOnlyCollection
787791

788792
member __.ReturnType =
789793
checkIsResolved()

src/fsharp/symbols/Symbols.fsi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,9 @@ and [<Class>] public FSharpUnionCase =
382382
/// Get the range of the name of the case
383383
member DeclarationLocation : range
384384

385+
/// Indicates if the union case has field definitions
386+
member HasFields: bool
387+
385388
/// Get the data carried by the case.
386389
member UnionCaseFields: IList<FSharpField>
387390

0 commit comments

Comments
 (0)