-
Notifications
You must be signed in to change notification settings - Fork 795
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
Wrap arg in parens when needed when adding new
keyword
#18179
Conversation
❗ Release notes required
|
920a375
to
8730a03
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, Brian, this was annoying. The fix is not trivial anymore so thanks for solid testing :)
Description
new
keyword" code fix to wrap the constructor argument in parentheses when needed, so that applying the fix does not cause Inconsistent handling of arguments for disposable types #15622.This change incidentally also prevents the code fix from suggesting a "fix" that would be invalid in various scenarios,1 e.g.:
Checklist
Footnotes
We could in theory update the code fix to suggest
new (Disposable)(arg)
(or evennew Disposable(arg)
),xs |> List.map (fun x -> new Disposable(x))
, etc., for such scenarios, but I considered that out of scope for this PR—and perhaps altogether, since transformations likexs |> List.map (fun x -> new Disposable(x))
also may not be valid, depending on the type of the constructor argument! For example, ifxs
is aunit list
, then transformingxs |> List.map Disposable
toxs |> List.map (fun x -> new Disposable(x))
is not valid. ↩