Skip to content
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

Merged
merged 2 commits into from
Nov 11, 2022

Conversation

jcouv
Copy link
Member

@jcouv jcouv commented Nov 11, 2022

Fixes #60332

@jcouv jcouv self-assigned this Nov 11, 2022
@jcouv jcouv marked this pull request as ready for review November 11, 2022 06:38
@jcouv jcouv requested a review from a team as a code owner November 11, 2022 06:38
@@ -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);
Copy link
Contributor

@AlekseyTs AlekseyTs Nov 11, 2022

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, should

var messageId = IsAsync ? MessageID.IDS_FeatureExtensionGetAsyncEnumerator : MessageID.IDS_FeatureExtensionGetEnumerator;
hasErrors |= !messageId.CheckFeatureAvailability(
diagnostics,
Compilation,
collectionExpr.Syntax.Location);
be tracked in a new issue to update as well?

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed #65363

@AlekseyTs
Copy link
Contributor

Done with review pass (commit 1)

@jcouv jcouv requested a review from AlekseyTs November 11, 2022 18:13
}
""";

var compilation = CreateCompilation(source, parseOptions: useCSharp9 ? TestOptions.Regular9 : TestOptions.Regular10, targetFramework: TargetFramework.Net70);
Copy link
Contributor

@AlekseyTs AlekseyTs Nov 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regular10

Regular? #ByDesign

Copy link
Member Author

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.

Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (commit 2)

@jcouv
Copy link
Member Author

jcouv commented Nov 11, 2022

@dotnet/roslyn-compiler for second review (one-line fix). Thanks

@jcouv jcouv merged commit f857e99 into dotnet:main Nov 11, 2022
@jcouv jcouv deleted the async-check branch November 11, 2022 22:11
@ghost ghost added this to the Next milestone Nov 11, 2022
@jcouv jcouv modified the milestones: Next, 17.5 Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ref/out parameters in async methods with AsyncMethodBuilderAttribute
4 participants