Skip to content

Commit 2f4b4f8

Browse files
Copilotabonie
andcommitted
Fix IsByRefLikeAttribute exclusion for IL types in completion filtering
The original fix only handled F# types through CheckFSharpAttributesForObsolete but types like Span<T> and ReadOnlySpan<T> are .NET types that go through IL attribute checking. Updated CheckILAttributesForUnseen to also exclude types with IsByRefLikeAttribute from being considered obsolete, ensuring they appear in completion lists despite having ObsoleteAttribute. Co-authored-by: abonie <[email protected]>
1 parent eb6e261 commit 2f4b4f8

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/Compiler/Checking/AttributeChecking.fs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,17 @@ let private CheckProvidedAttributes (g: TcGlobals) m (provAttribs: Tainted<IProv
441441
/// Indicate if a list of IL attributes contains 'ObsoleteAttribute'. Used to suppress the item in intellisense.
442442
let CheckILAttributesForUnseen (g: TcGlobals) cattrs _m =
443443
let (AttribInfo(tref, _)) = g.attrib_SystemObsolete
444-
Option.isSome (TryDecodeILAttribute tref cattrs)
444+
let hasObsolete = Option.isSome (TryDecodeILAttribute tref cattrs)
445+
if hasObsolete then
446+
// Exclude types marked with IsByRefLikeAttribute from being considered obsolete,
447+
// even if ObsoleteAttribute is present. This avoids improper suppression of types
448+
// like Span and ReadOnlySpan in completion lists due to their dual attributes.
449+
match g.attrib_IsByRefLikeAttribute_opt with
450+
| Some (AttribInfo(isByRefLikeTref, _)) ->
451+
not (Option.isSome (TryDecodeILAttribute isByRefLikeTref cattrs))
452+
| None -> true
453+
else
454+
false
445455

446456
/// Checks the attributes for CompilerMessageAttribute, which has an IsHidden argument that allows
447457
/// items to be suppressed from intellisense.

0 commit comments

Comments
 (0)