Skip to content

Commit 97e4223

Browse files
committed
Add with keyword to SynValSig.
1 parent 6a5ddec commit 97e4223

File tree

11 files changed

+61
-18
lines changed

11 files changed

+61
-18
lines changed

src/fsharp/CheckDeclarations.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4081,7 +4081,7 @@ module EstablishTypeDefinitionCores =
40814081
let abstractSlots =
40824082
[ for valSpfn, memberFlags in slotsigs do
40834083

4084-
let (SynValSig(_, _, _, _, _valSynData, _, _, _, _, _, m)) = valSpfn
4084+
let (SynValSig(range=m)) = valSpfn
40854085

40864086
CheckMemberFlags None NewSlotsOK OverridesOK memberFlags m
40874087

src/fsharp/CheckExpressions.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4009,7 +4009,7 @@ and TcPseudoMemberSpec cenv newOk env synTypes tpenv memSpfn m =
40094009

40104010
/// Check a value specification, e.g. in a signature, interface declaration or a constraint
40114011
and TcValSpec cenv env declKind newOk containerInfo memFlagsOpt thisTyOpt tpenv valSpfn attrs =
4012-
let (SynValSig(_, id, ValTyparDecls (synTypars, synTyparConstraints, _), ty, valSynInfo, _, _, _, _, _, m)) = valSpfn
4012+
let (SynValSig(ident=id; explicitValDecls=ValTyparDecls (synTypars, synTyparConstraints, _); synType=ty; arity=valSynInfo; range=m)) = valSpfn
40134013
let declaredTypars = TcTyparDecls cenv env synTypars
40144014
let (ContainerInfo(altActualParent, tcrefContainerInfo)) = containerInfo
40154015
let enclosingDeclaredTypars, memberContainerInfo, thisTyOpt, declKind =
@@ -11497,7 +11497,7 @@ and TcLetrec overridesOK cenv env tpenv (binds, bindsm, scopem) =
1149711497

1149811498
let TcAndPublishValSpec (cenv, env, containerInfo: ContainerInfo, declKind, memFlagsOpt, tpenv, valSpfn) =
1149911499

11500-
let (SynValSig (Attributes synAttrs, _, ValTyparDecls (synTypars, _, synCanInferTypars), _, _, isInline, mutableFlag, doc, vis, literalExprOpt, m)) = valSpfn
11500+
let (SynValSig (attributes=Attributes synAttrs; explicitValDecls=ValTyparDecls (synTypars, _, synCanInferTypars); isInline=isInline; isMutable=mutableFlag; xmlDoc=doc; accessibility=vis; synExpr=literalExprOpt; range=m)) = valSpfn
1150111501

1150211502
GeneralizationHelpers.CheckDeclaredTyparsPermitted(memFlagsOpt, synTypars, m)
1150311503
let canInferTypars = GeneralizationHelpers.ComputeCanInferExtraGeneralizableTypars (containerInfo.ParentRef, synCanInferTypars, memFlagsOpt)

src/fsharp/SyntaxTree.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,6 +1509,7 @@ type SynValSig =
15091509
xmlDoc: PreXmlDoc *
15101510
accessibility: SynAccess option *
15111511
synExpr: SynExpr option *
1512+
withKeyword: Range option *
15121513
range: range
15131514

15141515
member x.RangeOfId = let (SynValSig(ident=id)) = x in id.idRange

src/fsharp/SyntaxTree.fsi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,6 +1685,7 @@ type SynValSig =
16851685
xmlDoc: PreXmlDoc *
16861686
accessibility: SynAccess option *
16871687
synExpr: SynExpr option *
1688+
withKeyword: Range option *
16881689
range: range
16891690

16901691
member RangeOfId: range

src/fsharp/pars.fsy

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ valSpfn:
839839
let attr1, attr2, isInline, isMutable, vis2, id, doc, explicitValTyparDecls, (ty, arity), konst = ($1), ($4), ($5), ($6), ($7), ($8), grabXmlDoc(parseState, $1, 1), ($9), ($11), ($12)
840840
if not (isNil attr2) then errorR(Deprecated(FSComp.SR.parsAttributesMustComeBeforeVal(), rhs parseState 4))
841841
let m = rhs2 parseState 1 11
842-
let valSpfn = SynValSig((attr1@attr2), id, explicitValTyparDecls, ty, arity, isInline, isMutable, doc, vis2, konst, m)
842+
let valSpfn = SynValSig((attr1@attr2), id, explicitValTyparDecls, ty, arity, isInline, isMutable, doc, vis2, konst, None, m)
843843
SynModuleSigDecl.Val(valSpfn, m)
844844
}
845845

