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

Adjust IsMetadataVirtual assertion in MethodToClassRewriter #75066

Merged
merged 3 commits into from
Sep 17, 2024

Conversation

jcouv
Copy link
Member

@jcouv jcouv commented Sep 12, 2024

Fixes #73563

IsMetadataVirtual previously could either:

  • give a final answer but this required it to be called after ForceComplete (which may initialize it in SourceMemberContainerTypeSymbolSynthesizeInterfaceMemberImplementation)
  • give a partial answer (by passing ignoreInterfaceImplementationChanges)

Previously, in a scenario where comp2 references comp1 as a compilation reference and we emit comp2 and then emit comp1:

  1. emitting comp2 called MethodToClassRewriter.VisitCall which called IsMetadataVirtual on a not-yet-completed symbol from comp1. The read from IsMetadataVirtual set the "locked" flag.
  2. emitting comp1 completed that symbol from comp1 which would call EnsureMetadataVirtual. This asserted since the "locked" flag was already set

Now, the assertion in MethodToClassRewriter.VisitCall eagerly forces the completion of the symbol from comp1.

@jcouv jcouv self-assigned this Sep 12, 2024
@jcouv jcouv requested a review from a team as a code owner September 12, 2024 00:36
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Issues and PRs which have not yet been triaged by a lead label Sep 12, 2024
@jcouv jcouv marked this pull request as draft September 12, 2024 00:38
@jcouv jcouv force-pushed the fix-assertion branch 2 times, most recently from fbf84b4 to c03b894 Compare September 12, 2024 16:50
@@ -658,12 +658,24 @@ internal virtual bool IsMetadataFinal
/// signature).
/// WARN WARN WARN: We won't have a final value for this until declaration
/// diagnostics have been computed for all <see cref="SourceMemberContainerTypeSymbol"/>s, so pass
/// ignoringInterfaceImplementationChanges: true if you need a value sooner
/// option: <see cref="IsMetadataVirtualOption.IgnoreInterfaceImplementationChanges"/> true if you need a value sooner
Copy link
Contributor

@AlekseyTs AlekseyTs Sep 13, 2024

Choose a reason for hiding this comment

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

true

Delete? This looks like an artifact from the old state of the comment. #Closed

@AlekseyTs
Copy link
Contributor

AlekseyTs commented Sep 13, 2024

It looks like a couple of tests in RefStructInterfacesTests.cs were disabled because of this issue. I think we should enable them in this PR. #Closed

@AlekseyTs
Copy link
Contributor

Done with review pass (commit 1)

@jcouv
Copy link
Member Author

jcouv commented Sep 13, 2024

@dotnet/roslyn-compiler for second review. Thanks

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 Sep 16, 2024

@dotnet/roslyn-compiler for second review. Thanks

@jcouv
Copy link
Member Author

jcouv commented Sep 17, 2024

@dotnet/roslyn-compiler for second review. Thanks

@jcouv jcouv enabled auto-merge (squash) September 17, 2024 21:24
@jcouv jcouv merged commit a182892 into dotnet:main Sep 17, 2024
28 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Sep 17, 2024
@akhera99 akhera99 modified the milestones: Next, 17.12 P3 Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Assert fires in EnsureMetadataVirtual
4 participants