Stop Simplifier.ReduceAsync removing empty arg lists from delegates#40922
Merged
mavasani merged 15 commits intodotnet:masterfrom Feb 3, 2020
Merged
Conversation
Drawbacks: * Only covers cases where the invocation is nested within an executable statement * Performs abysmally due to creating a whole speculative semantic model for the vast majority of invocations, and additionally using GetOperation which is quite slow in general At some point amongst all the code that runs there is presumably a crucial function which has the rules for binding a name-type syntax into an invocation. Ideally we'd find a way to call just that function here on invocationExpression.Expression
a0e56e1 to
4685e06
Compare
(even without an arg list) It's possible there are some other cases when VB will happily invoke something without an arg list, but since i can't find the relevant spec or code, I'm erring on the side of caution
4685e06 to
37a230c
Compare
src/Workspaces/VisualBasic/Portable/Extensions/InvocationExpressionSyntaxExtensions.vb
Outdated
Show resolved
Hide resolved
src/EditorFeatures/Test2/Simplification/ParenthesisSimplificationTests.vb
Outdated
Show resolved
Hide resolved
src/EditorFeatures/Test2/Simplification/ParenthesisSimplificationTests.vb
Show resolved
Hide resolved
…ionTests.vb Co-Authored-By: CyrusNajmabadi <[email protected]>
Contributor
This file seems reasonable. |
CyrusNajmabadi
approved these changes
Jan 12, 2020
Contributor
CyrusNajmabadi
left a comment
There was a problem hiding this comment.
LGTM if we break the test into a few separate tests.
Contributor
|
From this point on, can you avoid force pushing? It makes it difficult to review things . Thanks! |
Contributor
|
Thanks for the PR @GrahamTheCoder ! |
Therefore we can't know it's safe to remove parentheses since it could be a delegate
This is to allow "TestInsertCallIfNecessary3()" to continue to pass. Note that the test result isn't fully simplified since it says: Call (Sub() Exit Sub) instead of Call Sub() Exit Sub This is outside the scope of this PR
Contributor
Author
|
I'll try to have a look at the other affected tests in the next day or so. Looks like |
There is no parameterless Console.Write hence it doesn't resolve, and Program doesn't exist in the context at all Don't think it's worth considering CandidateSymbols since they won't always be correct Expanding and reducing stuff that doesn't compile sounds generally risky. In a future PR perhaps the expander shouldn't add the parentheses if it can't resolve the symbol.
If it wasn't invokable it wouldn't be valid at this point
This reverts commit 3787058.
src/Workspaces/VisualBasic/Portable/Extensions/InvocationExpressionSyntaxExtensions.vb
Outdated
Show resolved
Hide resolved
Contributor
Author
|
I'm assuming this is now just in a queue to look at - let me know if there's anything else I can do to help it along |
mavasani
approved these changes
Feb 3, 2020
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #40442