-
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
Rectify async checks logic in presence of AsyncMethodBuilder attribute #65352
Conversation
@@ -1102,7 +1102,7 @@ protected void AsyncMethodChecks(bool verifyReturnType, Location errorLocation, | |||
|
|||
if (this.HasAsyncMethodBuilderAttribute(out _)) | |||
{ | |||
hasErrors |= MessageID.IDS_AsyncMethodBuilderOverride.CheckFeatureAvailability(diagnostics, this.DeclaringCompilation, errorLocation); | |||
hasErrors |= !MessageID.IDS_AsyncMethodBuilderOverride.CheckFeatureAvailability(diagnostics, this.DeclaringCompilation, errorLocation); |
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.
!MessageID.IDS_AsyncMethodBuilderOverride.CheckFeatureAvailability(diagnostics, this.DeclaringCompilation, errorLocation);
In my opinion registering language version check in hasErrors
is not the right thing to do. Wrong language version shouldn't change the analysis, and here, it clearly does. #Closed
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.
In that case, should
roslyn/src/Compilers/CSharp/Portable/Binder/ForEachLoopBinder.cs
Lines 226 to 230 in 9c04fee
var messageId = IsAsync ? MessageID.IDS_FeatureExtensionGetAsyncEnumerator : MessageID.IDS_FeatureExtensionGetEnumerator; | |
hasErrors |= !messageId.CheckFeatureAvailability( | |
diagnostics, | |
Compilation, | |
collectionExpr.Syntax.Location); |
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.
@Youssef1313 That seems a good idea. There's at least one check there that is conditional on hasErrors
.
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.
Filed #65363
Done with review pass (commit 1) |
} | ||
"""; | ||
|
||
var compilation = CreateCompilation(source, parseOptions: useCSharp9 ? TestOptions.Regular9 : TestOptions.Regular10, targetFramework: TargetFramework.Net70); |
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.
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 think Regular10 is better. That's what we usually do for explicit LangVer tests that verify the boundary when the feature was introduced.
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.
LGTM (commit 2)
@dotnet/roslyn-compiler for second review (one-line fix). Thanks |
Fixes #60332