[Parse] treat <> as a potential generic #86911
Open
+10
−4
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.
This commit changes canParseAsGenericArgumentList such that the guard no longer returns early for '<>' which is a single token when the brackets aren't seperated by a space, which fixes #68290.
Also adds a test case for this behavior and enables a generic disambiguation test with no params, since this affects all use of generics in expressions.
With this PR, code like this works:
There is some cause for concern about interacting with infix and postfix
<>operators; I think this change doesn't pose an issue for that since my read of the surrounding code is that the token is only treated like a generic if it has a disambiguating token after it, but in a future where.selfis dropped a decision might need to be made about which to prefer in some cases, and allowingT<>.selfnow would make it especially surprising to not allowT<>in that future.SwiftParser explicitly excludes this case and will need to be updated if allowing this is the direction to go in.