Skip to content

Fix AttributeUsage.AllowMultiple not inherited for C#-defined attributes#19583

Closed
T-Gro wants to merge 1 commit intomainfrom
fix-17107-allowmultiple-inherited-csharp
Closed

Fix AttributeUsage.AllowMultiple not inherited for C#-defined attributes#19583
T-Gro wants to merge 1 commit intomainfrom
fix-17107-allowmultiple-inherited-csharp

Conversation

@T-Gro
Copy link
Copy Markdown
Member

@T-Gro T-Gro commented Apr 14, 2026

Description

The F# compiler was not walking the inheritance chain for IL-imported (C#) attribute types when checking AllowMultiple. The supersOfTyconRef function only used tcaug_super, which is not populated for IL types.

This fix simplifies TryFindAttributeUsageAttribute to only check the current type definition, and adds a recursive allowsMultiple function in PostInferenceChecks that walks the inheritance chain using GetSuperTypeOfType, which correctly handles both F# and IL-imported types via ILTypeDef.Extends.

Based on work by @edgarfgp in PR #19315. Rebased onto main after the TypedTreeOps split (#19521).

Fixes #17107

Checklist

  • Test cases added
  • Release notes entry updated

…tes (#17107)

The F# compiler was not walking the inheritance chain for IL-imported (C#)
attribute types when checking AllowMultiple. The supersOfTyconRef function
only used tcaug_super, which is not populated for IL types.

This fix simplifies TryFindAttributeUsageAttribute to only check the
current type, and adds a recursive allowsMultiple function in
PostInferenceChecks that walks the inheritance chain using
GetSuperTypeOfType, which correctly handles both F# and IL-imported types.

Based on work by edgarfgp in PR #19315.
Fixes #17107

Co-authored-by: edgarfgp <31915729+edgarfgp@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

❗ Release notes required


✅ Found changes and release notes in following paths:

Warning

No PR link found in some release notes, please consider adding it.

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/11.0.100.md No current pull request URL (#19583) found, please consider adding it

@T-Gro T-Gro closed this Apr 14, 2026
@T-Gro T-Gro deleted the fix-17107-allowmultiple-inherited-csharp branch April 14, 2026 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

AttributeUsage.AllowMultiple is not inherited for attributes defined (subclassed) in C#

1 participant