@@ -941,7 +941,7 @@ tyconSpfnRhs:
941941
| DELEGATE OF topType
942942
{ let m = lhs parseState
943943
let ty, arity = $3
944-
let invoke = SynMemberSig.Member(SynValSig([], mkSynId m "Invoke", inferredTyparDecls, ty, arity, false, false, PreXmlDoc.Empty, None, None, m), AbstractMemberFlags SynMemberKind.Member, m)
944+
let invoke = SynMemberSig.Member(SynValSig([], mkSynId m "Invoke", inferredTyparDecls, ty, arity, false, false, PreXmlDoc.Empty, None, None, None, m), AbstractMemberFlags SynMemberKind.Member, m)
945945
(fun nameRange nameInfo mEquals augmentation ->
946946
if not (isNil augmentation) then raiseParseErrorAt m (FSComp.SR.parsAugmentationsIllegalOnDelegateType())
947947
let mWhole = unionRanges nameRange m
@@ -1022,7 +1022,7 @@ classMemberSpfn:
10221022
| None -> unionRanges m ty.Range
10231023
| Some m2 -> unionRanges m m2
10241024
|> fun m -> (m, $1) ||> unionRangeWithListBy (fun (a: SynAttributeList) -> a.Range)
1025-
let valSpfn = SynValSig($1, id, explicitValTyparDecls, ty, arity, isInline, false, doc, vis2, optLiteralValue, wholeRange)
1025+
let valSpfn = SynValSig($1, id, explicitValTyparDecls, ty, arity, isInline, false, doc, vis2, optLiteralValue, mWith, wholeRange)
10261026
let _, flags = $3
10271027
SynMemberSig.Member(valSpfn, flags (getSetAdjuster arity), wholeRange) }
10281028

@@ -1053,7 +1053,7 @@ classMemberSpfn:
10531053
{ let vis, doc, (ty, valSynInfo) = $2, grabXmlDoc(parseState, $1, 1), $5
10541054
let m = unionRanges (rhs parseState 1) ty.Range
10551055
let isInline = false
1056-
let valSpfn = SynValSig ($1, mkSynId (rhs parseState 3) "new", noInferredTypars, ty, valSynInfo, isInline, false, doc, vis, None, m)
1056+
let valSpfn = SynValSig ($1, mkSynId (rhs parseState 3) "new", noInferredTypars, ty, valSynInfo, isInline, false, doc, vis, None, None, m)
10571057
SynMemberSig.Member(valSpfn, CtorMemberFlags, m) }
10581058

10591059

@@ -1638,7 +1638,7 @@ tyconDefnRhs:
16381638
{ let m = lhs parseState
16391639
let ty, arity = $3
16401640
(fun nameRange augmentation ->
1641-
let valSpfn = SynValSig([], mkSynId m "Invoke", inferredTyparDecls, ty, arity, false, false, PreXmlDoc.Empty, None, None, m)
1641+
let valSpfn = SynValSig([], mkSynId m "Invoke", inferredTyparDecls, ty, arity, false, false, PreXmlDoc.Empty, None, None, None, m)
16421642
let invoke = SynMemberDefn.AbstractSlot(valSpfn, AbstractMemberFlags SynMemberKind.Member, m)
16431643
if not (isNil augmentation) then raiseParseErrorAt m (FSComp.SR.parsAugmentationsIllegalOnDelegateType())
16441644
SynTypeDefnRepr.ObjectModel (SynTypeDefnKind.Delegate (ty, arity), [invoke], m), []) }
@@ -1990,7 +1990,7 @@ classDefnMember:
19901990
| None -> unionRanges m ty.Range
19911991
| Some m2 -> unionRanges m m2
19921992
if Option.isSome $2 then errorR(Error(FSComp.SR.parsAccessibilityModsIllegalForAbstract(), wholeRange))
1993-
let valSpfn = SynValSig($1, id, explicitValTyparDecls, ty, arity, isInline, false, doc, None, None, wholeRange)
1993+
let valSpfn = SynValSig($1, id, explicitValTyparDecls, ty, arity, isInline, false, doc, None, None, mWith, wholeRange)
19941994
[ SynMemberDefn.AbstractSlot(valSpfn, AbstractMemberFlags (getSetAdjuster arity), wholeRange) ] }
19951995

19961996
| opt_attributes opt_declVisibility inheritsDefn

src/fsharp/service/ServiceNavigation.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ module NavigationImpl =
233233
[ createMember(rcid, NavigationItemKind.Field, FSharpGlyph.Field, range, enclosingEntityKind, false, access) ]
234234
| SynMemberDefn.AutoProperty(ident=id; accessibility=access) ->
235235
[ createMember(id, NavigationItemKind.Field, FSharpGlyph.Field, id.idRange, enclosingEntityKind, false, access) ]
236-
| SynMemberDefn.AbstractSlot(SynValSig(_, id, _, ty, _, _, _, _, access, _, _), _, _) ->
236+
| SynMemberDefn.AbstractSlot(SynValSig(ident=id; synType=ty; accessibility=access), _, _) ->
237237
[ createMember(id, NavigationItemKind.Method, FSharpGlyph.OverridenMethod, ty.Range, enclosingEntityKind, true, access) ]
238238
| SynMemberDefn.NestedType _ -> failwith "tycon as member????" //processTycon tycon
239239
| SynMemberDefn.Interface(members=Some(membs)) ->
@@ -392,15 +392,15 @@ module NavigationImpl =
392392
and processSigMembers (members: SynMemberSig list): list<NavigationItem * int> =
393393
[ for memb in members do
394394
match memb with
395-
| SynMemberSig.Member(SynValSig.SynValSig(_, id, _, _, _, _, _, _, access, _, m), _, _) ->
395+
| SynMemberSig.Member(SynValSig.SynValSig(ident=id; accessibility=access; range=m), _, _) ->
396396
yield createMember(id, NavigationItemKind.Method, FSharpGlyph.Method, m, NavigationEntityKind.Class, false, access)
397397
| SynMemberSig.ValField(SynField(_, _, Some(rcid), ty, _, _, access, _), _) ->
398398
yield createMember(rcid, NavigationItemKind.Field, FSharpGlyph.Field, ty.Range, NavigationEntityKind.Class, false, access)
399399
| _ -> () ]
400400

401401
// Process declarations in a module that belong to the right drop-down (let bindings)
402402
let processNestedSigDeclarations decls = decls |> List.collect (function
403-
| SynModuleSigDecl.Val(SynValSig.SynValSig(_, id, _, _, _, _, _, _, access, _, m), _) ->
403+
| SynModuleSigDecl.Val(SynValSig.SynValSig(ident=id; accessibility=access; range=m), _) ->
404404
[ createMember(id, NavigationItemKind.Method, FSharpGlyph.Method, m, NavigationEntityKind.Module, false, access) ]
405405
| _ -> [] )
406406

@@ -540,7 +540,7 @@ module NavigateTo =
540540
| _ -> ()
541541
{ Type = containerType; Name = formatLongIdent lid }
542542

543-
let addValSig kind (SynValSig(_, id, _, _, _, _, _, _, _, _, _)) isSig container =
543+
let addValSig kind (SynValSig(ident=id)) isSig container =
544544
addIdent kind id isSig container
545545

546546
let addField(SynField(_, _, id, _, _, _, _, _)) isSig container =

src/fsharp/service/ServiceParsedInputOps.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ module ParsedInput =
632632
and walkField (SynField(Attributes attrs, _, _, t, _, _, _, _)) =
633633
List.tryPick walkAttribute attrs |> Option.orElseWith (fun () -> walkType t)
634634

635-
and walkValSig (SynValSig(Attributes attrs, _, _, t, _, _, _, _, _, _, _)) =
635+
and walkValSig (SynValSig(attributes=Attributes attrs; synType=t)) =
636636
List.tryPick walkAttribute attrs |> Option.orElseWith (fun () -> walkType t)
637637

638638
and walkMemberSig = function
@@ -1387,7 +1387,7 @@ module ParsedInput =
13871387
List.iter walkAttribute attrs
13881388
walkType t
13891389

