Skip to content

Conversation

@sbomer
Copy link
Member

@sbomer sbomer commented Jul 18, 2022

Fixes #2826

This also fixes an unrelated issue I discovered where in Release mode, the compiler can generate struct closure environments that will never get instantiated via a ctor call. I added a testcase that runs the CompilerGeneratedTypes tests in Release mode to cover this.

sbomer added 5 commits July 18, 2022 14:53
- For a static closure shared by multiple methods
- Run existing tests in Release mode too
@sbomer sbomer marked this pull request as ready for review July 21, 2022 17:58
@sbomer sbomer requested a review from marek-safar as a code owner July 21, 2022 17:58
@sbomer sbomer requested review from agocke and vitek-karas July 21, 2022 18:00
sbomer and others added 2 commits July 25, 2022 09:28
@agocke
Copy link
Member

agocke commented Jul 25, 2022

Sorry, not sure I'm fully following the change. How does it prevent a sample like https://sharplab.io/#v2:D4AQTAjAsAUCDMACciDCAeAKgPkQb1kSMUOIWQBZEBZACgEp9TiyBWLXAMwkQF5EGfXABMAppwCGAVwA2AF1qZ6AbmYtk7HIk5g+AxrxHjp8xSrUBfWBaA== from producing a lot of warnings or failing? Since there's two constructor calls to a single type.

Copy link
Member

@agocke agocke left a comment

Choose a reason for hiding this comment

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

Ah, it looks like my case always goes through static fields. LGTM

@sbomer sbomer merged commit b883ec2 into dotnet:main Jul 26, 2022
agocke pushed a commit to dotnet/runtime that referenced this pull request Nov 16, 2022
This discovers type parameter mappings between generic type
parameters and static closures which reference them. It detects
the closure environment by scanning for stsfld instructions which
reference generic closure types. There may be multiple methods
associated with the same static closure, so this case doesn't
produce warnings.

This also fixes an unrelated issue where in Release mode, the
compiler can generate struct closure environments that will never
get instantiated via a ctor call. A new testcase runs the
CompilerGeneratedTypes tests in Release mode to cover this.


Commit migrated from dotnet/linker@b883ec2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support mapping type parameters for C# static closures in linker

3 participants