Skip to content

Commit bae73d3

Browse files
authored
Symbols: try to use ValReprInfoForDisplay in Mfv.CurriedParameterGroups (#18124)
1 parent beee039 commit bae73d3

File tree

5 files changed

+49
-7
lines changed

5 files changed

+49
-7
lines changed

docs/release-notes/.FSharp.Compiler.Service/9.0.200.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* Add missing nullable-metadata for C# consumers of records,exceptions and DU subtypes generated from F# code. [PR #18079](https://github.com/dotnet/fsharp/pull/18079)
1818
* Fix a race condition in file book keeping in the compiler service ([#18008](https://github.com/dotnet/fsharp/pull/18008))
1919
* Fix trimming '%' characters when lowering interpolated string to a concat call [PR #18123](https://github.com/dotnet/fsharp/pull/18123)
20+
* Symbols: try to use ValReprInfoForDisplay in Mfv.CurriedParameterGroups ([PR #18124](https://github.com/dotnet/fsharp/pull/18124))
2021
* Shim/file system: fix leaks of the shim [PR #18144](https://github.com/dotnet/fsharp/pull/18144)
2122

2223
### Added

src/Compiler/Symbols/Symbols.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2135,7 +2135,7 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
21352135
|> makeReadOnlyCollection
21362136

21372137
| V v ->
2138-
match v.ValReprInfo with
2138+
match tryGetArityOfValForDisplay v.Deref with
21392139
| None ->
21402140
let _, tau = v.GeneralizedType
21412141
if isFunTy cenv.g tau then

src/Compiler/TypedTree/TypedTreeBasics.fs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,12 @@ let arityOfVal (v: Val) =
6262
| None -> ValReprInfo.emptyValData
6363
| Some info -> info
6464

65+
let tryGetArityOfValForDisplay (v: Val) =
66+
v.ValReprInfoForDisplay
67+
|> Option.orElseWith (fun _ -> v.ValReprInfo)
68+
6569
let arityOfValForDisplay (v: Val) =
66-
match v.ValReprInfoForDisplay with
67-
| Some info -> info
68-
| None ->
69-
match v.ValReprInfo with
70-
| None -> ValReprInfo.emptyValData
71-
| Some info -> info
70+
tryGetArityOfValForDisplay v |> Option.defaultValue ValReprInfo.emptyValData
7271

7372
let tupInfoRef = TupInfo.Const false
7473

src/Compiler/TypedTree/TypedTreeBasics.fsi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ val nameOfVal: v: Val -> string
4545

4646
val arityOfVal: v: Val -> ValReprInfo
4747

48+
val tryGetArityOfValForDisplay: v: Val -> ValReprInfo option
49+
4850
val arityOfValForDisplay: v: Val -> ValReprInfo
4951

5052
val tupInfoRef: TupInfo

tests/FSharp.Compiler.Service.Tests/Symbols.fs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,46 @@ type T() =
787787

788788
assertRange (9, 19) (9, 20) mProp
789789

790+
791+
[<Fact>]
792+
let ``Repr info 01`` () =
793+
let _, checkResults =
794+
getParseAndCheckResults """
795+
module Module
796+
797+
let f x = ()
798+
"""
799+
let mfv = findSymbolByName "f" checkResults :?> FSharpMemberOrFunctionOrValue
800+
let param = mfv.CurriedParameterGroups[0][0]
801+
param.Name.Value |> shouldEqual "x"
802+
803+
[<Fact>]
804+
let ``Repr info 02`` () =
805+
let _, checkResults =
806+
getParseAndCheckResults """
807+
module Module
808+
809+
do
810+
let f x = ()
811+
()
812+
"""
813+
let mfv = findSymbolByName "f" checkResults :?> FSharpMemberOrFunctionOrValue
814+
let param = mfv.CurriedParameterGroups[0][0]
815+
param.Name.Value |> shouldEqual "x"
816+
817+
[<Fact>]
818+
let ``Repr info 03`` () =
819+
let _, checkResults =
820+
getParseAndCheckResults """
821+
module Module
822+
823+
type T() =
824+
let f x = ()
825+
"""
826+
let mfv = findSymbolByName "f" checkResults :?> FSharpMemberOrFunctionOrValue
827+
let param = mfv.CurriedParameterGroups[0][0]
828+
param.Name.Value |> shouldEqual "x"
829+
790830
module GetValSignatureText =
791831
let private assertSignature (expected:string) source (lineNumber, column, line, identifier) =
792832
let _, checkResults = getParseAndCheckResults source

0 commit comments

Comments
 (0)