-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Fix parsing of generics in casts. #69519
Conversation
@@ -5824,7 +5824,7 @@ private ScanTypeArgumentListKind ScanTypeArgumentList(NameOptions options) | |||
// Note: we check if we got 'MustBeType' which triggers for predefined types, | |||
// (int, string, etc.), or array types (Goo[], A<T>[][] etc.), or pointer types | |||
// of things that must be types (int*, void**, etc.). | |||
isDefinitelyTypeArgumentList = DetermineIfDefinitelyTypeArgumentList(isDefinitelyTypeArgumentList); | |||
isDefinitelyTypeArgumentList = isDefinitelyTypeArgumentList || this.CurrentToken.Kind is SyntaxKind.CommaToken or SyntaxKind.GreaterThanToken; |
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.
i inlined this method as i found it easier to reason about just looking at teh check directly in code.
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.
note: tehre are further changes i'd like to make to this method for clarity/correctness/invariants. but i'm trying to keep the PR small for the purposes of fixing this important issue.
@RikkiGibson @cston ptal asap. |
src/Compilers/CSharp/Test/Syntax/Parsing/CollectionExpressionParsingTests.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Syntax/Parsing/CollectionExpressionParsingTests.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Syntax/Parsing/CollectionExpressionParsingTests.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Syntax/Parsing/CollectionExpressionParsingTests.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Syntax/Parsing/CollectionExpressionParsingTests.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Syntax/Parsing/CollectionExpressionParsingTests.cs
Outdated
Show resolved
Hide resolved
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
{ | ||
if (!isDefinitelyTypeArgumentList) | ||
// If we have `X<Y>)` then this would definitely be a type argument list. | ||
isDefinitelyTypeArgumentList = isDefinitelyTypeArgumentList || this.CurrentToken.Kind is SyntaxKind.CloseParenToken; |
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.
Could you help me understand in which scenarios we are depending on this line versus line 5874 for correct behavior?
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.
so 5874 related to incomplete nested generics. so if you had (X<Y<Z>)
(note the lack of the last >
) .
This line applies when you have (X<Y>)
or (X<Y<Z>>)
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!
Fixes #69508