You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix AttributeUsage.AllowMultiple not inherited for C#-defined attributes (#19315)
* Fix AttributeUsage.AllowMultiple not inherited for C#-defined attributes (#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>
* Use O(1) WellKnownILAttributes fast-path for AttributeUsage lookup
Switch TryFindAttributeUsageAttribute to use tryBindTyconRefAttributeCore
with ValueSome WellKnownILAttributes.AttributeUsageAttribute, enabling
O(1) early exit on IL types that lack [AttributeUsage]. This avoids a
full linear attribute scan at each level of the inheritance chain walk.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Tomas Grosup <Tomas.Grosup@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix `AttributeUsage.AllowMultiple` not being inherited for attributes subclassed in C#. ([Issue #17107](https://github.com/dotnet/fsharp/issues/17107), [PR #19315](https://github.com/dotnet/fsharp/pull/19315))
|> withSingleDiagnostic (Error 429, Line 4, Col 10, Line 4, Col 15,"The attribute type 'ChildAttribute' has 'AllowMultiple=false'. Multiple instances of this attribute cannot be attached to a single language element.")
|> withSingleDiagnostic (Error 429, Line 4, Col 10, Line 4, Col 15,"The attribute type 'ChildAttribute' has 'AllowMultiple=false'. Multiple instances of this attribute cannot be attached to a single language element.")
169
+
170
+
[<FSharp.Test.FactForNETCOREAPP>]
171
+
let``F# attribute subclass of C# base inherits AllowMultiple true`` ()=
0 commit comments