Skip to content

Symbols: try to use ValReprInfoForDisplay in Mfv.CurriedParameterGroups #18124

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

Merged
merged 4 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/9.0.200.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* 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)
* Fix a race condition in file book keeping in the compiler service ([#18008](https://github.com/dotnet/fsharp/pull/18008))
* Fix trimming '%' characters when lowering interpolated string to a concat call [PR #18123](https://github.com/dotnet/fsharp/pull/18123)
* Symbols: try to use ValReprInfoForDisplay in Mfv.CurriedParameterGroups ([PR #18124](https://github.com/dotnet/fsharp/pull/18124))
* Shim/file system: fix leaks of the shim [PR #18144](https://github.com/dotnet/fsharp/pull/18144)

### Added
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/Symbols/Symbols.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2135,7 +2135,7 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
|> makeReadOnlyCollection

| V v ->
match v.ValReprInfo with
match tryGetArityOfValForDisplay v.Deref with
| None ->
let _, tau = v.GeneralizedType
if isFunTy cenv.g tau then
Expand Down
11 changes: 5 additions & 6 deletions src/Compiler/TypedTree/TypedTreeBasics.fs
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,12 @@ let arityOfVal (v: Val) =
| None -> ValReprInfo.emptyValData
| Some info -> info

let tryGetArityOfValForDisplay (v: Val) =
v.ValReprInfoForDisplay
|> Option.orElseWith (fun _ -> v.ValReprInfo)

let arityOfValForDisplay (v: Val) =
match v.ValReprInfoForDisplay with
| Some info -> info
| None ->
match v.ValReprInfo with
| None -> ValReprInfo.emptyValData
| Some info -> info
tryGetArityOfValForDisplay v |> Option.defaultValue ValReprInfo.emptyValData

let tupInfoRef = TupInfo.Const false

Expand Down
2 changes: 2 additions & 0 deletions src/Compiler/TypedTree/TypedTreeBasics.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ val nameOfVal: v: Val -> string

val arityOfVal: v: Val -> ValReprInfo

val tryGetArityOfValForDisplay: v: Val -> ValReprInfo option

val arityOfValForDisplay: v: Val -> ValReprInfo

val tupInfoRef: TupInfo
Expand Down
40 changes: 40 additions & 0 deletions tests/FSharp.Compiler.Service.Tests/Symbols.fs
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,46 @@ type T() =

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


[<Fact>]
let ``Repr info 01`` () =
let _, checkResults =
getParseAndCheckResults """
module Module

let f x = ()
"""
let mfv = findSymbolByName "f" checkResults :?> FSharpMemberOrFunctionOrValue
let param = mfv.CurriedParameterGroups[0][0]
param.Name.Value |> shouldEqual "x"

[<Fact>]
let ``Repr info 02`` () =
let _, checkResults =
getParseAndCheckResults """
module Module

do
let f x = ()
()
"""
let mfv = findSymbolByName "f" checkResults :?> FSharpMemberOrFunctionOrValue
let param = mfv.CurriedParameterGroups[0][0]
param.Name.Value |> shouldEqual "x"

[<Fact>]
let ``Repr info 03`` () =
let _, checkResults =
getParseAndCheckResults """
module Module

type T() =
let f x = ()
"""
let mfv = findSymbolByName "f" checkResults :?> FSharpMemberOrFunctionOrValue
let param = mfv.CurriedParameterGroups[0][0]
param.Name.Value |> shouldEqual "x"

module GetValSignatureText =
let private assertSignature (expected:string) source (lineNumber, column, line, identifier) =
let _, checkResults = getParseAndCheckResults source
Expand Down
Loading