Skip to content

Commit 86b3242

Browse files
committed
add ImplementedAbstractSignatures on FSharpMemberOrFunctionOrValue
1 parent dd4f98d commit 86b3242

File tree

3 files changed

+118
-0
lines changed

3 files changed

+118
-0
lines changed

src/fsharp/infos.fs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,9 @@ type ValRef with
375375
| TSlotSig(_,oty,_,_,_,_) :: _ -> isInterfaceTy g oty
376376
| [] -> false)
377377

378+
member vref.ImplementedSlotSignatures =
379+
vref.MemberInfo.Value.ImplementedSlotSigs
380+
378381
//-------------------------------------------------------------------------
379382
// Helper methods associated with using TAST metadata (F# members, values etc.)
380383
// as backing data for MethInfo, PropInfo etc.
@@ -1090,6 +1093,11 @@ type MethInfo =
10901093
| ProvidedMeth _ -> false
10911094
#endif
10921095

1096+
member x.ImplementedSlotSignatures =
1097+
match x with
1098+
| FSMeth(_,_,vref,_) -> vref.ImplementedSlotSignatures
1099+
| _ -> failwith "not supported"
1100+
10931101
/// Indicates if this is an extension member.
10941102
member x.IsExtensionMember = x.IsCSharpStyleExtensionMember || x.IsFSharpStyleExtensionMember
10951103

@@ -1796,6 +1804,9 @@ type PropInfo =
17961804
| Some vref -> vref.IsDefiniteFSharpOverrideMember
17971805
| None -> false
17981806

1807+
member x.ImplementedSlotSignatures =
1808+
x.ArbitraryValRef.Value.ImplementedSlotSignatures
1809+
17991810
member x.IsFSharpExplicitInterfaceImplementation =
18001811
match x.ArbitraryValRef with
18011812
| Some vref -> vref.IsFSharpExplicitInterfaceImplementation x.TcGlobals

src/fsharp/vs/Symbols.fs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,57 @@ and FSharpDelegateSignature(cenv, info : SlotSig) =
855855
| Some ty -> FSharpType(cenv, ty)
856856
override x.ToString() = "<delegate signature>"
857857

858+
and FSharpAbstractParameter(cenv, info : SlotParam) =
859+
860+
member __.Name =
861+
let (TSlotParam(name, _, _, _, _, _)) = info
862+
name
863+
864+
member __.Type = FSharpType(cenv, info.Type)
865+
866+
member __.IsInArg =
867+
let (TSlotParam(_, _, isIn, _, _, _)) = info
868+
isIn
869+
870+
member __.IsOutArg =
871+
let (TSlotParam(_, _, _, isOut, _, _)) = info
872+
isOut
873+
874+
member __.IsOptionalArg =
875+
let (TSlotParam(_, _, _, _, isOptional, _)) = info
876+
isOptional
877+
878+
member __.Attributes =
879+
let (TSlotParam(_, _, _, _, _, attribs)) = info
880+
attribs |> List.map (fun a -> FSharpAttribute(cenv, AttribInfo.FSAttribInfo(cenv.g, a)))
881+
|> makeReadOnlyCollection
882+
883+
and FSharpAbstractSignature(cenv, info : SlotSig) =
884+
885+
member __.AbstractArguments =
886+
info.FormalParams
887+
|> List.map (List.map (fun p -> FSharpAbstractParameter(cenv, p)) >> makeReadOnlyCollection)
888+
|> makeReadOnlyCollection
889+
890+
member __.AbstractReturnType =
891+
match info.FormalReturnType with
892+
| None -> FSharpType(cenv, cenv.g.unit_ty)
893+
| Some ty -> FSharpType(cenv, ty)
894+
895+
member __.DeclaringTypeGenericParameters =
896+
info.ClassTypars
897+
|> List.map (fun t -> FSharpGenericParameter(cenv, t))
898+
|> makeReadOnlyCollection
899+
900+
member __.MethodGenericParameters =
901+
info.MethodTypars
902+
|> List.map (fun t -> FSharpGenericParameter(cenv, t))
903+
|> makeReadOnlyCollection
904+
905+
member __.Name = info.Name
906+
907+
member __.DeclaringType = FSharpType(cenv, info.ImplementedType)
908+
858909
and FSharpGenericParameterMemberConstraint(cenv, info : TraitConstraintInfo) =
859910
let (TTrait(tys,nm,flags,atys,rty,_)) = info
860911
member __.MemberSources =
@@ -1338,6 +1389,17 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
13381389
| M m -> m.IsFSharpExplicitInterfaceImplementation
13391390
| V v -> v.IsFSharpExplicitInterfaceImplementation cenv.g
13401391

1392+
member __.ImplementedAbstractSignatures =
1393+
checkIsResolved()
1394+
let sigs =
1395+
match d with
1396+
| E e -> e.GetAddMethod().ImplementedSlotSignatures
1397+
| P p -> p.ImplementedSlotSignatures
1398+
| M m -> m.ImplementedSlotSignatures
1399+
| V v -> v.ImplementedSlotSignatures
1400+
sigs |> List.map (fun s -> FSharpAbstractSignature (cenv, s))
1401+
|> makeReadOnlyCollection
1402+
13411403
member __.IsImplicitConstructor =
13421404
if isUnresolved() then false else
13431405
match fsharpInfo() with

src/fsharp/vs/Symbols.fsi

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,48 @@ and [<Class>] FSharpDelegateSignature =
289289
/// Get the return type of the delegate signature
290290
member DelegateReturnType : FSharpType
291291

292+
/// Represents a parameter in an abstract method of a class or interface
293+
and [<Class>] FSharpAbstractParameter =
294+
295+
/// The optional name of the parameter
296+
member Name : string option
297+
298+
/// The declared or inferred type of the parameter
299+
member Type : FSharpType
300+
301+
/// Indicate this is an in argument
302+
member IsInArg : bool
303+
304+
/// Indicate this is an out argument
305+
member IsOutArg : bool
306+
307+
/// Indicate this is an optional argument
308+
member IsOptionalArg : bool
309+
310+
/// The declared attributes of the parameter
311+
member Attributes : IList<FSharpAttribute>
312+
313+
/// Represents the signature of an abstract slot of a class or interface
314+
and [<Class>] FSharpAbstractSignature =
315+
316+
/// Get the arguments of the abstract slot
317+
member AbstractArguments : IList<IList<FSharpAbstractParameter>>
318+
319+
/// Get the return type of the abstract slot
320+
member AbstractReturnType : FSharpType
321+
322+
/// Get the generic arguments of the type defining the abstract slot
323+
member DeclaringTypeGenericParameters : IList<FSharpGenericParameter>
324+
325+
/// Get the generic arguments of the abstract slot
326+
member MethodGenericParameters : IList<FSharpGenericParameter>
327+
328+
/// Get the name of the abstract slot
329+
member Name : string
330+
331+
/// Get the declaring type of the abstract slot
332+
member DeclaringType : FSharpType
333+
292334
/// A subtype of FSharpSymbol that represents a union case as seen by the F# language
293335
and [<Class>] FSharpUnionCase =
294336
inherit FSharpSymbol
@@ -617,6 +659,9 @@ and [<Class>] FSharpMemberOrFunctionOrValue =
617659
/// Indicates if this is an explicit implementation of an interface member
618660
member IsExplicitInterfaceImplementation : bool
619661

662+
/// Gets the list of the abstract slot signatures implemented by the member
663+
member ImplementedAbstractSignatures : IList<FSharpAbstractSignature>
664+
620665
/// Indicates if this is a member, including extension members?
621666
member IsMember : bool
622667

0 commit comments

Comments
 (0)