1390-
and walkValSig (SynValSig(Attributes attrs, _, _, t, SynValInfo(argInfos, argInfo), _, _, _, _, _, _)) =
1390+
and walkValSig (SynValSig(attributes=Attributes attrs; synType=t; arity=SynValInfo(argInfos, argInfo))) =
13911391
List.iter walkAttribute attrs
13921392
walkType t
13931393
argInfo :: (argInfos |> List.concat)

src/fsharp/service/ServiceStructure.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ module Structure =
823823

824824
let rec parseModuleSigDeclaration (decl: SynModuleSigDecl) =
825825
match decl with
826-
| SynModuleSigDecl.Val (SynValSig(attrs, ident, _, _, _, _, _, _, _, _, valrange), r) ->
826+
| SynModuleSigDecl.Val (SynValSig(attributes=attrs; ident=ident; range=valrange), r) ->
827827
let collapse = Range.endToEnd ident.idRange valrange
828828
rcheck Scope.Val Collapse.Below r collapse
829829
parseAttributes attrs

src/fsharp/service/ServiceXmlDocParser.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ module XmlDocParsing =
122122
let paramNames = digNamesFrom synPat
123123
[XmlDocable(line,indent,paramNames)]
124124
else []
125-
| SynMemberDefn.AbstractSlot(SynValSig(synAttributes, _, _, _, synValInfo, _, _, preXmlDoc, _, _, _), _, range) ->
125+
| SynMemberDefn.AbstractSlot(SynValSig(attributes=synAttributes; arity=synValInfo; xmlDoc=preXmlDoc), _, range) ->
126126
if isEmptyXmlDoc preXmlDoc then
127127
let fullRange = synAttributes |> List.fold (fun r a -> unionRanges r a.Range) range
128128
let line = fullRange.StartLine

tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8881,7 +8881,7 @@ FSharp.Compiler.Syntax.SynValSig: FSharp.Compiler.Syntax.SynValInfo SynInfo
88818881
FSharp.Compiler.Syntax.SynValSig: FSharp.Compiler.Syntax.SynValInfo arity
88828882
FSharp.Compiler.Syntax.SynValSig: FSharp.Compiler.Syntax.SynValInfo get_SynInfo()
88838883
FSharp.Compiler.Syntax.SynValSig: FSharp.Compiler.Syntax.SynValInfo get_arity()
8884-
FSharp.Compiler.Syntax.SynValSig: FSharp.Compiler.Syntax.SynValSig NewSynValSig(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList], FSharp.Compiler.Syntax.Ident, FSharp.Compiler.Syntax.SynValTyparDecls, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynValInfo, Boolean, Boolean, FSharp.Compiler.Xml.PreXmlDoc, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynAccess], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynExpr], FSharp.Compiler.Text.Range)
8884+
FSharp.Compiler.Syntax.SynValSig: FSharp.Compiler.Syntax.SynValSig NewSynValSig(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList], FSharp.Compiler.Syntax.Ident, FSharp.Compiler.Syntax.SynValTyparDecls, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynValInfo, Boolean, Boolean, FSharp.Compiler.Xml.PreXmlDoc, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynAccess], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynExpr], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], FSharp.Compiler.Text.Range)
88858885
FSharp.Compiler.Syntax.SynValSig: FSharp.Compiler.Syntax.SynValTyparDecls explicitValDecls
88868886
FSharp.Compiler.Syntax.SynValSig: FSharp.Compiler.Syntax.SynValTyparDecls get_explicitValDecls()
88878887
FSharp.Compiler.Syntax.SynValSig: FSharp.Compiler.Text.Range RangeOfId
@@ -8898,6 +8898,8 @@ FSharp.Compiler.Syntax.SynValSig: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Co
88988898
FSharp.Compiler.Syntax.SynValSig: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynAccess] get_accessibility()
88998899
FSharp.Compiler.Syntax.SynValSig: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynExpr] get_synExpr()
89008900
FSharp.Compiler.Syntax.SynValSig: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynExpr] synExpr
8901+
FSharp.Compiler.Syntax.SynValSig: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_withKeyword()
8902+
FSharp.Compiler.Syntax.SynValSig: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] withKeyword
89018903
FSharp.Compiler.Syntax.SynValSig: System.String ToString()
89028904
FSharp.Compiler.Syntax.SynValTyparDecls
89038905
FSharp.Compiler.Syntax.SynValTyparDecls: Boolean canInfer

0 commit comments

Comments
 (0)