Skip to content

illink: Fix TypeMap instantiation not propagating to TypeMapAssociation entries#127554

Closed
Copilot wants to merge 2 commits intocopilot/fix-typemap-instantiation-issuefrom
copilot/sub-pr-127452
Closed

illink: Fix TypeMap instantiation not propagating to TypeMapAssociation entries#127554
Copilot wants to merge 2 commits intocopilot/fix-typemap-instantiation-issuefrom
copilot/sub-pr-127452

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 29, 2026

TypeMapHandler.MarkTypeMapAttribute called Annotations.MarkInstantiated(targetTypeDef) directly, bypassing MarkRequirementsForInstantiatedTypes. ProcessInstantiated was therefore never invoked from that path, so any TypeMapAssociation entry keyed on that target as source type stayed unprocessed unless the type was independently instantiated by user code.

Description

MarkStep.cs

  • MarkRequirementsForInstantiatedTypes: protected virtualprotected internal virtual so TypeMapHandler (same assembly) can call it.

TypeMapHandler.cs

  • In MarkTypeMapAttribute, route through the full instantiation pipeline:
-  _context.Annotations.MarkInstantiated(targetTypeDef);
+  _markStep.MarkRequirementsForInstantiatedTypes(targetTypeDef);

This ensures ProcessInstantiated runs, which marks associated TypeMapAssociation entries.

TypeMap.cs (test)

  • New regression case: a TypeMap<UsedTypeMap> whose target differs from its trim target, paired with a TypeMapAssociation<UsedTypeMap> whose source is that target. Only the trim target is new'd in Main; the target reaches instantiation solely via TypeMap processing. Without the fix, the TypeMapAssociation attribute is silently dropped.
  • Assertions that depend on this propagation chain are scoped with By = Tool.Trimmer so ILCompiler.Trimming.Tests passes; the equivalent ILCompiler fix is left as a follow-up (per reviewer guidance).

Note

This PR description was generated with AI assistance (GitHub Copilot).

…llow-up)

Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/cf93865a-0ed7-45ea-afc8-fbca5c23c3e5

Co-authored-by: jtschuster <36744439+jtschuster@users.noreply.github.com>
@dotnet-policy-service dotnet-policy-service Bot added the linkable-framework Issues associated with delivering a linker friendly framework label Apr 29, 2026
Copilot AI changed the title [WIP] Fix TypeMap instantiation not propagating to TypeMapAssociation entries illink: Fix TypeMap instantiation not propagating to TypeMapAssociation entries Apr 29, 2026
Copilot AI requested a review from jtschuster April 29, 2026 09:51
@github-actions github-actions Bot added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Apr 29, 2026
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @dotnet/illink
See info in area-owners.md if you want to be subscribed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Tools-ILLink .NET linker development as well as trimming analyzers linkable-framework Issues associated with delivering a linker friendly framework

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants