Skip to content

Commit 24b080b

Browse files
committed
Restore behavior for CompilerMessageAttribute
1 parent b455c56 commit 24b080b

File tree

3 files changed

+16
-20
lines changed

3 files changed

+16
-20
lines changed

src/Compiler/Checking/AttributeChecking.fs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -478,13 +478,11 @@ let CheckFSharpAttributesForObsolete (g:TcGlobals) attribs =
478478
// like Span and ReadOnlySpan in completion lists due to their dual attributes.
479479
not (HasFSharpAttributeOpt g g.attrib_IsByRefLikeAttribute_opt attribs)
480480

481-
/// Indicate if a list of F# attributes contains 'ObsoleteAttribute'. Used to suppress the item in intellisense.
482-
/// Also check the attributes for CompilerMessageAttribute, which has an IsHidden argument that allows
483-
/// items to be suppressed from intellisense.
484-
let CheckFSharpAttributesForUnseen g attribs _m =
481+
/// Indicates if a list of F# attributes contains 'ObsoleteAttribute' or CompilerMessageAttribute', which has an IsHidden argument
482+
/// May be used to suppress items from intellisense.
483+
let CheckFSharpAttributesForUnseen g attribs _m allowObsolete =
485484
not (isNil attribs) &&
486-
(CheckFSharpAttributesForObsolete g attribs ||
487-
CheckFSharpAttributesForHidden g attribs)
485+
(not allowObsolete && CheckFSharpAttributesForObsolete g attribs || CheckFSharpAttributesForHidden g attribs)
488486

489487
#if !NO_TYPEPROVIDERS
490488
/// Indicate if a list of provided attributes contains 'ObsoleteAttribute'. Used to suppress the item in intellisense.
@@ -579,13 +577,11 @@ let CheckMethInfoAttributes g m tyargsOpt (minfo: MethInfo) =
579577
/// Used to suppress the item in intellisense.
580578
let MethInfoIsUnseen g (m: range) (ty: TType) minfo allowObsolete =
581579
let isUnseenByObsoleteAttrib () =
582-
if allowObsolete then false else
583-
584580
match BindMethInfoAttributes m minfo
585-
(fun ilAttribs -> Some(CheckILAttributesForUnseen g ilAttribs m))
586-
(fun fsAttribs -> Some(CheckFSharpAttributesForUnseen g fsAttribs m))
581+
(fun ilAttribs -> Some(not allowObsolete && CheckILAttributesForUnseen g ilAttribs m))
582+
(fun fsAttribs -> Some(CheckFSharpAttributesForUnseen g fsAttribs m allowObsolete))
587583
#if !NO_TYPEPROVIDERS
588-
(fun provAttribs -> Some(CheckProvidedAttributesForUnseen provAttribs m))
584+
(fun provAttribs -> Some(not allowObsolete && CheckProvidedAttributesForUnseen provAttribs m))
589585
#else
590586
(fun _provAttribs -> None)
591587
#endif
@@ -622,14 +618,14 @@ let MethInfoIsUnseen g (m: range) (ty: TType) minfo allowObsolete =
622618

623619
/// Indicate if a property has 'Obsolete' or 'CompilerMessageAttribute'.
624620
/// Used to suppress the item in intellisense.
625-
let PropInfoIsUnseen m pinfo =
621+
let PropInfoIsUnseen m allowObsolete pinfo =
626622
match pinfo with
627623
| ILProp (ILPropInfo(_, pdef) as ilpinfo) ->
628624
// Properties on .NET tuple types are resolvable but unseen
629625
isAnyTupleTy pinfo.TcGlobals ilpinfo.ILTypeInfo.ToType ||
630626
CheckILAttributesForUnseen pinfo.TcGlobals pdef.CustomAttrs m
631627
| FSProp (g, _, Some vref, _)
632-
| FSProp (g, _, _, Some vref) -> CheckFSharpAttributesForUnseen g vref.Attribs m
628+
| FSProp (g, _, _, Some vref) -> CheckFSharpAttributesForUnseen g vref.Attribs m allowObsolete
633629
| FSProp _ -> failwith "CheckPropInfoAttributes: unreachable"
634630
#if !NO_TYPEPROVIDERS
635631
| ProvidedProp (_amap, pi, m) ->

src/Compiler/Checking/AttributeChecking.fsi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ val CheckFSharpAttributesForHidden: g: TcGlobals -> attribs: Attrib list -> bool
6868

6969
val CheckFSharpAttributesForObsolete: g: TcGlobals -> attribs: Attrib list -> bool
7070

71-
val CheckFSharpAttributesForUnseen: g: TcGlobals -> attribs: Attrib list -> _m: 'a -> bool
71+
val CheckFSharpAttributesForUnseen: g: TcGlobals -> attribs: Attrib list -> _m: 'a -> allowObsolete: bool -> bool
7272

7373
val CheckPropInfoAttributes: pinfo: PropInfo -> m: range -> OperationResult<unit>
7474

@@ -79,7 +79,7 @@ val CheckMethInfoAttributes:
7979

8080
val MethInfoIsUnseen: g: TcGlobals -> m: range -> ty: TType -> minfo: MethInfo -> allowObsolete: bool -> bool
8181

82-
val PropInfoIsUnseen: m: 'a -> pinfo: PropInfo -> bool
82+
val PropInfoIsUnseen: m: 'a -> allowObsolete: bool -> pinfo: PropInfo -> bool
8383

8484
val CheckEntityAttributes: g: TcGlobals -> tcref: TyconRef -> m: range -> OperationResult<unit>
8585

src/Compiler/Checking/NameResolution.fs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4275,19 +4275,19 @@ let IsTyconUnseenObsoleteSpec ad g amap m (x: TyconRef) allowObsolete =
42754275
(if x.IsILTycon then
42764276
CheckILAttributesForUnseen g x.ILTyconRawMetadata.CustomAttrs m
42774277
else
4278-
CheckFSharpAttributesForUnseen g x.Attribs m))
4278+
CheckFSharpAttributesForUnseen g x.Attribs m allowObsolete))
42794279

42804280
let IsTyconUnseen ad g amap m allowObsolete (x: TyconRef) = IsTyconUnseenObsoleteSpec ad g amap m x allowObsolete
42814281

42824282
let IsValUnseen ad g m allowObsolete (v: ValRef) =
42834283
v.IsCompilerGenerated ||
42844284
v.Deref.IsClassConstructor ||
42854285
not (IsValAccessible ad v) ||
4286-
not allowObsolete && CheckFSharpAttributesForUnseen g v.Attribs m
4286+
not allowObsolete && CheckFSharpAttributesForUnseen g v.Attribs m allowObsolete
42874287

42884288
let IsUnionCaseUnseen ad g amap m allowObsolete (ucref: UnionCaseRef) =
42894289
not (IsUnionCaseAccessible amap m ad ucref) ||
4290-
not allowObsolete && (IsTyconUnseen ad g amap m allowObsolete ucref.TyconRef || CheckFSharpAttributesForUnseen g ucref.Attribs m)
4290+
not allowObsolete && (IsTyconUnseen ad g amap m allowObsolete ucref.TyconRef || CheckFSharpAttributesForUnseen g ucref.Attribs m allowObsolete)
42914291

42924292
let ItemIsUnseen ad g amap m allowObsolete item =
42934293
match item with
@@ -4423,7 +4423,7 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv (completionTargets: Reso
44234423
if allowObsolete then pinfosIncludingUnseen else
44244424

44254425
pinfosIncludingUnseen
4426-
|> List.filter (fun x -> not (PropInfoIsUnseen m x))
4426+
|> List.filter (fun x -> not (PropInfoIsUnseen m allowObsolete x))
44274427

44284428
let minfoFilter (suppressedMethNames: Zset<_>) (minfo: MethInfo) =
44294429
let isApplicableMeth =
@@ -5127,7 +5127,7 @@ let ResolveCompletionsInTypeForItem (ncenv: NameResolver) nenv m ad statics ty (
51275127

51285128
let pinfos =
51295129
pinfosIncludingUnseen
5130-
|> List.filter (fun x -> not (PropInfoIsUnseen m x))
5130+
|> List.filter (fun x -> not (PropInfoIsUnseen m false x))
51315131

51325132
let minfoFilter (suppressedMethNames: Zset<_>) (minfo: MethInfo) =
51335133
// Only show the Finalize, MemberwiseClose etc. methods on System.Object for values whose static type really is

0 commit comments

Comments
 (0)