-
Notifications
You must be signed in to change notification settings - Fork 864
Report the resolved overload for [<CustomOperation>] keywords in QuickInfo and SymbolUse #19865
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
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
e8f9625
Add failing FCS tooltip tests for overloaded CE custom operators (#11…
5fd6c99
Show all overloads in QuickInfo for overloaded CE custom operators (#…
6c5c951
Add PR link to release notes entry
de10d70
Move release notes entry for #11612 to 11.0.100.md
4ba013a
Resolve CE [<CustomOperation>] overload sink to the actually-picked M…
T-Gro 0eb958f
Apply review feedback: simplify CE custom-op deferred sink
T-Gro 2d9b6bc
Second review round: extract helpers, drop unused params, restore joi…
T-Gro fa5b9f6
Extract deferred CO sink machinery into its own module
T-Gro e27bbd6
R1 review pass: rename extracted module + helpers, fix stale xrefs
T-Gro 109698d
R2 review pass: add prior-art comment citing TcMethodItemThen
T-Gro bd68ff6
R3 review pass: use Range.comparer for Dictionary hashing
T-Gro 217769a
Rewrite CheckComputationExpressionsCustomOps via 5-agent + 3-voter co…
T-Gro 7f5043e
Drop mutable record field, Candidates list, and MethInfosEquivByNameA…
T-Gro 0b6f597
Document and test the [mi] vs multi-element MethodGroup case
T-Gro 28ff883
Strip code comments from product code
T-Gro 7e0710e
Merge remote-tracking branch 'origin/main' into fix/issue-11612
04a4f2d
Merge remote-tracking branch 'origin/main' into fix/issue-11612
T-Gro 67bc84f
Merge remote-tracking branch 'origin/main' into fix/issue-11612
T-Gro b815763
Merge branch 'main' into fix/issue-11612
T-Gro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
src/Compiler/Checking/Expressions/CheckComputationExpressionsCustomOps.fs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. | ||
|
|
||
| /// Sinks the resolved overload's `MethInfo` at the keyword range of an overloaded | ||
| /// `[<CustomOperation>]` usage in a computation expression — fixes #11612 / #15206. | ||
| module internal FSharp.Compiler.CheckComputationExpressionsCustomOps | ||
|
|
||
| open System.Collections.Generic | ||
| open FSharp.Compiler.AccessibilityLogic | ||
| open FSharp.Compiler.Infos | ||
| open FSharp.Compiler.NameResolution | ||
| open FSharp.Compiler.Syntax | ||
| open FSharp.Compiler.Text | ||
| open FSharp.Compiler.TypedTree | ||
| open FSharp.Compiler.TypedTreeOps | ||
|
|
||
| [<NoComparison; NoEquality>] | ||
| type DeferredCustomOpSink = | ||
| { | ||
| KeywordRange: range | ||
| OpName: string | ||
| UsageText: unit -> string option | ||
| SyntheticCallRange: range | ||
| Fallback: MethInfo | ||
| NameEnv: NameResolutionEnv | ||
| AccessRights: AccessorDomain | ||
| } | ||
|
|
||
| let private makeCustomOpResolutionCapturingSink | ||
| (forwardTo: ITypecheckResultsSink) | ||
| (capturedResolutions: Dictionary<range, string * MethInfo * TyparInstantiation>) | ||
| : ITypecheckResultsSink = | ||
|
|
||
| let tryCapture (m: range) (item: Item) (tpinst: TyparInstantiation) = | ||
| match item with | ||
| | Item.MethodGroup(name, [ mi ], _) -> | ||
| match capturedResolutions.TryGetValue m with | ||
| | true, (expectedName, _, _) when name = expectedName -> capturedResolutions[m] <- (expectedName, mi, tpinst) | ||
| | _ -> () | ||
| | _ -> () | ||
|
|
||
| { new ITypecheckResultsSink with | ||
| member _.NotifyEnvWithScope(m, nenv, ad) = | ||
| forwardTo.NotifyEnvWithScope(m, nenv, ad) | ||
|
|
||
| member _.NotifyExprHasType(ty, nenv, ad, m) = | ||
| forwardTo.NotifyExprHasType(ty, nenv, ad, m) | ||
|
|
||
| member _.NotifyExprHasTypeSynthetic(ty, nenv, ad, m) = | ||
| forwardTo.NotifyExprHasTypeSynthetic(ty, nenv, ad, m) | ||
|
|
||
| member _.NotifyNameResolution(endPos, item, tpinst, occurrenceType, nenv, ad, m, replace) = | ||
| tryCapture m item tpinst | ||
| forwardTo.NotifyNameResolution(endPos, item, tpinst, occurrenceType, nenv, ad, m, replace) | ||
|
|
||
| member _.NotifyMethodGroupNameResolution(endPos, item, itemMethodGroup, tpinst, occurrenceType, nenv, ad, m, replace) = | ||
| tryCapture m item tpinst | ||
| forwardTo.NotifyMethodGroupNameResolution(endPos, item, itemMethodGroup, tpinst, occurrenceType, nenv, ad, m, replace) | ||
|
|
||
| member _.NotifyFormatSpecifierLocation(m, numArgs) = | ||
| forwardTo.NotifyFormatSpecifierLocation(m, numArgs) | ||
|
|
||
| member _.NotifyRelatedSymbolUse(m, item, kind) = | ||
| forwardTo.NotifyRelatedSymbolUse(m, item, kind) | ||
|
|
||
| member _.NotifyOpenDeclaration openDeclaration = | ||
| forwardTo.NotifyOpenDeclaration openDeclaration | ||
|
|
||
| member _.CurrentSourceText = forwardTo.CurrentSourceText | ||
|
|
||
| member _.FormatStringCheckContext = forwardTo.FormatStringCheckContext | ||
| } | ||
|
|
||
| let enqueueDeferredCustomOpSink | ||
| (sink: TcResultsSink) | ||
| (nenv: NameResolutionEnv) | ||
| (ad: AccessorDomain) | ||
| (queue: ResizeArray<DeferredCustomOpSink>) | ||
| (nm: Ident) | ||
| opName | ||
| usageText | ||
| syntheticCallRange | ||
| (fallback: MethInfo) | ||
| = | ||
| let fallbackItem = Item.CustomOperation(opName, usageText, Some fallback) | ||
|
|
||
| CallNameResolutionSink sink (nm.idRange, nenv, fallbackItem, emptyTyparInst, ItemOccurrence.Use, ad) | ||
|
|
||
| queue.Add | ||
| { | ||
| KeywordRange = nm.idRange | ||
| OpName = opName | ||
| UsageText = usageText | ||
| SyntheticCallRange = syntheticCallRange | ||
| Fallback = fallback | ||
| NameEnv = nenv | ||
| AccessRights = ad | ||
| } | ||
|
|
||
| let captureCustomOperationOverloads (sink: TcResultsSink) (queue: ResizeArray<DeferredCustomOpSink>) (action: unit -> 'T) : 'T = | ||
| match sink.CurrentSink with | ||
| | Some oldSink when queue.Count > 0 -> | ||
| let capturedResolutions = | ||
| Dictionary<range, string * MethInfo * TyparInstantiation>(Range.comparer) | ||
|
|
||
| for entry in queue do | ||
| capturedResolutions[entry.SyntheticCallRange] <- (entry.Fallback.LogicalName, entry.Fallback, emptyTyparInst) | ||
|
|
||
| let captureSink = makeCustomOpResolutionCapturingSink oldSink capturedResolutions | ||
|
|
||
| let result = | ||
| use _holder = WithNewTypecheckResultsSink(captureSink, sink) | ||
| action () | ||
|
|
||
| for entry in queue do | ||
| let _, resolved, tpinst = capturedResolutions[entry.SyntheticCallRange] | ||
|
|
||
| if not (MethInfo.MethInfosUseIdenticalDefinitions resolved entry.Fallback) then | ||
| let item = Item.CustomOperation(entry.OpName, entry.UsageText, Some resolved) | ||
|
|
||
| CallNameResolutionSinkReplacing | ||
| sink | ||
| (entry.KeywordRange, entry.NameEnv, item, tpinst, ItemOccurrence.Use, entry.AccessRights) | ||
|
|
||
| result | ||
| | _ -> action () | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.