Fix ICE in BuildDisposableCleanup when Dispose extension methods are in scope#19568
Fix ICE in BuildDisposableCleanup when Dispose extension methods are in scope#19568
Conversation
…in scope Use AtMostOneResult to leverage existing intrinsic-over-extension priority in AllMethInfosOfTypeInScope, matching how regular method calls resolve Dispose. Agent-Logs-Url: https://github.com/dotnet/fsharp/sessions/ebba43f1-81b6-417c-9138-f5867056fd94 Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
❗ Release notes requiredCaution No release notes found for the changed paths (see table below). Please make sure to add an entry with an informative description of the change as well as link to this pull request, issue and language suggestion if applicable. Release notes for this repository are based on Keep A Changelog format. The following format is recommended for this repository:
If you believe that release notes are not necessary for this PR, please add NO_RELEASE_NOTES label to the pull request. You can open this PR in browser to add release notes: open in github.dev
|
BuildDisposableCleanupcrashes with an ICE ("Couldn't find Dispose on IDisposable, or it was overloaded") when a C#-styleDisposeextension method is in scope alongside the intrinsicIDisposable.Dispose.Cause
The lookup uses
TryFindIntrinsicOrExtensionMethInfowithResultCollectionSettings.AllResults, which collects both intrinsic and extension methods. The subsequent| [x] -> xmatch fails when >1 candidate is returned.Fix
Switch to
ResultCollectionSettings.AtMostOneResult. This leverages the existing priority mechanism inAllMethInfosOfTypeInScope— when intrinsic methods are found, extension methods are skipped. Same priority rules as a hand-written(x :> IDisposable).Dispose()call.