From b78ad5cd6feea006986869506f33aab84c37398a Mon Sep 17 00:00:00 2001 From: Florian Verdonck Date: Wed, 12 Oct 2022 15:00:32 +0200 Subject: [PATCH 1/8] Add SynType.Or. (#14058) * Add SynType.Or for generic constrains in the form (^A or ^B):... --- src/Compiler/Checking/CheckExpressions.fs | 8 +- src/Compiler/FSComp.txt | 1 + src/Compiler/Service/ServiceParseTreeWalk.fs | 3 +- src/Compiler/Service/ServiceParsedInputOps.fs | 14 +- src/Compiler/SyntaxTree/SyntaxTree.fs | 9 +- src/Compiler/SyntaxTree/SyntaxTree.fsi | 7 +- src/Compiler/SyntaxTree/SyntaxTreeOps.fs | 9 + src/Compiler/SyntaxTree/SyntaxTreeOps.fsi | 2 + src/Compiler/SyntaxTree/SyntaxTrivia.fs | 3 + src/Compiler/SyntaxTree/SyntaxTrivia.fsi | 8 + src/Compiler/pars.fsy | 25 ++- src/Compiler/xlf/FSComp.txt.cs.xlf | 5 + src/Compiler/xlf/FSComp.txt.de.xlf | 5 + src/Compiler/xlf/FSComp.txt.es.xlf | 5 + src/Compiler/xlf/FSComp.txt.fr.xlf | 5 + src/Compiler/xlf/FSComp.txt.it.xlf | 5 + src/Compiler/xlf/FSComp.txt.ja.xlf | 5 + src/Compiler/xlf/FSComp.txt.ko.xlf | 5 + src/Compiler/xlf/FSComp.txt.pl.xlf | 5 + src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 5 + src/Compiler/xlf/FSComp.txt.ru.xlf | 5 + src/Compiler/xlf/FSComp.txt.tr.xlf | 5 + src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 5 + src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 5 + ...erService.SurfaceArea.netstandard.expected | 30 +++- tests/service/SyntaxTreeTests/SynTypeTests.fs | 156 ++++++++++++++++++ 26 files changed, 311 insertions(+), 29 deletions(-) diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index 9e21c434270..a83ef7d669b 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -3953,7 +3953,7 @@ let rec TcTyparConstraint ridx (cenv: cenv) newOk checkConstraints occ (env: TcE | SynTypeConstraint.WhereTyparIsDelegate(tp, synTys, m) -> TcConstraintWhereTyparIsDelegate cenv env newOk checkConstraints occ tpenv tp synTys m - | SynTypeConstraint.WhereTyparSupportsMember(synSupportTys, synMemberSig, m) -> + | SynTypeConstraint.WhereTyparSupportsMember(TypesForTypar synSupportTys, synMemberSig, m) -> TcConstraintWhereTyparSupportsMember cenv env newOk tpenv synSupportTys synMemberSig m | SynTypeConstraint.WhereSelfConstrained(ty, m) -> @@ -4361,6 +4361,10 @@ and TcTypeOrMeasure kindOpt (cenv: cenv) newOk checkConstraints occ (iwsam: Warn | SynType.Paren(innerType, _) | SynType.SignatureParameter(usedType = innerType) -> TcTypeOrMeasure kindOpt cenv newOk checkConstraints occ iwsam env tpenv innerType + + | SynType.Or(range = m) -> + // The inner types are expected to be collected by (|TypesForTypar|) at this point. + error(Error((FSComp.SR.tcSynTypeOrInvalidInDeclaration()), m)) and CheckIWSAM (cenv: cenv) (env: TcEnv) checkConstraints iwsam m tcref = let g = cenv.g @@ -5651,7 +5655,7 @@ and TcExprUndelayed (cenv: cenv) (overallTy: OverallTy) env tpenv (synExpr: SynE TcNonControlFlowExpr env <| fun env -> TcExprNamedIndexPropertySet cenv overallTy env tpenv (synLongId, synExpr1, synExpr2, mStmt) - | SynExpr.TraitCall (tps, synMemberSig, arg, m) -> + | SynExpr.TraitCall (TypesForTypar tps, synMemberSig, arg, m) -> TcNonControlFlowExpr env <| fun env -> TcExprTraitCall cenv overallTy env tpenv (tps, synMemberSig, arg, m) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 80c356d31db..2e3267b01a7 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1656,3 +1656,4 @@ reprStateMachineInvalidForm,"The state machine has an unexpected form" 3546,parsExpectingPatternInTuple,"Expecting pattern" 3547,parsExpectedPatternAfterToken,"Expected a pattern after this point" 3548,matchNotAllowedForUnionCaseWithNoData,"Pattern discard is not allowed for union case that takes no data." +3549,tcSynTypeOrInvalidInDeclaration,"SynType.Or is not permitted in this declaration" \ No newline at end of file diff --git a/src/Compiler/Service/ServiceParseTreeWalk.fs b/src/Compiler/Service/ServiceParseTreeWalk.fs index f3443fd95ff..274d2741365 100755 --- a/src/Compiler/Service/ServiceParseTreeWalk.fs +++ b/src/Compiler/Service/ServiceParseTreeWalk.fs @@ -821,7 +821,8 @@ module SyntaxTraversal = | SynType.WithGlobalConstraints (ty, _, _) | SynType.Array (_, ty, _) -> traverseSynType path ty | SynType.StaticConstantNamed (ty1, ty2, _) - | SynType.MeasureDivide (ty1, ty2, _) -> [ ty1; ty2 ] |> List.tryPick (traverseSynType path) + | SynType.MeasureDivide (ty1, ty2, _) + | SynType.Or (ty1, ty2, _, _) -> [ ty1; ty2 ] |> List.tryPick (traverseSynType path) | SynType.Tuple (path = segments) -> getTypeFromTuplePath segments |> List.tryPick (traverseSynType path) | SynType.StaticConstantExpr (expr, _) -> traverseSynExpr [] expr | SynType.Paren (innerType = t) diff --git a/src/Compiler/Service/ServiceParsedInputOps.fs b/src/Compiler/Service/ServiceParsedInputOps.fs index ef194965b34..3ff647478a8 100644 --- a/src/Compiler/Service/ServiceParsedInputOps.fs +++ b/src/Compiler/Service/ServiceParsedInputOps.fs @@ -607,7 +607,7 @@ module ParsedInput = | SynTypeConstraint.WhereTyparIsComparable (t, _) -> walkTypar t | SynTypeConstraint.WhereTyparIsEquatable (t, _) -> walkTypar t | SynTypeConstraint.WhereTyparSubtypeOfType (t, ty, _) -> walkTypar t |> Option.orElseWith (fun () -> walkType ty) - | SynTypeConstraint.WhereTyparSupportsMember (ts, sign, _) -> + | SynTypeConstraint.WhereTyparSupportsMember (TypesForTypar ts, sign, _) -> List.tryPick walkType ts |> Option.orElseWith (fun () -> walkMemberSig sign) | SynTypeConstraint.WhereTyparIsEnum (t, ts, _) -> walkTypar t |> Option.orElseWith (fun () -> List.tryPick walkType ts) | SynTypeConstraint.WhereTyparIsDelegate (t, ts, _) -> walkTypar t |> Option.orElseWith (fun () -> List.tryPick walkType ts) @@ -668,7 +668,8 @@ module ParsedInput = | SynType.Fun (argType = t1; returnType = t2) -> walkType t1 |> Option.orElseWith (fun () -> walkType t2) | SynType.WithGlobalConstraints (t, _, _) -> walkType t | SynType.HashConstraint (t, _) -> walkType t - | SynType.MeasureDivide (t1, t2, _) -> walkType t1 |> Option.orElseWith (fun () -> walkType t2) + | SynType.MeasureDivide (t1, t2, _) + | SynType.Or (t1, t2, _, _) -> walkType t1 |> Option.orElseWith (fun () -> walkType t2) | SynType.MeasurePower (t, _, _) -> walkType t | SynType.Paren (t, _) | SynType.SignatureParameter (usedType = t) -> walkType t @@ -838,7 +839,7 @@ module ParsedInput = | SynExpr.DoBang (e, _) -> walkExprWithKind parentKind e - | SynExpr.TraitCall (ts, sign, e, _) -> + | SynExpr.TraitCall (TypesForTypar ts, sign, e, _) -> List.tryPick walkType ts |> Option.orElseWith (fun () -> walkMemberSig sign) |> Option.orElseWith (fun () -> walkExprWithKind parentKind e) @@ -1621,7 +1622,7 @@ module ParsedInput = | SynTypeConstraint.WhereTyparIsDelegate (t, ts, _) -> walkTypar t List.iter walkType ts - | SynTypeConstraint.WhereTyparSupportsMember (ts, sign, _) -> + | SynTypeConstraint.WhereTyparSupportsMember (TypesForTypar ts, sign, _) -> List.iter walkType ts walkMemberSig sign | SynTypeConstraint.WhereSelfConstrained (ty, _) -> walkType ty @@ -1673,7 +1674,8 @@ module ParsedInput = | SynType.Paren (t, _) | SynType.SignatureParameter (usedType = t) -> walkType t | SynType.Fun (argType = t1; returnType = t2) - | SynType.MeasureDivide (t1, t2, _) -> + | SynType.MeasureDivide (t1, t2, _) + | SynType.Or (t1, t2, _, _) -> walkType t1 walkType t2 | SynType.LongIdent ident -> addLongIdentWithDots ident @@ -1820,7 +1822,7 @@ module ParsedInput = walkExpr eAndBang walkExpr e2 - | SynExpr.TraitCall (ts, sign, e, _) -> + | SynExpr.TraitCall (TypesForTypar ts, sign, e, _) -> List.iter walkType ts walkMemberSig sign walkExpr e diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fs b/src/Compiler/SyntaxTree/SyntaxTree.fs index 7ef394a67f0..051bb1e7af8 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fs +++ b/src/Compiler/SyntaxTree/SyntaxTree.fs @@ -330,7 +330,7 @@ type SynTypeConstraint = | WhereTyparSubtypeOfType of typar: SynTypar * typeName: SynType * range: range - | WhereTyparSupportsMember of typars: SynType list * memberSig: SynMemberSig * range: range + | WhereTyparSupportsMember of typars: SynType * memberSig: SynMemberSig * range: range | WhereTyparIsEnum of typar: SynTypar * typeArgs: SynType list * range: range @@ -441,6 +441,8 @@ type SynType = | SignatureParameter of attributes: SynAttributes * optional: bool * id: Ident option * usedType: SynType * range: range + | Or of lhsType: SynType * rhsType: SynType * range: range * trivia: SynTypeOrTrivia + member x.Range = match x with | SynType.App (range = m) @@ -459,7 +461,8 @@ type SynType = | SynType.MeasureDivide (range = m) | SynType.MeasurePower (range = m) | SynType.Paren (range = m) - | SynType.SignatureParameter (range = m) -> m + | SynType.SignatureParameter (range = m) + | SynType.Or (range = m) -> m | SynType.LongIdent lidwd -> lidwd.Range [] @@ -647,7 +650,7 @@ type SynExpr = | AddressOf of isByref: bool * expr: SynExpr * opRange: range * range: range - | TraitCall of supportTys: SynType list * traitSig: SynMemberSig * argExpr: SynExpr * range: range + | TraitCall of supportTys: SynType * traitSig: SynMemberSig * argExpr: SynExpr * range: range | JoinIn of lhsExpr: SynExpr * lhsRange: range * rhsExpr: SynExpr * range: range diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fsi b/src/Compiler/SyntaxTree/SyntaxTree.fsi index 8d977a4c027..4ecffe92ef4 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTree.fsi @@ -405,7 +405,7 @@ type SynTypeConstraint = | WhereTyparSubtypeOfType of typar: SynTypar * typeName: SynType * range: range /// F# syntax is ^T: (static member MemberName: ^T * int -> ^T) - | WhereTyparSupportsMember of typars: SynType list * memberSig: SynMemberSig * range: range + | WhereTyparSupportsMember of typars: SynType * memberSig: SynMemberSig * range: range /// F# syntax is 'typar: enum<'UnderlyingType> | WhereTyparIsEnum of typar: SynTypar * typeArgs: SynType list * range: range @@ -518,6 +518,9 @@ type SynType = usedType: SynType * range: range + /// F# syntax: ^a or ^b, used in trait calls + | Or of lhsType: SynType * rhsType: SynType * range: range * trivia: SynTypeOrTrivia + /// Gets the syntax range of this construct member Range: range @@ -817,7 +820,7 @@ type SynExpr = | AddressOf of isByref: bool * expr: SynExpr * opRange: range * range: range /// F# syntax: ((type1 or ... or typeN): (member-dig) expr) - | TraitCall of supportTys: SynType list * traitSig: SynMemberSig * argExpr: SynExpr * range: range + | TraitCall of supportTys: SynType * traitSig: SynMemberSig * argExpr: SynExpr * range: range /// F# syntax: ... in ... /// Computation expressions only, based on JOIN_IN token from lex filter diff --git a/src/Compiler/SyntaxTree/SyntaxTreeOps.fs b/src/Compiler/SyntaxTree/SyntaxTreeOps.fs index aefc238d10e..fda76bc0e47 100644 --- a/src/Compiler/SyntaxTree/SyntaxTreeOps.fs +++ b/src/Compiler/SyntaxTree/SyntaxTreeOps.fs @@ -1082,3 +1082,12 @@ let (|MultiDimensionArrayType|_|) (t: SynType) = else None | _ -> None + +let (|TypesForTypar|) (t: SynType) = + let rec visit continuation t = + match t with + | SynType.Paren (innerT, _) -> visit continuation innerT + | SynType.Or (lhsT, rhsT, _, _) -> visit (fun lhsTs -> [ yield! lhsTs; yield rhsT ] |> continuation) lhsT + | _ -> continuation [ t ] + + visit id t diff --git a/src/Compiler/SyntaxTree/SyntaxTreeOps.fsi b/src/Compiler/SyntaxTree/SyntaxTreeOps.fsi index b78563d4bce..bb72345971e 100644 --- a/src/Compiler/SyntaxTree/SyntaxTreeOps.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTreeOps.fsi @@ -357,3 +357,5 @@ val desugarGetSetMembers: memberDefns: SynMemberDefns -> SynMemberDefns val getTypeFromTuplePath: path: SynTupleTypeSegment list -> SynType list val (|MultiDimensionArrayType|_|): t: SynType -> (int * SynType * range) option + +val (|TypesForTypar|): t: SynType -> SynType list diff --git a/src/Compiler/SyntaxTree/SyntaxTrivia.fs b/src/Compiler/SyntaxTree/SyntaxTrivia.fs index fa4ebc784c8..7c15170e74f 100644 --- a/src/Compiler/SyntaxTree/SyntaxTrivia.fs +++ b/src/Compiler/SyntaxTree/SyntaxTrivia.fs @@ -265,3 +265,6 @@ type SynMemberGetSetTrivia = [] type SynArgPatsNamePatPairsTrivia = { ParenRange: range } + +[] +type SynTypeOrTrivia = { OrKeyword: range } diff --git a/src/Compiler/SyntaxTree/SyntaxTrivia.fsi b/src/Compiler/SyntaxTree/SyntaxTrivia.fsi index b6f0532d73c..c52cacea7b2 100644 --- a/src/Compiler/SyntaxTree/SyntaxTrivia.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTrivia.fsi @@ -384,3 +384,11 @@ type SynArgPatsNamePatPairsTrivia = /// The syntax range from the beginning of the `(` token till the end of the `)` token. ParenRange: range } + +/// Represents additional information for SynType.Or +[] +type SynTypeOrTrivia = + { + /// The syntax range of the `or` keyword + OrKeyword: range + } diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index 4b5888bf2f4..1dc110accee 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -2226,10 +2226,12 @@ typeConstraint: | typar COLON LPAREN classMemberSpfn rparen { let tp = $1 - SynTypeConstraint.WhereTyparSupportsMember([ SynType.Var(tp, tp.Range) ], $4, lhs parseState) } + SynTypeConstraint.WhereTyparSupportsMember(SynType.Var(tp, tp.Range), $4, lhs parseState) } | LPAREN typeAlts rparen COLON LPAREN classMemberSpfn rparen - { SynTypeConstraint.WhereTyparSupportsMember(List.rev($2), $6, lhs parseState) } + { let mParen = rhs2 parseState 1 3 + let t = SynType.Paren($2, mParen) + SynTypeConstraint.WhereTyparSupportsMember(t, $6, lhs parseState) } | typar COLON DELEGATE typeArgsNoHpaDeprecated { let _ltm, _gtm, args, _commas, mWhole = $4 @@ -2254,10 +2256,12 @@ typeConstraint: typeAlts: | typeAlts OR appType - { $3 :: $1 } + { let mOr = rhs parseState 2 + let m = unionRanges $1.Range $3.Range + SynType.Or($1, $3, m, { OrKeyword = mOr }) } | appType - { [$1] } + { $1 } /* The core of a union type definition */ unionTypeRepr: @@ -4485,17 +4489,20 @@ parenExprBody: typars: | typar - { [SynType.Var($1, rhs parseState 1)] } + { SynType.Var($1, rhs parseState 1) } - | LPAREN typarAlts rparen - { List.rev $2 } + | LPAREN typarAlts rparen + { let m = rhs2 parseState 1 3 + SynType.Paren($2, m) } typarAlts: | typarAlts OR appType - {$3 :: $1} + { let mOr = rhs parseState 2 + let m = unionRanges $1.Range $3.Range + SynType.Or($1, $3, m, { OrKeyword = mOr }) } | typar - { [SynType.Var($1, rhs parseState 1)] } + { SynType.Var($1, rhs parseState 1) } braceExpr: | LBRACE braceExprBody rbrace diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 7cccaaa5d29..1489085bcb7 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -977,6 +977,11 @@ Tento výraz implicitně převede typ {0} na typ {1}. Přečtěte si téma https://aka.ms/fsharp-implicit-convs. + + SynType.Or is not permitted in this declaration + SynType.Or is not permitted in this declaration + + The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 159319c2da5..00da1cbd6af 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -977,6 +977,11 @@ Dieser Ausdruck konvertiert den Typ "{0}" implizit in den Typ "{1}". Siehe https://aka.ms/fsharp-implicit-convs. + + SynType.Or is not permitted in this declaration + SynType.Or is not permitted in this declaration + + The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 92090c2cfb0..f6cdcdddad2 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -977,6 +977,11 @@ Esta expresión convierte implícitamente el tipo '{0}' al tipo '{1}'. Consulte https://aka.ms/fsharp-implicit-convs. + + SynType.Or is not permitted in this declaration + SynType.Or is not permitted in this declaration + + The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index eef8d9e96dd..ec74d45bf45 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -977,6 +977,11 @@ Cette expression convertit implicitement le type « {0} » en type « {1} ». Voir https://aka.ms/fsharp-implicit-convs. + + SynType.Or is not permitted in this declaration + SynType.Or is not permitted in this declaration + + The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 46fe0bfdf02..4a810e60fcc 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -977,6 +977,11 @@ Questa espressione converte in modo implicito il tipo '{0}' nel tipo '{1}'. Vedere https://aka.ms/fsharp-implicit-convs. + + SynType.Or is not permitted in this declaration + SynType.Or is not permitted in this declaration + + The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 58341cfee8b..0fc08e21cfe 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -977,6 +977,11 @@ この式は、型 '{0}' を型 '{1}' に暗黙的に変換します。https://aka.ms/fsharp-implicit-convs を参照してください。 + + SynType.Or is not permitted in this declaration + SynType.Or is not permitted in this declaration + + The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index f17e7a6e178..9a5deaa0421 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -977,6 +977,11 @@ 이 식은 암시적으로 '{0}' 형식을 '{1}' 형식으로 변환 합니다. https://aka.ms/fsharp-implicit-convs 참조 + + SynType.Or is not permitted in this declaration + SynType.Or is not permitted in this declaration + + The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 90f31614688..7f869a057f2 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -977,6 +977,11 @@ To wyrażenie bezwzględnie konwertuje typ "{0}" na typ "{1}". Zobacz https://aka.ms/fsharp-implicit-convs. + + SynType.Or is not permitted in this declaration + SynType.Or is not permitted in this declaration + + The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 31ba7d3299e..165404290f0 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -977,6 +977,11 @@ Essa expressão converte implicitamente o tipo '{0}' ao tipo '{1}'. Consulte https://aka.ms/fsharp-implicit-convs. + + SynType.Or is not permitted in this declaration + SynType.Or is not permitted in this declaration + + The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 3af5738e4d1..52876a45a7d 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -977,6 +977,11 @@ Это выражение неявно преобразует тип "{0}" в тип "{1}". См. сведения на странице https://aka.ms/fsharp-implicit-convs. + + SynType.Or is not permitted in this declaration + SynType.Or is not permitted in this declaration + + The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index c74d382e716..1c7303bf2fb 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -977,6 +977,11 @@ Bu ifade '{0}' türünü örtülü olarak '{1}' türüne dönüştürür. https://aka.ms/fsharp-implicit-convs adresine bakın. + + SynType.Or is not permitted in this declaration + SynType.Or is not permitted in this declaration + + The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index a1860f2bedc..45189c5d7dd 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -977,6 +977,11 @@ 此表达式将类型“{0}”隐式转换为类型“{1}”。请参阅 https://aka.ms/fsharp-implicit-convs。 + + SynType.Or is not permitted in this declaration + SynType.Or is not permitted in this declaration + + The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 41e6735e44d..27040f48efe 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -977,6 +977,11 @@ 此運算式將類型 '{0}' 隱含轉換為類型 '{1}'。請參閱 https://aka.ms/fsharp-implicit-convs。 + + SynType.Or is not permitted in this declaration + SynType.Or is not permitted in this declaration + + The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. The trait '{0}' invoked by this call has multiple support types. This invocation syntax is not permitted for such traits. See https://aka.ms/fsharp-srtp for guidance. diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected b/tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected index 9045f24ab29..d7f8a490d26 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected @@ -6744,10 +6744,10 @@ FSharp.Compiler.Syntax.SynExpr+TraitCall: FSharp.Compiler.Syntax.SynExpr argExpr FSharp.Compiler.Syntax.SynExpr+TraitCall: FSharp.Compiler.Syntax.SynExpr get_argExpr() FSharp.Compiler.Syntax.SynExpr+TraitCall: FSharp.Compiler.Syntax.SynMemberSig get_traitSig() FSharp.Compiler.Syntax.SynExpr+TraitCall: FSharp.Compiler.Syntax.SynMemberSig traitSig +FSharp.Compiler.Syntax.SynExpr+TraitCall: FSharp.Compiler.Syntax.SynType get_supportTys() +FSharp.Compiler.Syntax.SynExpr+TraitCall: FSharp.Compiler.Syntax.SynType supportTys FSharp.Compiler.Syntax.SynExpr+TraitCall: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynExpr+TraitCall: FSharp.Compiler.Text.Range range -FSharp.Compiler.Syntax.SynExpr+TraitCall: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType] get_supportTys() -FSharp.Compiler.Syntax.SynExpr+TraitCall: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType] supportTys FSharp.Compiler.Syntax.SynExpr+TryFinally: FSharp.Compiler.Syntax.DebugPointAtFinally finallyDebugPoint FSharp.Compiler.Syntax.SynExpr+TryFinally: FSharp.Compiler.Syntax.DebugPointAtFinally get_finallyDebugPoint() FSharp.Compiler.Syntax.SynExpr+TryFinally: FSharp.Compiler.Syntax.DebugPointAtTry get_tryDebugPoint() @@ -7030,7 +7030,7 @@ FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewRecord(Microso FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewSequential(FSharp.Compiler.Syntax.DebugPointAtSequential, Boolean, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewSequentialOrImplicitYield(FSharp.Compiler.Syntax.DebugPointAtSequential, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewSet(FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range) -FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewTraitCall(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], FSharp.Compiler.Syntax.SynMemberSig, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range) +FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewTraitCall(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynMemberSig, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewTryFinally(FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range, FSharp.Compiler.Syntax.DebugPointAtTry, FSharp.Compiler.Syntax.DebugPointAtFinally, FSharp.Compiler.SyntaxTrivia.SynExprTryFinallyTrivia) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewTryWith(FSharp.Compiler.Syntax.SynExpr, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynMatchClause], FSharp.Compiler.Text.Range, FSharp.Compiler.Syntax.DebugPointAtTry, FSharp.Compiler.Syntax.DebugPointAtWith, FSharp.Compiler.SyntaxTrivia.SynExprTryWithTrivia) FSharp.Compiler.Syntax.SynExpr: FSharp.Compiler.Syntax.SynExpr NewTuple(Boolean, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynExpr], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range], FSharp.Compiler.Text.Range) @@ -8512,6 +8512,14 @@ FSharp.Compiler.Syntax.SynType+MeasurePower: FSharp.Compiler.Syntax.SynType base FSharp.Compiler.Syntax.SynType+MeasurePower: FSharp.Compiler.Syntax.SynType get_baseMeasure() FSharp.Compiler.Syntax.SynType+MeasurePower: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynType+MeasurePower: FSharp.Compiler.Text.Range range +FSharp.Compiler.Syntax.SynType+Or: FSharp.Compiler.Syntax.SynType get_lhsType() +FSharp.Compiler.Syntax.SynType+Or: FSharp.Compiler.Syntax.SynType get_rhsType() +FSharp.Compiler.Syntax.SynType+Or: FSharp.Compiler.Syntax.SynType lhsType +FSharp.Compiler.Syntax.SynType+Or: FSharp.Compiler.Syntax.SynType rhsType +FSharp.Compiler.Syntax.SynType+Or: FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia get_trivia() +FSharp.Compiler.Syntax.SynType+Or: FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia trivia +FSharp.Compiler.Syntax.SynType+Or: FSharp.Compiler.Text.Range get_range() +FSharp.Compiler.Syntax.SynType+Or: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynType+Paren: FSharp.Compiler.Syntax.SynType get_innerType() FSharp.Compiler.Syntax.SynType+Paren: FSharp.Compiler.Syntax.SynType innerType FSharp.Compiler.Syntax.SynType+Paren: FSharp.Compiler.Text.Range get_range() @@ -8550,6 +8558,7 @@ FSharp.Compiler.Syntax.SynType+Tags: Int32 LongIdent FSharp.Compiler.Syntax.SynType+Tags: Int32 LongIdentApp FSharp.Compiler.Syntax.SynType+Tags: Int32 MeasureDivide FSharp.Compiler.Syntax.SynType+Tags: Int32 MeasurePower +FSharp.Compiler.Syntax.SynType+Tags: Int32 Or FSharp.Compiler.Syntax.SynType+Tags: Int32 Paren FSharp.Compiler.Syntax.SynType+Tags: Int32 SignatureParameter FSharp.Compiler.Syntax.SynType+Tags: Int32 StaticConstant @@ -8584,6 +8593,7 @@ FSharp.Compiler.Syntax.SynType: Boolean IsLongIdent FSharp.Compiler.Syntax.SynType: Boolean IsLongIdentApp FSharp.Compiler.Syntax.SynType: Boolean IsMeasureDivide FSharp.Compiler.Syntax.SynType: Boolean IsMeasurePower +FSharp.Compiler.Syntax.SynType: Boolean IsOr FSharp.Compiler.Syntax.SynType: Boolean IsParen FSharp.Compiler.Syntax.SynType: Boolean IsSignatureParameter FSharp.Compiler.Syntax.SynType: Boolean IsStaticConstant @@ -8602,6 +8612,7 @@ FSharp.Compiler.Syntax.SynType: Boolean get_IsLongIdent() FSharp.Compiler.Syntax.SynType: Boolean get_IsLongIdentApp() FSharp.Compiler.Syntax.SynType: Boolean get_IsMeasureDivide() FSharp.Compiler.Syntax.SynType: Boolean get_IsMeasurePower() +FSharp.Compiler.Syntax.SynType: Boolean get_IsOr() FSharp.Compiler.Syntax.SynType: Boolean get_IsParen() FSharp.Compiler.Syntax.SynType: Boolean get_IsSignatureParameter() FSharp.Compiler.Syntax.SynType: Boolean get_IsStaticConstant() @@ -8620,6 +8631,7 @@ FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewLongIdent(FSha FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewLongIdentApp(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynLongIdent, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewMeasureDivide(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewMeasurePower(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynRationalConst, FSharp.Compiler.Text.Range) +FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewOr(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewParen(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewSignatureParameter(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList], Boolean, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.Ident], FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewStaticConstant(FSharp.Compiler.Syntax.SynConst, FSharp.Compiler.Text.Range) @@ -8638,6 +8650,7 @@ FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+LongIdent FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+LongIdentApp FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+MeasureDivide FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+MeasurePower +FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+Or FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+Paren FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+SignatureParameter FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType+StaticConstant @@ -8715,10 +8728,10 @@ FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSubtypeOfType: FSharp.Compile FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSubtypeOfType: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSupportsMember: FSharp.Compiler.Syntax.SynMemberSig get_memberSig() FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSupportsMember: FSharp.Compiler.Syntax.SynMemberSig memberSig +FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSupportsMember: FSharp.Compiler.Syntax.SynType get_typars() +FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSupportsMember: FSharp.Compiler.Syntax.SynType typars FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSupportsMember: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSupportsMember: FSharp.Compiler.Text.Range range -FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSupportsMember: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType] get_typars() -FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSupportsMember: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType] typars FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSupportsNull: FSharp.Compiler.Syntax.SynTypar get_typar() FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSupportsNull: FSharp.Compiler.Syntax.SynTypar typar FSharp.Compiler.Syntax.SynTypeConstraint+WhereTyparSupportsNull: FSharp.Compiler.Text.Range get_range() @@ -8757,7 +8770,7 @@ FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstrai FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint NewWhereTyparIsUnmanaged(FSharp.Compiler.Syntax.SynTypar, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint NewWhereTyparIsValueType(FSharp.Compiler.Syntax.SynTypar, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint NewWhereTyparSubtypeOfType(FSharp.Compiler.Syntax.SynTypar, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range) -FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint NewWhereTyparSupportsMember(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], FSharp.Compiler.Syntax.SynMemberSig, FSharp.Compiler.Text.Range) +FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint NewWhereTyparSupportsMember(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynMemberSig, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint NewWhereTyparSupportsNull(FSharp.Compiler.Syntax.SynTypar, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint+Tags FSharp.Compiler.Syntax.SynTypeConstraint: FSharp.Compiler.Syntax.SynTypeConstraint+WhereSelfConstrained @@ -9594,6 +9607,11 @@ FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia: FSharp.Compiler.Text.Range ArrowR FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia: FSharp.Compiler.Text.Range get_ArrowRange() FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia: System.String ToString() FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia: Void .ctor(FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia +FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia: FSharp.Compiler.Text.Range OrKeyword +FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia: FSharp.Compiler.Text.Range get_OrKeyword() +FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia: System.String ToString() +FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia: Void .ctor(FSharp.Compiler.Text.Range) FSharp.Compiler.SyntaxTrivia.SynUnionCaseTrivia FSharp.Compiler.SyntaxTrivia.SynUnionCaseTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] BarRange FSharp.Compiler.SyntaxTrivia.SynUnionCaseTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_BarRange() diff --git a/tests/service/SyntaxTreeTests/SynTypeTests.fs b/tests/service/SyntaxTreeTests/SynTypeTests.fs index 1ab5ed12e94..7f18521a995 100644 --- a/tests/service/SyntaxTreeTests/SynTypeTests.fs +++ b/tests/service/SyntaxTreeTests/SynTypeTests.fs @@ -49,3 +49,159 @@ type T = ])) -> assertRange (3, 14) (3, 56) mTuple | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``SynType.Or inside SynExpr.TraitCall`` () = + let parseResults = + getParseResults + """ +let inline (!!) (x: ^a) : ^b = ((^a or ^b): (static member op_Implicit: ^a -> ^b) x) + """ + + match parseResults with + | ParsedInput.ImplFile (ParsedImplFileInput (contents = [ SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Let(bindings = [ + SynBinding(expr = + SynExpr.Typed(expr = + SynExpr.Paren(expr = + SynExpr.TraitCall(supportTys = + SynType.Paren( + SynType.Or( + SynType.Var(range = mVar1), + SynType.Var(range = mVar2), + mOrType, + { OrKeyword = mOrWord }), + mParen)) + ))) + ]) ]) ])) -> + assertRange (2, 33) (2, 35) mVar1 + assertRange (2, 36) (2, 38) mOrWord + assertRange (2, 39) (2, 41) mVar2 + assertRange (2, 33) (2, 41) mOrType + assertRange (2, 32) (2, 42) mParen + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``SynType.Or inside SynTypeConstraint.WhereTyparSupportsMember`` () = + let parseResults = + getParseResults + """ +let inline f_StaticMethod<'T1, 'T2 when ('T1 or 'T2) : (static member StaticMethod: int -> int) >() : int = + () + """ + + match parseResults with + | ParsedInput.ImplFile (ParsedImplFileInput (contents = [ SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Let(bindings = [ + SynBinding(headPat = + SynPat.LongIdent(typarDecls = Some (SynValTyparDecls(typars = Some (SynTyparDecls.PostfixList(constraints = [ + SynTypeConstraint.WhereTyparSupportsMember(typars = SynType.Paren( + SynType.Or( + SynType.Var(range = mVar1), + SynType.Var(range = mVar2), + mOrType, + { OrKeyword = mOrWord }), + mParen + )) + ])))))) + ]) ]) ])) -> + assertRange (2, 41) (2, 44) mVar1 + assertRange (2, 45) (2, 47) mOrWord + assertRange (2, 48) (2, 51) mVar2 + assertRange (2, 41) (2, 51) mOrType + assertRange (2, 40) (2, 52) mParen + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``Nested SynType.Or inside SynExpr.TraitCall`` () = + let parseResults = + getParseResults + """ +let inline (!!) (x: ^a * ^b) : ^c = ((^a or ^b or ^c): (static member op_Implicit: ^a * ^b -> ^c) x) + """ + + match parseResults with + | ParsedInput.ImplFile (ParsedImplFileInput (contents = [ SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Let(bindings = [ + SynBinding(expr = + SynExpr.Typed(expr = + SynExpr.Paren(expr = + SynExpr.TraitCall(supportTys = + SynType.Paren( + SynType.Or( + SynType.Or( + SynType.Var(range = mVarA), + SynType.Var(range = mVarB), + mOrType1, + { OrKeyword = mOrWord1 } + ), + SynType.Var(range = mVarC), + mOrType2, + { OrKeyword = mOrWord2 }), + mParen)) + ))) + ]) ]) ])) -> + assertRange (2, 38) (2, 40) mVarA + assertRange (2, 41) (2, 43) mOrWord1 + assertRange (2, 44) (2, 46) mVarB + assertRange (2, 38) (2, 46) mOrType1 + assertRange (2, 47) (2, 49) mOrWord2 + assertRange (2, 50) (2, 52) mVarC + assertRange (2, 38) (2, 52) mOrType2 + assertRange (2, 37) (2, 53) mParen + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``Single SynType inside SynExpr.TraitCall`` () = + let parseResults = + getParseResults + """ +type X = + static member inline replace< ^a, ^b, ^c when ^b: (static member replace: ^a * ^b -> ^c)>(a: ^a, f: ^b) = + (^b : (static member replace: ^a * ^b -> ^c) (a, f)) + """ + + match parseResults with + | ParsedInput.ImplFile (ParsedImplFileInput (contents = [ SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Types(typeDefns = [ + SynTypeDefn(typeRepr = SynTypeDefnRepr.ObjectModel(members = [ + SynMemberDefn.Member(memberDefn = + SynBinding(expr = + SynExpr.Paren(expr = + SynExpr.TraitCall(supportTys = + SynType.Var(range = mVar)) + ))) + ])) + ]) ]) ])) -> + assertRange (4, 9) (4, 11) mVar + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``SynType.Or with appType on the right hand side`` () = + let parseResults = + getParseResults + """ +let inline f (x: 'T) = ((^T or int) : (static member A: int) ()) + """ + + match parseResults with + | ParsedInput.ImplFile (ParsedImplFileInput (contents = [ SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Let(bindings = [ + SynBinding(expr = + SynExpr.Paren(expr = + SynExpr.TraitCall(supportTys = + SynType.Paren( + SynType.Or( + SynType.Var(range = mVar), + (SynType.LongIdent _ as appType), + mOrType, + { OrKeyword = mOrWord }), + mParen)) + )) + ]) ]) ])) -> + assertRange (2, 25) (2,27) mVar + assertRange (2, 28) (2, 30) mOrWord + assertRange (2, 31) (2, 34) appType.Range + assertRange (2,25) (2, 34) mOrType + assertRange (2,24) (2, 35) mParen + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" From 889709d8e506e6b707c6eaec5c310edda9c2be65 Mon Sep 17 00:00:00 2001 From: Rustam Date: Wed, 12 Oct 2022 16:43:47 +0300 Subject: [PATCH 2/8] Change ty1.Equals(ty2) to call static op_Equality (#13028) Co-authored-by: Vlad Zarytovskii Co-authored-by: Don Syme --- src/Compiler/AbstractIL/ilreflect.fs | 5 +- src/Compiler/TypedTree/TypeProviders.fs | 2 +- src/Compiler/Utilities/sformat.fs | 4 +- src/Compiler/Utilities/sr.fs | 2 +- src/FSharp.Build/FSharpEmbedResourceText.fs | 2 +- src/FSharp.Core/Linq.fs | 11 +- src/FSharp.Core/Query.fs | 44 +-- src/FSharp.Core/prim-types.fs | 319 +++++++++--------- src/FSharp.Core/quotations.fs | 2 +- src/FSharp.Core/reflect.fs | 4 +- .../FSharp.DependencyManager.fs | 2 +- tests/service/data/TestTP/ProvidedTypes.fs | 2 +- 12 files changed, 202 insertions(+), 197 deletions(-) diff --git a/src/Compiler/AbstractIL/ilreflect.fs b/src/Compiler/AbstractIL/ilreflect.fs index 0fc3e73e247..5cf3ec58222 100644 --- a/src/Compiler/AbstractIL/ilreflect.fs +++ b/src/Compiler/AbstractIL/ilreflect.fs @@ -412,7 +412,7 @@ module Zmap = | Some y -> y | None -> failwithf "Zmap.force: %s: x = %+A" str x -let equalTypes (s: Type) (t: Type) = s.Equals t +let equalTypes (s: Type) (t: Type) = Type.op_Equality (s, t) let equalTypeLists (tys1: Type list) (tys2: Type list) = List.lengthsEqAndForall2 equalTypes tys1 tys2 @@ -820,7 +820,8 @@ let TypeBuilderInstantiationT = ty let typeIsNotQueryable (ty: Type) = - (ty :? TypeBuilder) || ((ty.GetType()).Equals(TypeBuilderInstantiationT)) + (ty :? TypeBuilder) + || Type.op_Equality (ty.GetType(), TypeBuilderInstantiationT) let queryableTypeGetField _emEnv (parentT: Type) (fref: ILFieldRef) = let res = diff --git a/src/Compiler/TypedTree/TypeProviders.fs b/src/Compiler/TypedTree/TypeProviders.fs index 662081a1f45..02f6fafd05d 100644 --- a/src/Compiler/TypedTree/TypeProviders.fs +++ b/src/Compiler/TypedTree/TypeProviders.fs @@ -415,7 +415,7 @@ type ProvidedType (x: Type, ctxt: ProvidedTypeContext) = member _.ApplyStaticArguments(provider: ITypeProvider, fullTypePathAfterArguments, staticArgs: obj[]) = provider.ApplyStaticArguments(x, fullTypePathAfterArguments, staticArgs) |> ProvidedType.Create ctxt - member _.IsVoid = (typeof.Equals x || (x.Namespace = "System" && x.Name = "Void")) + member _.IsVoid = (Type.op_Equality(x, typeof) || (x.Namespace = "System" && x.Name = "Void")) member _.IsGenericParameter = x.IsGenericParameter diff --git a/src/Compiler/Utilities/sformat.fs b/src/Compiler/Utilities/sformat.fs index 42b13e28ff9..303e2f968b5 100644 --- a/src/Compiler/Utilities/sformat.fs +++ b/src/Compiler/Utilities/sformat.fs @@ -455,9 +455,9 @@ module ReflectUtils = isNamedType (ty1) && if ty1.IsGenericType then ty2.IsGenericType - && (ty1.GetGenericTypeDefinition()).Equals(ty2.GetGenericTypeDefinition()) + && Type.op_Equality (ty1.GetGenericTypeDefinition(), ty2.GetGenericTypeDefinition()) else - ty1.Equals(ty2) + Type.op_Equality (ty1, ty2) let option = typedefof diff --git a/src/Compiler/Utilities/sr.fs b/src/Compiler/Utilities/sr.fs index 245ed9841c2..77552a03b90 100644 --- a/src/Compiler/Utilities/sr.fs +++ b/src/Compiler/Utilities/sr.fs @@ -37,7 +37,7 @@ module internal DiagnosticMessage = let isFunctionType (ty1: System.Type) = isNamedType (ty1) && ty1.IsGenericType - && (ty1.GetGenericTypeDefinition()).Equals(funTyC) + && System.Type.op_Equality (ty1.GetGenericTypeDefinition(), funTyC) let rec destFunTy (ty: System.Type) = if isFunctionType ty then diff --git a/src/FSharp.Build/FSharpEmbedResourceText.fs b/src/FSharp.Build/FSharpEmbedResourceText.fs index 77002aa4f54..d8a3848ba27 100644 --- a/src/FSharp.Build/FSharpEmbedResourceText.fs +++ b/src/FSharp.Build/FSharpEmbedResourceText.fs @@ -289,7 +289,7 @@ open Printf static let isNamedType(ty:System.Type) = not (ty.IsArray || ty.IsByRef || ty.IsPointer) static let isFunctionType (ty1:System.Type) = - isNamedType(ty1) && getTypeInfo(ty1).IsGenericType && (ty1.GetGenericTypeDefinition()).Equals(funTyC) + isNamedType(ty1) && getTypeInfo(ty1).IsGenericType && System.Type.op_Equality(ty1.GetGenericTypeDefinition(), funTyC) static let rec destFunTy (ty:System.Type) = if isFunctionType ty then diff --git a/src/FSharp.Core/Linq.fs b/src/FSharp.Core/Linq.fs index 33a1dd18265..6b62eccb93e 100644 --- a/src/FSharp.Core/Linq.fs +++ b/src/FSharp.Core/Linq.fs @@ -44,9 +44,9 @@ module LeafExpressionConverter = let equivHeadTypes (ty1:Type) (ty2:Type) = isNamedType(ty1) && if ty1.IsGenericType then - ty2.IsGenericType && (ty1.GetGenericTypeDefinition()).Equals(ty2.GetGenericTypeDefinition()) + ty2.IsGenericType && Type.op_Equality(ty1.GetGenericTypeDefinition(), ty2.GetGenericTypeDefinition()) else - ty1.Equals(ty2) + Type.op_Equality(ty1, ty2) let isFunctionType typ = equivHeadTypes typ (typeof<(int -> int)>) @@ -458,7 +458,7 @@ module LeafExpressionConverter = let converted = ConvExprToLinqInContext env x // Most of conversion scenarios in C# are covered by Expression.Convert - if x.Type.Equals toTy then converted // source and target types match - do nothing + if Type.op_Equality(x.Type, toTy) then converted // source and target types match - do nothing elif not (x.Type.IsValueType || toTy.IsValueType) && toTy.IsAssignableFrom x.Type then converted // converting reference type to supertype - do nothing else Expression.Convert(converted, toTy) |> asExpr // emit Expression.Convert @@ -522,7 +522,10 @@ module LeafExpressionConverter = Expression.New(ctor, argsR, [| for p in props -> (p :> MemberInfo) |]) |> asExpr // Do the same thing as C# compiler for string addition - | PlusQ (_, GenericArgs [|ty1; ty2; ty3|], [x1; x2]) when ty1 = typeof && ty2 = typeof && ty3 = typeof -> + | PlusQ (_, GenericArgs [|ty1; ty2; ty3|], [x1; x2]) + when Type.op_Equality(ty1, typeof) && + Type.op_Equality(ty2, typeof) && + Type.op_Equality(ty3, typeof) -> Expression.Add(ConvExprToLinqInContext env x1, ConvExprToLinqInContext env x2, StringConcat) |> asExpr // LanguagePrimitives.PhysicalEquality's generic constraint of both sides being the same reference type is already sufficient for Linq Expressions' requirements diff --git a/src/FSharp.Core/Query.fs b/src/FSharp.Core/Query.fs index ae11d3835a1..28a460619f6 100644 --- a/src/FSharp.Core/Query.fs +++ b/src/FSharp.Core/Query.fs @@ -440,7 +440,7 @@ module Query = let IsIEnumerableTy (ty: System.Type) = ty.IsGenericType && ty.GetGenericTypeDefinition() = IEnumerableTypeDef // Check a tag type on QuerySource is IQueryable - let qTyIsIQueryable (ty : System.Type) = not (ty.Equals(typeof)) + let qTyIsIQueryable (ty : System.Type) = not (Type.op_Equality(ty, typeof)) let FuncExprToDelegateExpr (srcTy, targetTy, v, body) = Expr.NewDelegate (Linq.Expressions.Expression.GetFuncType [| srcTy; targetTy |], [v], body) @@ -588,21 +588,21 @@ module Query = let selector = MakeImplicitExpressionConversion selector let maker = match resTyNoNullable with - | ty when ty = typeof -> mq_double - | ty when ty = typeof -> mq_single - | ty when ty = typeof -> mq_decimal - | ty when ty = typeof -> mq_int32 - | ty when ty = typeof -> mq_int64 + | ty when Type.op_Equality(ty, typeof) -> mq_double + | ty when Type.op_Equality(ty, typeof) -> mq_single + | ty when Type.op_Equality(ty, typeof) -> mq_decimal + | ty when Type.op_Equality(ty, typeof) -> mq_int32 + | ty when Type.op_Equality(ty, typeof) -> mq_int64 | _ -> failDueToUnsupportedInputTypeInSumByOrAverageBy() maker ([srcItemTy], [src; selector]) else // Try to dynamically invoke a LINQ method if one exists, since these may be optimized over arrays etc. match resTyNoNullable with - | ty when ty = typeof -> me_double ([srcItemTy], [src; selector]) - | ty when ty = typeof -> me_single ([srcItemTy], [src; selector]) - | ty when ty = typeof -> me_decimal ([srcItemTy], [src; selector]) - | ty when ty = typeof -> me_int32 ([srcItemTy], [src; selector]) - | ty when ty = typeof -> me_int64 ([srcItemTy], [src; selector]) + | ty when Type.op_Equality(ty, typeof) -> me_double ([srcItemTy], [src; selector]) + | ty when Type.op_Equality(ty, typeof) -> me_single ([srcItemTy], [src; selector]) + | ty when Type.op_Equality(ty, typeof) -> me_decimal ([srcItemTy], [src; selector]) + | ty when Type.op_Equality(ty, typeof) -> me_int32 ([srcItemTy], [src; selector]) + | ty when Type.op_Equality(ty, typeof) -> me_int64 ([srcItemTy], [src; selector]) | _ -> // The F# implementation needs a QuerySource as a parameter. let qTy = typeof @@ -617,22 +617,22 @@ module Query = let selector = FuncExprToLinqFunc2Expression (srcItemTy, resTy, v, res) let caller = match resTyNoNullable with - | ty when ty = typeof -> cq_double - | ty when ty = typeof -> cq_single - | ty when ty = typeof -> cq_decimal - | ty when ty = typeof -> cq_int32 - | ty when ty = typeof -> cq_int64 + | ty when Type.op_Equality(ty, typeof) -> cq_double + | ty when Type.op_Equality(ty, typeof) -> cq_single + | ty when Type.op_Equality(ty, typeof) -> cq_decimal + | ty when Type.op_Equality(ty, typeof) -> cq_int32 + | ty when Type.op_Equality(ty, typeof) -> cq_int64 | _ -> failDueToUnsupportedInputTypeInSumByOrAverageBy() caller ([srcItemTy], [src; box selector]) : obj else // Try to dynamically invoke a LINQ method if one exists, since these may be optimized over arrays etc. let linqMethOpt = match resTyNoNullable with - | ty when ty = typeof -> Some ce_double - | ty when ty = typeof -> Some ce_single - | ty when ty = typeof -> Some ce_decimal - | ty when ty = typeof -> Some ce_int32 - | ty when ty = typeof -> Some ce_int64 + | ty when Type.op_Equality(ty, typeof) -> Some ce_double + | ty when Type.op_Equality(ty, typeof) -> Some ce_single + | ty when Type.op_Equality(ty, typeof) -> Some ce_decimal + | ty when Type.op_Equality(ty, typeof) -> Some ce_int32 + | ty when Type.op_Equality(ty, typeof) -> Some ce_int64 | _ -> None match linqMethOpt with | Some ce -> @@ -1617,7 +1617,7 @@ module Query = let IQueryableTySpec = MakeIQueryableTy tyArg // if result type of nested query is derived from IQueryable but not IQueryable itself (i.e. IOrderedQueryable) // then add coercion to IQueryable so result type will match expected signature of QuerySource.Run - if (IQueryableTySpec.IsAssignableFrom replNestedQuery.Type) && not (IQueryableTySpec.Equals replNestedQuery.Type) then + if (IQueryableTySpec.IsAssignableFrom replNestedQuery.Type) && not (Type.op_Equality(IQueryableTySpec, replNestedQuery.Type)) then Expr.Coerce (replNestedQuery, IQueryableTySpec) else replNestedQuery diff --git a/src/FSharp.Core/prim-types.fs b/src/FSharp.Core/prim-types.fs index 0489528c062..85befedcb4b 100644 --- a/src/FSharp.Core/prim-types.fs +++ b/src/FSharp.Core/prim-types.fs @@ -606,7 +606,7 @@ namespace Microsoft.FSharp.Core then TypeNullnessSemantics_NullNever else if not (typeof<'T>.IsDefined(typeof, false)) then TypeNullnessSemantics_NullIsExtraValue - elif typeof<'T>.Equals(typeof) then + elif Type.op_Equality (typeof<'T>, typeof) then TypeNullnessSemantics_NullTrueValue elif typeof.IsAssignableFrom(typeof<'T>) then TypeNullnessSemantics_NullIsExtraValue @@ -2098,22 +2098,22 @@ namespace Microsoft.FSharp.Core type FastGenericEqualityComparerTable<'T>() = static let f : IEqualityComparer<'T> = match typeof<'T> with - | ty when ty.Equals(typeof) -> unboxPrim (box BoolIEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box ByteIEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box Int32IEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box UInt32IEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box CharIEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box SByteIEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box Int16IEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box Int64IEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box IntPtrIEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box UInt16IEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box UInt64IEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box UIntPtrIEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box FloatIEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box Float32IEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box DecimalIEquality) - | ty when ty.Equals(typeof) -> unboxPrim (box StringIEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box BoolIEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box ByteIEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box Int32IEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box UInt32IEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box CharIEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box SByteIEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box Int16IEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box Int64IEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box IntPtrIEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box UInt16IEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box UInt64IEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box UIntPtrIEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box FloatIEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box Float32IEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box DecimalIEquality) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box StringIEquality) | _ -> MakeGenericEqualityComparer<'T>() static member Function : IEqualityComparer<'T> = f @@ -2193,42 +2193,42 @@ namespace Microsoft.FSharp.Core // REVIEW: in a future version we could extend this to include additional types static let fCanBeNull : IComparer<'T> = match typeof<'T> with - | ty when ty.Equals(typeof) -> unboxPrim (box IntPtrComparer) - | ty when ty.Equals(typeof) -> unboxPrim (box UIntPtrComparer) - | ty when ty.Equals(typeof) -> null - | ty when ty.Equals(typeof) -> null - | ty when ty.Equals(typeof) -> null - | ty when ty.Equals(typeof) -> null - | ty when ty.Equals(typeof) -> null - | ty when ty.Equals(typeof) -> null - | ty when ty.Equals(typeof) -> null - | ty when ty.Equals(typeof) -> null - | ty when ty.Equals(typeof) -> null - | ty when ty.Equals(typeof) -> null - | ty when ty.Equals(typeof) -> null - | ty when ty.Equals(typeof) -> null - | ty when ty.Equals(typeof) -> unboxPrim (box StringComparer) - | ty when ty.Equals(typeof) -> null + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box IntPtrComparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box UIntPtrComparer) + | ty when Type.op_Equality(ty, typeof) -> null + | ty when Type.op_Equality(ty, typeof) -> null + | ty when Type.op_Equality(ty, typeof) -> null + | ty when Type.op_Equality(ty, typeof) -> null + | ty when Type.op_Equality(ty, typeof) -> null + | ty when Type.op_Equality(ty, typeof) -> null + | ty when Type.op_Equality(ty, typeof) -> null + | ty when Type.op_Equality(ty, typeof) -> null + | ty when Type.op_Equality(ty, typeof) -> null + | ty when Type.op_Equality(ty, typeof) -> null + | ty when Type.op_Equality(ty, typeof) -> null + | ty when Type.op_Equality(ty, typeof) -> null + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box StringComparer) + | ty when Type.op_Equality(ty, typeof) -> null | _ -> MakeGenericComparer<'T>() static let f : IComparer<'T> = match typeof<'T> with - | ty when ty.Equals(typeof) -> unboxPrim (box ByteComparer) - | ty when ty.Equals(typeof) -> unboxPrim (box CharComparer) - | ty when ty.Equals(typeof) -> unboxPrim (box SByteComparer) - | ty when ty.Equals(typeof) -> unboxPrim (box Int16Comparer) - | ty when ty.Equals(typeof) -> unboxPrim (box Int32Comparer) - | ty when ty.Equals(typeof) -> unboxPrim (box Int64Comparer) - | ty when ty.Equals(typeof) -> unboxPrim (box IntPtrComparer) - | ty when ty.Equals(typeof) -> unboxPrim (box UInt16Comparer) - | ty when ty.Equals(typeof) -> unboxPrim (box UInt32Comparer) - | ty when ty.Equals(typeof) -> unboxPrim (box UInt64Comparer) - | ty when ty.Equals(typeof) -> unboxPrim (box UIntPtrComparer) - | ty when ty.Equals(typeof) -> unboxPrim (box FloatComparer) - | ty when ty.Equals(typeof) -> unboxPrim (box Float32Comparer) - | ty when ty.Equals(typeof) -> unboxPrim (box DecimalComparer) - | ty when ty.Equals(typeof) -> unboxPrim (box StringComparer) - | ty when ty.Equals(typeof) -> unboxPrim (box BoolComparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box ByteComparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box CharComparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box SByteComparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box Int16Comparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box Int32Comparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box Int64Comparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box IntPtrComparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box UInt16Comparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box UInt32Comparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box UInt64Comparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box UIntPtrComparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box FloatComparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box Float32Comparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box DecimalComparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box StringComparer) + | ty when Type.op_Equality(ty, typeof) -> unboxPrim (box BoolComparer) | _ -> // Review: There are situations where we should be able // to return Generic.Comparer<'T>.Default here. @@ -2450,46 +2450,46 @@ namespace Microsoft.FSharp.Core type GenericZeroDynamicImplTable<'T>() = static let result : 'T = // The dynamic implementation - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<'T> (box 0y) - elif aty.Equals(typeof) then unboxPrim<'T> (box 0s) - elif aty.Equals(typeof) then unboxPrim<'T> (box 0) - elif aty.Equals(typeof) then unboxPrim<'T> (box 0L) - elif aty.Equals(typeof) then unboxPrim<'T> (box 0n) - elif aty.Equals(typeof) then unboxPrim<'T> (box 0uy) - elif aty.Equals(typeof) then unboxPrim<'T> (box 0us) - elif aty.Equals(typeof) then unboxPrim<'T> (box '\000') - elif aty.Equals(typeof) then unboxPrim<'T> (box 0u) - elif aty.Equals(typeof) then unboxPrim<'T> (box 0UL) - elif aty.Equals(typeof) then unboxPrim<'T> (box 0un) - elif aty.Equals(typeof) then unboxPrim<'T> (box 0M) - elif aty.Equals(typeof) then unboxPrim<'T> (box 0.0) - elif aty.Equals(typeof) then unboxPrim<'T> (box 0.0f) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 0y) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 0s) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 0) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 0L) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 0n) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 0uy) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 0us) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box '\000') + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 0u) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 0UL) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 0un) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 0M) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 0.0) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 0.0f) else - let pinfo = aty.GetProperty("Zero") + let pinfo = ty.GetProperty("Zero") unboxPrim<'T> (pinfo.GetValue(null,null)) static member Result : 'T = result type GenericOneDynamicImplTable<'T>() = static let result : 'T = // The dynamic implementation - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<'T> (box 1y) - elif aty.Equals(typeof) then unboxPrim<'T> (box 1s) - elif aty.Equals(typeof) then unboxPrim<'T> (box 1) - elif aty.Equals(typeof) then unboxPrim<'T> (box 1L) - elif aty.Equals(typeof) then unboxPrim<'T> (box 1n) - elif aty.Equals(typeof) then unboxPrim<'T> (box 1uy) - elif aty.Equals(typeof) then unboxPrim<'T> (box 1us) - elif aty.Equals(typeof) then unboxPrim<'T> (box '\001') - elif aty.Equals(typeof) then unboxPrim<'T> (box 1u) - elif aty.Equals(typeof) then unboxPrim<'T> (box 1UL) - elif aty.Equals(typeof) then unboxPrim<'T> (box 1un) - elif aty.Equals(typeof) then unboxPrim<'T> (box 1M) - elif aty.Equals(typeof) then unboxPrim<'T> (box 1.0) - elif aty.Equals(typeof) then unboxPrim<'T> (box 1.0f) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 1y) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 1s) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 1) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 1L) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 1n) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 1uy) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 1us) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box '\001') + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 1u) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 1UL) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 1un) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 1M) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 1.0) + elif Type.op_Equality(ty, typeof) then unboxPrim<'T> (box 1.0f) else - let pinfo = aty.GetProperty("One") + let pinfo = ty.GetProperty("One") unboxPrim<'T> (pinfo.GetValue(null,null)) static member Result : 'T = result @@ -2604,7 +2604,7 @@ namespace Microsoft.FSharp.Core let ameth = aty.GetSingleStaticMethodByTypes(opName, [| aty; bty |]) let bmeth = - if aty.Equals(bty) then null else + if Type.op_Equality(aty, bty) then null else bty.GetSingleStaticMethodByTypes(opName, [| aty; bty |]) match ameth, bmeth with | null, null -> raise (NotSupportedException (SR.GetString(SR.dyInvOpAddCoerce))) @@ -4175,7 +4175,7 @@ namespace Microsoft.FSharp.Core let Failure message = new Exception(message) [] - let (|Failure|_|) (error: exn) = if error.GetType().Equals(typeof) then Some error.Message else None + let (|Failure|_|) (error: exn) = if Type.op_Equality(error.GetType(), typeof) then Some error.Message else None let inline (<) x y = GenericLessThan x y @@ -5002,7 +5002,7 @@ namespace Microsoft.FSharp.Core when ^T : string = not (# "clt" (String.CompareOrdinal((# "" x : string #),(# "" y : string #))) 0 : bool #) when ^T : ^T = ((^T or ^U): (static member (>=) : ^T * ^U -> bool) (x,y)) - /// Static greater-than-or-equal with static optimizations for some well-known cases. + /// Static equal with static optimizations for some well-known cases. let inline (=) (x:^T) (y:^T) = EqualityDynamic<(^T), (^T), bool> x y when ^T : bool = (# "ceq" x y : bool #) @@ -5023,6 +5023,7 @@ namespace Microsoft.FSharp.Core when ^T : decimal = Decimal.op_Equality((# "" x:decimal #), (# "" y:decimal #)) when ^T : ^T = (^T : (static member (=) : ^T * ^T -> bool) (x,y)) + /// Static unequal with static optimizations for some well-known cases. let inline (<>) (x:^T) (y:^T) = InequalityDynamic<(^T), (^T), bool> x y when ^T : bool = not (# "ceq" x y : bool #) @@ -6472,181 +6473,181 @@ namespace Microsoft.FSharp.Core type AbsDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:sbyte) -> absImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:int16) -> absImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:int32) -> absImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:int64) -> absImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:nativeint) -> absImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> absImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> absImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:decimal) -> absImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:sbyte) -> absImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:int16) -> absImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:int32) -> absImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:int64) -> absImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:nativeint) -> absImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> absImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> absImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:decimal) -> absImpl x) else UnaryDynamicImpl "Abs" static member Result : ('T -> 'T) = result type AcosDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> acosImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> acosImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> acosImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> acosImpl x) else UnaryDynamicImpl "Acos" static member Result : ('T -> 'T) = result type AsinDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> asinImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> asinImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> asinImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> asinImpl x) else UnaryDynamicImpl "Asin" static member Result : ('T -> 'T) = result type AtanDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> atanImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> atanImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> atanImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> atanImpl x) else UnaryDynamicImpl "Atan" static member Result : ('T -> 'T) = result type Atan2DynamicImplTable<'T,'U>() = static let result : ('T -> 'T -> 'U) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) (y:float) -> atan2Impl x y) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) (y:float32) -> atan2Impl x y) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) (y:float) -> atan2Impl x y) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) (y:float32) -> atan2Impl x y) else BinaryDynamicImpl "Atan2" static member Result : ('T -> 'T -> 'U) = result type CeilingDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> ceilImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> ceilImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> ceilImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> ceilImpl x) else UnaryDynamicImpl "Ceiling" static member Result : ('T -> 'T) = result type ExpDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> expImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> expImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> expImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> expImpl x) else UnaryDynamicImpl "Exp" static member Result : ('T -> 'T) = result type FloorDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> floorImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> floorImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> floorImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> floorImpl x) else UnaryDynamicImpl "Floor" static member Result : ('T -> 'T) = result type TruncateDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> truncateImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> truncateImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> truncateImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> truncateImpl x) else UnaryDynamicImpl "Truncate" static member Result : ('T -> 'T) = result type RoundDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> roundImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> roundImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> roundImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> roundImpl x) else UnaryDynamicImpl "Round" static member Result : ('T -> 'T) = result type SignDynamicImplTable<'T>() = static let result : ('T -> int) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> signImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> signImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:nativeint) -> signImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:decimal) -> signImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:int16) -> signImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:int32) -> signImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:int64) -> signImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:sbyte) -> signImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> signImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> signImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:nativeint) -> signImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:decimal) -> signImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:int16) -> signImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:int32) -> signImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:int64) -> signImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:sbyte) -> signImpl x) else UnaryDynamicImpl "Sign" static member Result : ('T -> int) = result type LogDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> logImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> logImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> logImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> logImpl x) else UnaryDynamicImpl "Log" static member Result : ('T -> 'T) = result type Log10DynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> log10Impl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> log10Impl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> log10Impl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> log10Impl x) else UnaryDynamicImpl "Log10" static member Result : ('T -> 'T) = result type SqrtDynamicImplTable<'T,'U>() = static let result : ('T -> 'U) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> sqrtImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> sqrtImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> sqrtImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> sqrtImpl x) else UnaryDynamicImpl "Sqrt" static member Result : ('T -> 'U) = result type CosDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> cosImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> cosImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> cosImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> cosImpl x) else UnaryDynamicImpl "Cos" static member Result : ('T -> 'T) = result type CoshDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> coshImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> coshImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> coshImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> coshImpl x) else UnaryDynamicImpl "Cosh" static member Result : ('T -> 'T) = result type SinDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> sinImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> sinImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> sinImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> sinImpl x) else UnaryDynamicImpl "Sin" static member Result : ('T -> 'T) = result type SinhDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> sinhImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> sinhImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> sinhImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> sinhImpl x) else UnaryDynamicImpl "Sinh" static member Result : ('T -> 'T) = result type TanDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> tanImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> tanImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> tanImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> tanImpl x) else UnaryDynamicImpl "Tan" static member Result : ('T -> 'T) = result type TanhDynamicImplTable<'T>() = static let result : ('T -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) -> tanhImpl x) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) -> tanhImpl x) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) -> tanhImpl x) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) -> tanhImpl x) else UnaryDynamicImpl "Tanh" static member Result : ('T -> 'T) = result type PowDynamicImplTable<'T,'U>() = static let result : ('T -> 'U -> 'T) = - let aty = typeof<'T> - if aty.Equals(typeof) then unboxPrim<_>(fun (x:float) (y:float) -> powImpl x y) - elif aty.Equals(typeof) then unboxPrim<_>(fun (x:float32) (y:float32) -> powImpl x y) + let ty = typeof<'T> + if Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float) (y:float) -> powImpl x y) + elif Type.op_Equality(ty, typeof) then unboxPrim<_>(fun (x:float32) (y:float32) -> powImpl x y) else BinaryDynamicImpl "Pow" static member Result : ('T -> 'U -> 'T) = result diff --git a/src/FSharp.Core/quotations.fs b/src/FSharp.Core/quotations.fs index c3c7317e522..20f2e8ca06b 100644 --- a/src/FSharp.Core/quotations.fs +++ b/src/FSharp.Core/quotations.fs @@ -1403,7 +1403,7 @@ module Patterns = | Ambiguous of 'R let typeEquals (ty1: Type) (ty2: Type) = - ty1.Equals ty2 + Type.op_Equality (ty1, ty2) let typesEqual (tys1: Type list) (tys2: Type list) = (tys1.Length = tys2.Length) && List.forall2 typeEquals tys1 tys2 diff --git a/src/FSharp.Core/reflect.fs b/src/FSharp.Core/reflect.fs index 76dbb87c490..e9522f68c99 100644 --- a/src/FSharp.Core/reflect.fs +++ b/src/FSharp.Core/reflect.fs @@ -43,9 +43,9 @@ module internal Impl = isNamedType ty1 && if ty1.IsGenericType then ty2.IsGenericType - && (ty1.GetGenericTypeDefinition()).Equals(ty2.GetGenericTypeDefinition()) + && Type.op_Equality (ty1.GetGenericTypeDefinition(), ty2.GetGenericTypeDefinition()) else - ty1.Equals ty2 + Type.op_Equality (ty1, ty2) let func = typedefof<(obj -> obj)> diff --git a/src/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.fs b/src/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.fs index 294cf2df55d..0740f5aa753 100644 --- a/src/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.fs +++ b/src/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.fs @@ -132,7 +132,7 @@ module FSharpDependencyManager = | Some "timeout", None -> raise (ArgumentException(SR.missingTimeoutValue ())) | Some "timeout", value -> match value with - | Some v when v.GetType() = typeof -> + | Some v when Type.op_Equality (v.GetType(), typeof) -> let parsed, value = Int32.TryParse(v) if parsed && value >= 0 then diff --git a/tests/service/data/TestTP/ProvidedTypes.fs b/tests/service/data/TestTP/ProvidedTypes.fs index c13961cbc27..4e7a7604c6b 100644 --- a/tests/service/data/TestTP/ProvidedTypes.fs +++ b/tests/service/data/TestTP/ProvidedTypes.fs @@ -76,7 +76,7 @@ module Utils = /// General implementation of .Equals(Type) logic for System.Type over symbol types. You can use this with other types too. let rec eqTypes (ty1: Type) (ty2: Type) = if Object.ReferenceEquals(ty1, ty2) then true - elif ty1.IsGenericTypeDefinition then ty2.IsGenericTypeDefinition && ty1.Equals(ty2) + elif ty1.IsGenericTypeDefinition then ty2.IsGenericTypeDefinition && Type.op_Equality(ty1, ty2) elif ty1.IsGenericType then ty2.IsGenericType && not ty2.IsGenericTypeDefinition && eqTypes (ty1.GetGenericTypeDefinition()) (ty2.GetGenericTypeDefinition()) && lengthsEqAndForall2 (ty1.GetGenericArguments()) (ty2.GetGenericArguments()) eqTypes elif ty1.IsArray then ty2.IsArray && ty1.GetArrayRank() = ty2.GetArrayRank() && eqTypes (ty1.GetElementType()) (ty2.GetElementType()) elif ty1.IsPointer then ty2.IsPointer && eqTypes (ty1.GetElementType()) (ty2.GetElementType()) From 434391e887c0dbb12093243ebcba4e88066d708d Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Thu, 13 Oct 2022 10:23:46 +0200 Subject: [PATCH 3/8] FsharpCompilerService benchmark for changes in a cascade of files referencing each other (#14096) * Generating cascading project * Benchmark attributes added --- .../FSharp.Compiler.Benchmarks.fsproj | 1 + .../FileCascadeBenchmarks.fs | 118 ++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 tests/benchmarks/FCSBenchmarks/CompilerServiceBenchmarks/FileCascadeBenchmarks.fs diff --git a/tests/benchmarks/FCSBenchmarks/CompilerServiceBenchmarks/FSharp.Compiler.Benchmarks.fsproj b/tests/benchmarks/FCSBenchmarks/CompilerServiceBenchmarks/FSharp.Compiler.Benchmarks.fsproj index 4bdb142e62b..d1187649935 100644 --- a/tests/benchmarks/FCSBenchmarks/CompilerServiceBenchmarks/FSharp.Compiler.Benchmarks.fsproj +++ b/tests/benchmarks/FCSBenchmarks/CompilerServiceBenchmarks/FSharp.Compiler.Benchmarks.fsproj @@ -17,6 +17,7 @@ + diff --git a/tests/benchmarks/FCSBenchmarks/CompilerServiceBenchmarks/FileCascadeBenchmarks.fs b/tests/benchmarks/FCSBenchmarks/CompilerServiceBenchmarks/FileCascadeBenchmarks.fs new file mode 100644 index 00000000000..746f81065b7 --- /dev/null +++ b/tests/benchmarks/FCSBenchmarks/CompilerServiceBenchmarks/FileCascadeBenchmarks.fs @@ -0,0 +1,118 @@ +namespace FSharp.Compiler.Benchmarks + +open System +open System.IO +open System.Text +open FSharp.Compiler.CodeAnalysis +open FSharp.Compiler.Diagnostics +open FSharp.Compiler.EditorServices +open FSharp.Compiler.Text +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.ILBinaryReader +open BenchmarkDotNet.Attributes +open FSharp.Compiler.Benchmarks +open Microsoft.CodeAnalysis.Text +open BenchmarkDotNet.Order +open BenchmarkDotNet.Mathematics + +[] +module private CascadeProjectHelpers = + + let createProject files projectFilename = + { + ProjectFileName = projectFilename + ProjectId = None + SourceFiles = files + OtherOptions = [|"--optimize+" |] + ReferencedProjects = [||] + IsIncompleteTypeCheckEnvironment = false + UseScriptResolutionRules = false + LoadTime = DateTime() + UnresolvedReferences = None + OriginalLoadReferences = [] + Stamp = Some 0L (* set the stamp to 0L on each run so we don't evaluate the whole project again *) + } + + let baselineModule = + $""" +module Benchmark0 +let returnValue = 5 +let myFunc0 () = 5""" + + let generateSourceCode number = + $""" +module Benchmark%i{number} +open Benchmark%i{number-1} +let myFunc%i{number} () = myFunc%i{number-1}() +//$COMMENTAREA$""" + +[] +[] +[] +[] +type FileCascadeBenchmarks() = + let mutable project : FSharpProjectOptions option = None + + let getProject() = project.Value + + let checker = FSharpChecker.Create(projectCacheSize = 5, enableParallelCheckingWithSignatureFiles = true, parallelReferenceResolution = true) + let filesToCreate = 64 + + let mutable finalFileContents = SourceText.ofString "" + + [] + member _.Setup() = + let projectFolder = Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(),"CascadeBenchmarkProject")) + if(projectFolder.Exists) then + do projectFolder.Delete(recursive=true) + do Directory.CreateDirectory(projectFolder.FullName) |> ignore + + let inProjectFolder fileName = Path.Combine(projectFolder.FullName,fileName) + + File.WriteAllText(inProjectFolder "Benchmark0.fs",baselineModule) + for i = 1 to filesToCreate do + File.WriteAllText(inProjectFolder $"Benchmark%i{i}.fs", generateSourceCode i) + + let dllFileName = inProjectFolder "CascadingBenchMark.dll" + let allSourceCodeFiles = [| for i in 0 .. filesToCreate -> inProjectFolder $"Benchmark%i{i}.fs"|] + let x = createProject allSourceCodeFiles dllFileName + project <- Some x + finalFileContents <- generateSourceCode filesToCreate |> SourceText.ofString + + + member x.ChangeFile(fileIndex:int, action) = + let project = getProject() + let fileName = project.SourceFiles.[fileIndex] + let fullOriginalSource = File.ReadAllText(fileName) + try + File.WriteAllText(fileName, fullOriginalSource.Replace("$COMMENTAREA$","$FILEMODIFIED")) + action() + finally + File.WriteAllText(fileName,fullOriginalSource) + + member x.CheckFinalFile () = + let project = getProject() + let lastFile = project.SourceFiles |> Array.last + checker.ParseAndCheckFileInProject(lastFile,999,finalFileContents,project) + + [] + member x.ParseProjectAsIs() = + x.CheckFinalFile() + + [] + member x.ParseProjectWithFullCacheClear() = + checker.ClearCache([getProject()]) + checker.InvalidateConfiguration(getProject()) + x.CheckFinalFile() + + [] + member x.ParseProjectWithChangingFirstFile() = + x.ChangeFile(fileIndex=0, action= fun () -> x.CheckFinalFile()) + + [] + member x.ParseProjectWithChanging25thPercentileFile() = + x.ChangeFile(fileIndex=filesToCreate/4, action= fun () -> x.CheckFinalFile()) + + [] + member x.ParseProjectWithChangingMiddleFile() = + x.ChangeFile(fileIndex=filesToCreate/2, action= fun () -> x.CheckFinalFile()) \ No newline at end of file From 5f54b69c67b3bae7321906ea35874ff33457cdb9 Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Thu, 13 Oct 2022 12:11:37 +0200 Subject: [PATCH 4/8] Fixed bug in examples for pick and tryPick (#14080) Co-authored-by: Kevin Ransom (msft) --- src/FSharp.Core/list.fsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/FSharp.Core/list.fsi b/src/FSharp.Core/list.fsi index db6a16c2bcb..782a035e891 100644 --- a/src/FSharp.Core/list.fsi +++ b/src/FSharp.Core/list.fsi @@ -1674,7 +1674,7 @@ module List = /// /// let input = [1; 2; 3] /// - /// input |> List.pick (fun n -> if n > 3 = 0 then Some (string n) else None) + /// input |> List.pick (fun n -> if n > 3 then Some (string n) else None) /// /// Throws KeyNotFoundException. /// @@ -2300,7 +2300,7 @@ module List = /// /// let input = [1; 2; 3] /// - /// input |> List.tryPick (fun n -> if n > 3 = 0 then Some (string n) else None) + /// input |> List.tryPick (fun n -> if n > 3 then Some (string n) else None) /// /// Evaluates to None. /// From 80c3d34989a79dbde8fb797ac32a5a465d33ee51 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Thu, 13 Oct 2022 13:08:14 +0200 Subject: [PATCH 5/8] Compiler error for signature/implementation files when declaring multiple parameters with the same name in abstract methods (#14084) --- src/Compiler/Checking/CheckDeclarations.fs | 31 +++- src/Compiler/FSComp.txt | 3 +- src/Compiler/xlf/FSComp.txt.cs.xlf | 5 + src/Compiler/xlf/FSComp.txt.de.xlf | 5 + src/Compiler/xlf/FSComp.txt.es.xlf | 5 + src/Compiler/xlf/FSComp.txt.fr.xlf | 5 + src/Compiler/xlf/FSComp.txt.it.xlf | 5 + src/Compiler/xlf/FSComp.txt.ja.xlf | 5 + src/Compiler/xlf/FSComp.txt.ko.xlf | 5 + src/Compiler/xlf/FSComp.txt.pl.xlf | 5 + src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 5 + src/Compiler/xlf/FSComp.txt.ru.xlf | 5 + src/Compiler/xlf/FSComp.txt.tr.xlf | 5 + src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 5 + src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 5 + .../MethodsAndProperties.fs | 159 ++++++++++++++++++ 16 files changed, 254 insertions(+), 4 deletions(-) diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index ac0080ca829..3bb776b2399 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -395,7 +395,22 @@ let CheckDuplicates (idf: _ -> Ident) k elems = errorR (Duplicate(k, id1.idText, id1.idRange)))) elems - +let private CheckDuplicatesArgNames (synVal: SynValSig) m = + let argNames = synVal.SynInfo.ArgNames |> List.duplicates + for name in argNames do + errorR(Error((FSComp.SR.chkDuplicatedMethodParameter(name), m))) + +let private CheckDuplicatesAbstractMethodParmsSig (typeSpecs: SynTypeDefnSig list) = + for SynTypeDefnSig(typeRepr= trepr) in typeSpecs do + match trepr with + | SynTypeDefnSigRepr.ObjectModel(_, synMemberSigs, _) -> + for sms in synMemberSigs do + match sms with + | SynMemberSig.Member(synValSig, _, m) -> + CheckDuplicatesArgNames synValSig m + | _ -> () + | _ -> () + module TcRecdUnionAndEnumDeclarations = let CombineReprAccess parent vis = @@ -3946,6 +3961,14 @@ module TcDeclarations = | SynMemberDefn.NestedType (range=m) :: _ -> errorR(Error(FSComp.SR.tcTypesCannotContainNestedTypes(), m)) | _ -> () | ds -> + // Check for duplicated parameters in abstract methods + for slot in ds do + if isAbstractSlot slot then + match slot with + | SynMemberDefn.AbstractSlot (synVal, _, m) -> + CheckDuplicatesArgNames synVal m + | _ -> () + // Classic class construction let _, ds = List.takeUntil (allFalse [isMember;isAbstractSlot;isInterface;isInherit;isField;isTycon]) ds match ds with @@ -4351,7 +4374,8 @@ let rec TcSignatureElementNonMutRec (cenv: cenv) parent typeNames endm (env: TcE let _, _, _, env = TcExceptionDeclarations.TcExnSignature cenv env parent emptyUnscopedTyparEnv (edef, scopem) return env - | SynModuleSigDecl.Types (typeSpecs, m) -> + | SynModuleSigDecl.Types (typeSpecs, m) -> + CheckDuplicatesAbstractMethodParmsSig typeSpecs let scopem = unionRanges m endm let mutRecDefns = typeSpecs |> List.map MutRecShape.Tycon let env = TcDeclarations.TcMutRecSignatureDecls cenv env parent typeNames emptyUnscopedTyparEnv m scopem None mutRecDefns @@ -4521,7 +4545,8 @@ and TcSignatureElementsMutRec cenv parent typeNames m mutRecNSInfo envInitial (d let rec loop isNamespace moduleRange defs: MutRecSigsInitialData = ((true, true), defs) ||> List.collectFold (fun (openOk, moduleAbbrevOk) def -> match def with - | SynModuleSigDecl.Types (typeSpecs, _) -> + | SynModuleSigDecl.Types (typeSpecs, _) -> + CheckDuplicatesAbstractMethodParmsSig typeSpecs let decls = typeSpecs |> List.map MutRecShape.Tycon decls, (false, false) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 2e3267b01a7..f79a7068cf6 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1656,4 +1656,5 @@ reprStateMachineInvalidForm,"The state machine has an unexpected form" 3546,parsExpectingPatternInTuple,"Expecting pattern" 3547,parsExpectedPatternAfterToken,"Expected a pattern after this point" 3548,matchNotAllowedForUnionCaseWithNoData,"Pattern discard is not allowed for union case that takes no data." -3549,tcSynTypeOrInvalidInDeclaration,"SynType.Or is not permitted in this declaration" \ No newline at end of file +3549,tcSynTypeOrInvalidInDeclaration,"SynType.Or is not permitted in this declaration" +3550,chkDuplicatedMethodParameter,"Duplicate parameter. The parameter '%s' has been used more that once in this method." diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 1489085bcb7..9ecac5b6c31 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -12,6 +12,11 @@ Soubor {0} má nerozpoznanou příponu. Zdrojové soubory musí mít příponu .fs, .fsi, .fsx nebo .fsscript. + + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + + Feature '{0}' is not available in F# {1}. Please use language version {2} or greater. Funkce {0} není v jazyce F# {1} dostupná. Použijte prosím jazyk verze {2} nebo vyšší. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 00da1cbd6af..4f7c728edf8 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -12,6 +12,11 @@ Die Dateierweiterung von „{0}“ wurde nicht erkannt. Quelldateien müssen die Erweiterung .fs, .fsi, .fsx oder .fsscript haben + + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + + Feature '{0}' is not available in F# {1}. Please use language version {2} or greater. Das Feature "{0}" ist in F# {1} nicht verfügbar. Verwenden Sie Sprachversion {2} oder höher. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index f6cdcdddad2..e57459c4a2b 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -12,6 +12,11 @@ No se reconoce la extensión de archivo de '{0}'. Los archivos de código fuente deben tener las extensiones .fs, .fsi, .fsx o .fsscript + + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + + Feature '{0}' is not available in F# {1}. Please use language version {2} or greater. La característica "{0}" no está disponible en F# {1}. Use la versión {2} del lenguaje o una posterior. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index ec74d45bf45..b93761c594a 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -12,6 +12,11 @@ L'extension de fichier de '{0}' n'est pas reconnue. Les fichiers sources doivent avoir l'extension .fs, .fsi, .fsx, ou .fsscript. + + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + + Feature '{0}' is not available in F# {1}. Please use language version {2} or greater. La fonctionnalité '{0}' n'est pas disponible en F# {1}. Utilisez la version de langage {2} ou une version ultérieure. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 4a810e60fcc..1801e06c6f6 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -12,6 +12,11 @@ Estensione di file di '{0}' non riconosciuta. I file di origine devono avere estensione .fs, .fsi, .fsx or .fsscript + + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + + Feature '{0}' is not available in F# {1}. Please use language version {2} or greater. La funzionalità '{0}' non è disponibile in F# {1}. Usare la versione {2} o versioni successive del linguaggio. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 0fc08e21cfe..b3d3c99155b 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -12,6 +12,11 @@ '{0}' のファイル拡張子は認識されません。ソース ファイルの拡張子は .fs、.fsi、.fsx、または .fsscript にする必要があります。 + + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + + Feature '{0}' is not available in F# {1}. Please use language version {2} or greater. 機能 '{0}' は F# {1} では使用できません。{2} 以上の言語バージョンをお使いください。 diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 9a5deaa0421..cfa2326e06a 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -12,6 +12,11 @@ '{0}'의 파일 확장명을 인식할 수 없습니다. 원본 파일의 확장명은 .fs, .fsi, .fsx 또는 .fsscript여야 합니다. + + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + + Feature '{0}' is not available in F# {1}. Please use language version {2} or greater. '{0}' 기능은 F# {1}에서 사용할 수 없습니다. {2} 이상의 언어 버전을 사용하세요. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 7f869a057f2..b530606c2b9 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -12,6 +12,11 @@ Rozszerzenie pliku "{0}" nie zostało rozpoznane. Pliki źródłowe muszą mieć rozszerzenie .fs, .fsi, .fsx lub .fsscript + + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + + Feature '{0}' is not available in F# {1}. Please use language version {2} or greater. Funkcja „{0}” nie jest dostępna w języku F# {1}. Użyj języka w wersji {2} lub nowszej. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 165404290f0..f7379662f5a 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -12,6 +12,11 @@ A extensão do arquivo de '{0}' não foi reconhecida. Os arquivos de origem devem ter a extensão .fs, .fsi, .fsx or .fsscript + + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + + Feature '{0}' is not available in F# {1}. Please use language version {2} or greater. O recurso '{0}' não está disponível no F# {1}. Use a versão da linguagem {2} ou superior. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 52876a45a7d..f0d9472c167 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -12,6 +12,11 @@ Расширение файла "{0}" не распознано. Исходные файлы должны иметь расширения FS, FSI, FSX или FSSCRIPT + + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + + Feature '{0}' is not available in F# {1}. Please use language version {2} or greater. Компонент "{0}" недоступен в F# {1}. Используйте версию языка {2} или выше. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 1c7303bf2fb..4cbfd16f9fa 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -12,6 +12,11 @@ '{0}' kaynak dosyasının dosya uzantısı tanınmadı. Kaynak dosyaların uzantısı .fs, .fsi, .fsx veya .fsscript olmalıdır. + + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + + Feature '{0}' is not available in F# {1}. Please use language version {2} or greater. '{0}' özelliği F# {1} sürümünde kullanılamıyor. Lütfen {2} veya daha yüksek bir dil sürümünü kullanın. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 45189c5d7dd..499dbad9df2 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -12,6 +12,11 @@ 无法识别“{0}”的文件扩展名。源文件必须具有扩展名 .fs、.fsi、.fsx 或 .fsscript + + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + + Feature '{0}' is not available in F# {1}. Please use language version {2} or greater. 功能“{0}”在 F# {1} 中不可用。请使用 {2} 或更高的语言版本。 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 27040f48efe..aba607cb582 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -12,6 +12,11 @@ 無法辨識 '{0}' 的副檔名。來源檔案的副檔名必須是 .fs、.fsi、.fsx 或 .fsscript。 + + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + Duplicate parameter. The parameter '{0}' has been used more that once in this method. + + Feature '{0}' is not available in F# {1}. Please use language version {2} or greater. F# {1} 中無法使用 '{0}' 功能。請使用語言版本 {2} 或更新的版本。 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs index 363e045f26a..fee65b3ad49 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/MethodsAndProperties.fs @@ -414,4 +414,163 @@ module MethodsAndProperties = |> verifyCompileAndRun |> shouldSucceed + [] + let ``Error in implementation file with abstract methods when reusing parameters`` () = + Fsx """ +namespace Foo +type I = + // Tupled. + abstract M : i:int * i:int -> int + // Curried. + abstract N : i:int -> i:int -> int + // More than two. + abstract O : i:int * i: int * i:int -> int + // Multiple distinct names repeated. + abstract P : i:int * j:int * i:int * j:int -> int + """ + |> compile + |> shouldFail + |> withDiagnostics [ + (Error 3550, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3550, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3550, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3550, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3550, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") + ] + + [] + let ``Error in signature file with no implementation file with abstract methods when reusing parameters`` () = + let encodeFsi = + Fsi """ +namespace Foo +type I = + // Tupled. + abstract M : i:int * i:int -> int + // Curried. + abstract N : i:int -> i:int -> int + // More than two. + abstract O : i:int * i: int * i:int -> int + // Multiple distinct names repeated. + abstract P : i:int * j:int * i:int * j:int -> int + """ + encodeFsi + |> verifyCompile + |> shouldFail + |> withDiagnostics [ + (Error 3550, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3550, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3550, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3550, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3550, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") + (Error 240, Line 2, Col 1, Line 11, Col 54, "The signature file 'Test' does not have a corresponding implementation file. If an implementation file exists then check the 'module' and 'namespace' declarations in the signature and implementation files match.") + ] + + [] + let ``Error in signature file with not implementation file with abstract methods when reusing parameters in recursive namespace`` () = + let encodeFsi = + Fsi """ +namespace rec Foo +type I = + // Tupled. + abstract M : i:int * i:int -> int + // Curried. + abstract N : i:int -> i:int -> int + // More than two. + abstract O : i:int * i: int * i:int -> int + // Multiple distinct names repeated. + abstract P : i:int * j:int * i:int * j:int -> int + """ + encodeFsi + |> verifyCompile + |> shouldFail + |> withDiagnostics [ + (Error 3550, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3550, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3550, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3550, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3550, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") + (Error 240, Line 2, Col 1, Line 11, Col 54, "The signature file 'Test' does not have a corresponding implementation file. If an implementation file exists then check the 'module' and 'namespace' declarations in the signature and implementation files match.") + ] + + [] + let ``Errors in signature and implementation files with abstract methods when reusing parameters`` () = + let encodeFsi = + Fsi """ +namespace Foo +type I = + // Tupled. + abstract M : i:int * i:int -> int + // Curried. + abstract N : i:int -> i:int -> int + // More than two. + abstract O : i:int * i: int * i:int -> int + // Multiple distinct names repeated. + abstract P : i:int * j:int * i:int * j:int -> int + """ + let encodeFs = + FsSource """ +namespace Foo +type I = + abstract M : i:int * i:int -> int + abstract N : i:int -> i:int -> int + abstract O : i:int * i: int * i:int -> int + abstract P : i:int * j:int * i:int * j:int -> int + """ + encodeFsi + |> withAdditionalSourceFile encodeFs + |> compile + |> shouldFail + |> withDiagnostics [ + (Error 3550, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3550, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3550, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3550, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3550, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") + (Error 3550, Line 4, Col 5, Line 4, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3550, Line 5, Col 5, Line 5, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3550, Line 6, Col 5, Line 6, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3550, Line 7, Col 5, Line 7, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3550, Line 7, Col 5, Line 7, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") + ] + + [] + let ``Errors in signature and implementation files with abstract methods when reusing parameters in recursive namespaces`` () = + let encodeFsi = + Fsi """ +namespace rec Foo +type I = + // Tupled. + abstract M : i:int * i:int -> int + // Curried. + abstract N : i:int -> i:int -> int + // More than two. + abstract O : i:int * i: int * i:int -> int + // Multiple distinct names repeated. + abstract P : i:int * j:int * i:int * j:int -> int + """ + let encodeFs = + FsSource """ +namespace rec Foo +type I = + abstract M : i:int * i:int -> int + abstract N : i:int -> i:int -> int + abstract O : i:int * i: int * i:int -> int + abstract P : i:int * j:int * i:int * j:int -> int + """ + encodeFsi + |> withAdditionalSourceFile encodeFs + |> compile + |> shouldFail + |> withDiagnostics [ + (Error 3550, Line 5, Col 5, Line 5, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3550, Line 7, Col 5, Line 7, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3550, Line 9, Col 5, Line 9, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3550, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3550, Line 11, Col 5, Line 11, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") + (Error 3550, Line 4, Col 5, Line 4, Col 38, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3550, Line 5, Col 5, Line 5, Col 39, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3550, Line 6, Col 5, Line 6, Col 47, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3550, Line 7, Col 5, Line 7, Col 54, "Duplicate parameter. The parameter 'i' has been used more that once in this method.") + (Error 3550, Line 7, Col 5, Line 7, Col 54, "Duplicate parameter. The parameter 'j' has been used more that once in this method.") + ] From 05201993cfaac663c72b6431d81f543e3d001dfe Mon Sep 17 00:00:00 2001 From: Florian Verdonck Date: Thu, 13 Oct 2022 15:47:45 +0200 Subject: [PATCH 6/8] Leading keyword synbinding (#14056) * Add SynLeadingKeyword * Add StaticLet and StaticLetRec. * Add Do and StaticDo. * Trigger CI * Format SyntaxTrivia. * Update Surface area. * Trigger CI Co-authored-by: Tomas Grosup --- .../Checking/AugmentWithHashCompare.fs | 7 +- src/Compiler/Checking/CheckDeclarations.fs | 20 +- src/Compiler/Checking/CheckExpressions.fs | 4 +- .../Checking/CheckIncrementalClasses.fs | 9 +- .../Service/ServiceInterfaceStubGenerator.fs | 2 +- src/Compiler/Service/ServiceNavigation.fs | 14 +- src/Compiler/Service/ServiceParseTreeWalk.fs | 2 +- src/Compiler/Service/ServiceParsedInputOps.fs | 8 +- src/Compiler/Service/ServiceStructure.fs | 4 +- src/Compiler/SyntaxTree/ParseHelpers.fs | 60 +- src/Compiler/SyntaxTree/ParseHelpers.fsi | 17 +- src/Compiler/SyntaxTree/SyntaxTree.fs | 11 +- src/Compiler/SyntaxTree/SyntaxTree.fsi | 12 +- src/Compiler/SyntaxTree/SyntaxTreeOps.fs | 97 +-- src/Compiler/SyntaxTree/SyntaxTreeOps.fsi | 31 +- src/Compiler/SyntaxTree/SyntaxTrivia.fs | 103 +++- src/Compiler/SyntaxTree/SyntaxTrivia.fsi | 94 ++- src/Compiler/TypedTree/TypedTreePickle.fs | 4 +- src/Compiler/pars.fsy | 180 +++--- .../FSharp.Compiler.Service.Tests.fsproj | 3 + ...erService.SurfaceArea.netstandard.expected | 291 +++++++-- tests/service/SyntaxTreeTests/BindingTests.fs | 7 +- tests/service/SyntaxTreeTests/ExternTests.fs | 2 +- .../SyntaxTreeTests/LeadingKeywordTests.fs | 561 ++++++++++++++++++ .../SyntaxTreeTests/MemberFlagTests.fs | 71 ++- tests/service/SyntaxTreeTests/MemberTests.fs | 6 +- .../SyntaxTreeTests/SignatureTypeTests.fs | 3 +- tests/service/TreeVisitorTests.fs | 2 +- 28 files changed, 1236 insertions(+), 389 deletions(-) create mode 100644 tests/service/SyntaxTreeTests/LeadingKeywordTests.fs diff --git a/src/Compiler/Checking/AugmentWithHashCompare.fs b/src/Compiler/Checking/AugmentWithHashCompare.fs index 59d74eb0335..dd81dc0a575 100644 --- a/src/Compiler/Checking/AugmentWithHashCompare.fs +++ b/src/Compiler/Checking/AugmentWithHashCompare.fs @@ -7,7 +7,6 @@ open Internal.Utilities.Library open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler.DiagnosticsLogger open FSharp.Compiler.Syntax -open FSharp.Compiler.SyntaxTrivia open FSharp.Compiler.Xml open FSharp.Compiler.TcGlobals open FSharp.Compiler.TypedTree @@ -856,8 +855,7 @@ let slotImplMethod (final, c, slotsig) : ValMemberInfo = IsFinal=final IsOverrideOrExplicitImpl=true GetterOrSetterIsCompilerGenerated=false - MemberKind=SynMemberKind.Member - Trivia=SynMemberFlagsTrivia.Zero} + MemberKind=SynMemberKind.Member } IsImplemented=false ApparentEnclosingEntity=c} @@ -868,8 +866,7 @@ let nonVirtualMethod c : ValMemberInfo = IsFinal=false IsOverrideOrExplicitImpl=false GetterOrSetterIsCompilerGenerated=false - MemberKind=SynMemberKind.Member - Trivia=SynMemberFlagsTrivia.Zero} + MemberKind=SynMemberKind.Member } IsImplemented=false ApparentEnclosingEntity=c} diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index 3bb776b2399..11a372bb5c5 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -452,13 +452,13 @@ module TcRecdUnionAndEnumDeclarations = | _ -> () rfspec - let TcAnonFieldDecl cenv env parent tpenv nm (SynField(Attributes attribs, isStatic, idOpt, ty, isMutable, xmldoc, vis, m)) = + let TcAnonFieldDecl cenv env parent tpenv nm (SynField(Attributes attribs, isStatic, idOpt, ty, isMutable, xmldoc, vis, m, _)) = let mName = m.MakeSynthetic() let id = match idOpt with None -> mkSynId mName nm | Some id -> id let xmlDoc = xmldoc.ToXmlDoc(true, Some []) TcFieldDecl cenv env parent false tpenv (isStatic, attribs, id, idOpt.IsNone, ty, isMutable, xmlDoc, vis, m) - let TcNamedFieldDecl cenv env parent isIncrClass tpenv (SynField(Attributes attribs, isStatic, id, ty, isMutable, xmldoc, vis, m)) = + let TcNamedFieldDecl cenv env parent isIncrClass tpenv (SynField(Attributes attribs, isStatic, id, ty, isMutable, xmldoc, vis, m, _)) = match id with | None -> error (Error(FSComp.SR.tcFieldRequiresName(), m)) | Some id -> @@ -494,10 +494,10 @@ module TcRecdUnionAndEnumDeclarations = match seen.TryGetValue f.LogicalName with | true, synField -> match sf, synField with - | SynField(_, _, Some id, _, _, _, _, _), SynField(_, _, Some _, _, _, _, _, _) -> + | SynField(idOpt = Some id), SynField(idOpt = Some _) -> error(Error(FSComp.SR.tcFieldNameIsUsedModeThanOnce(id.idText), id.idRange)) - | SynField(_, _, Some id, _, _, _, _, _), SynField(_, _, None, _, _, _, _, _) - | SynField(_, _, None, _, _, _, _, _), SynField(_, _, Some id, _, _, _, _, _) -> + | SynField(idOpt = Some id), SynField(idOpt = None) + | SynField(idOpt = None), SynField(idOpt = Some id) -> error(Error(FSComp.SR.tcFieldNameConflictsWithGeneratedNameForAnonymousField(id.idText), id.idRange)) | _ -> assert false | _ -> @@ -2377,7 +2377,7 @@ module EstablishTypeDefinitionCores = for SynUnionCase (caseType=args; range=m) in unionCases do match args with | SynUnionCaseKind.Fields flds -> - for SynField(_, _, _, ty, _, _, _, m) in flds do + for SynField(fieldType = ty; range = m) in flds do let tyR, _ = TcTypeAndRecover cenv NoNewTypars NoCheckCxs ItemOccurence.UseInType WarnOnIWSAM.Yes env tpenv ty yield (tyR, m) @@ -2394,7 +2394,7 @@ module EstablishTypeDefinitionCores = | SynTypeDefnSimpleRepr.General (_, _, _, fields, _, _, implicitCtorSynPats, _) when tycon.IsFSharpStructOrEnumTycon -> // for structs for field in fields do - let (SynField(_, isStatic, _, ty, _, _, _, m)) = field + let (SynField(isStatic = isStatic; fieldType = ty; range = m)) = field if not isStatic then let tyR, _ = TcTypeAndRecover cenv NoNewTypars NoCheckCxs ItemOccurence.UseInType WarnOnIWSAM.Yes env tpenv ty yield (tyR, m) @@ -2414,7 +2414,7 @@ module EstablishTypeDefinitionCores = yield (ty, m) | SynTypeDefnSimpleRepr.Record (_, fields, _) -> - for SynField(_, _, _, ty, _, _, _, m) in fields do + for SynField(fieldType = ty; range = m) in fields do let tyR, _ = TcTypeAndRecover cenv NoNewTypars NoCheckCxs ItemOccurence.UseInType WarnOnIWSAM.Yes env tpenv ty yield (tyR, m) @@ -3998,7 +3998,7 @@ module TcDeclarations = | SynTypeDefnRepr.ObjectModel(kind, cspec, m) -> let cspec = desugarGetSetMembers cspec CheckMembersForm cspec - let fields = cspec |> List.choose (function SynMemberDefn.ValField (f, _) -> Some f | _ -> None) + let fields = cspec |> List.choose (function SynMemberDefn.ValField (fieldInfo = f) -> Some f | _ -> None) let implements2 = cspec |> List.choose (function SynMemberDefn.Interface (interfaceType=ty) -> Some(ty, ty.Range) | _ -> None) let inherits = cspec |> List.choose (function @@ -4056,7 +4056,7 @@ module TcDeclarations = // Convert auto properties to member bindings in the post-list let rec postAutoProps memb = match memb with - | SynMemberDefn.AutoProperty(attributes=Attributes attribs; isStatic=isStatic; ident=id; typeOpt=tyOpt; propKind=propKind; memberFlags=memberFlags; memberFlagsForSet=memberFlagsForSet; xmlDoc=xmlDoc; accessibility=access; getSetRange=mGetSetOpt) -> + | SynMemberDefn.AutoProperty(attributes=Attributes attribs; isStatic=isStatic; ident=id; typeOpt=tyOpt; propKind=propKind; memberFlags=memberFlags; memberFlagsForSet=memberFlagsForSet; xmlDoc=xmlDoc; accessibility=access; trivia = { GetSetKeyword = mGetSetOpt }) -> let mMemberPortion = id.idRange // Only the keep the non-field-targeted attributes let attribs = attribs |> List.filter (fun a -> match a.Target with Some t when t.idText = "field" -> false | _ -> true) diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index a83ef7d669b..9e6524f2627 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -6705,7 +6705,7 @@ and TcObjectExprBinding (cenv: cenv) (env: TcEnv) implTy tpenv (absSlotInfo, bin | SynPat.Named (SynIdent(id,_), _, _, _), None -> let bindingRhs = PushOnePatternToRhs cenv true (mkSynThisPatVar (ident (CompilerGeneratedName "this", id.idRange))) bindingRhs let logicalMethId = id - let memberFlags = OverrideMemberFlags SynMemberFlagsTrivia.Zero SynMemberKind.Member + let memberFlags = OverrideMemberFlags SynMemberKind.Member bindingRhs, logicalMethId, memberFlags | SynPat.InstanceMember(thisId, memberId, _, _, _), Some memberFlags -> @@ -8579,7 +8579,7 @@ and TcImplicitOpItemThen (cenv: cenv) overallTy env id sln tpenv mItem delayed = let vs, ves = argTys |> List.mapi (fun i ty -> mkCompGenLocal mItem ("arg" + string i) ty) |> List.unzip - let memberFlags = StaticMemberFlags SynMemberFlagsTrivia.Zero SynMemberKind.Member + let memberFlags = StaticMemberFlags SynMemberKind.Member let logicalCompiledName = ComputeLogicalName id memberFlags let traitInfo = TTrait(argTys, logicalCompiledName, memberFlags, argTys, Some retTy, sln) diff --git a/src/Compiler/Checking/CheckIncrementalClasses.fs b/src/Compiler/Checking/CheckIncrementalClasses.fs index c58414dfb00..893cdc4e193 100644 --- a/src/Compiler/Checking/CheckIncrementalClasses.fs +++ b/src/Compiler/Checking/CheckIncrementalClasses.fs @@ -14,7 +14,6 @@ open FSharp.Compiler.CompilerGlobalState open FSharp.Compiler.DiagnosticsLogger open FSharp.Compiler.NameResolution open FSharp.Compiler.Syntax -open FSharp.Compiler.SyntaxTrivia open FSharp.Compiler.SyntaxTreeOps open FSharp.Compiler.Text open FSharp.Compiler.Xml @@ -122,7 +121,7 @@ let TcImplicitCtorLhs_Phase2A(cenv: cenv, env, tpenv, tcref: TyconRef, vis, attr // NOTE: no attributes can currently be specified for the implicit constructor let attribs = TcAttributes cenv env (AttributeTargets.Constructor ||| AttributeTargets.Method) attrs - let memberFlags = CtorMemberFlags SynMemberFlagsTrivia.Zero + let memberFlags = CtorMemberFlags let synArgInfos = List.map (SynInfo.InferSynArgInfoFromSimplePat []) spats let valSynData = SynValInfo([synArgInfos], SynInfo.unnamedRetVal) @@ -150,8 +149,8 @@ let TcImplicitCtorLhs_Phase2A(cenv: cenv, env, tpenv, tcref: TyconRef, vis, attr let cctorTy = mkFunTy g g.unit_ty g.unit_ty let valSynData = SynValInfo([[]], SynInfo.unnamedRetVal) let id = ident ("cctor", m) - CheckForNonAbstractInterface ModuleOrMemberBinding tcref (ClassCtorMemberFlags SynMemberFlagsTrivia.Zero) id.idRange - let memberInfo = MakeMemberDataAndMangledNameForMemberVal(g, tcref, false, [], [], (ClassCtorMemberFlags SynMemberFlagsTrivia.Zero), valSynData, id, false) + CheckForNonAbstractInterface ModuleOrMemberBinding tcref ClassCtorMemberFlags id.idRange + let memberInfo = MakeMemberDataAndMangledNameForMemberVal(g, tcref, false, [], [], ClassCtorMemberFlags, valSynData, id, false) let prelimValReprInfo = TranslateSynValInfo m (TcAttributes cenv env) valSynData let prelimTyschemeG = GeneralizedType(copyOfTyconTypars, cctorTy) let valReprInfo = InferGenericArityFromTyScheme prelimTyschemeG prelimValReprInfo @@ -323,7 +322,7 @@ type IncrClassReprInfo = let tps, _, argInfos, _, _ = GetValReprTypeInCompiledForm g valReprInfo 0 v.Type v.Range let valSynInfo = SynValInfo(argInfos |> List.mapSquared (fun (_, argInfo) -> SynArgInfo([], false, argInfo.Name)), SynInfo.unnamedRetVal) - let memberFlags = (if isStatic then StaticMemberFlags else NonVirtualMemberFlags) SynMemberFlagsTrivia.Zero SynMemberKind.Member + let memberFlags = (if isStatic then StaticMemberFlags else NonVirtualMemberFlags) SynMemberKind.Member let id = mkSynId v.Range name let memberInfo = MakeMemberDataAndMangledNameForMemberVal(g, tcref, false, [], [], memberFlags, valSynInfo, mkSynId v.Range name, true) diff --git a/src/Compiler/Service/ServiceInterfaceStubGenerator.fs b/src/Compiler/Service/ServiceInterfaceStubGenerator.fs index bf28a121d43..a5a3f8d844a 100644 --- a/src/Compiler/Service/ServiceInterfaceStubGenerator.fs +++ b/src/Compiler/Service/ServiceInterfaceStubGenerator.fs @@ -841,7 +841,7 @@ module InterfaceStubGenerator = | None, Some binding -> walkBinding binding | Some getBinding, Some setBinding -> walkBinding getBinding |> Option.orElseWith (fun () -> walkBinding setBinding) | SynMemberDefn.NestedType (typeDef, _access, _range) -> walkSynTypeDefn typeDef - | SynMemberDefn.ValField (_field, _range) -> None + | SynMemberDefn.ValField _ -> None | SynMemberDefn.LetBindings (bindings, _isStatic, _isRec, _range) -> List.tryPick walkBinding bindings | SynMemberDefn.Open _ | SynMemberDefn.ImplicitCtor _ diff --git a/src/Compiler/Service/ServiceNavigation.fs b/src/Compiler/Service/ServiceNavigation.fs index c38ce9793e2..8f5a4acb2b1 100755 --- a/src/Compiler/Service/ServiceNavigation.fs +++ b/src/Compiler/Service/ServiceNavigation.fs @@ -118,7 +118,7 @@ module NavigationImpl = match fldspec with | SynUnionCaseKind.Fields (flds) -> flds - |> List.fold (fun st (SynField (_, _, _, _, _, _, _, m)) -> unionRangesChecked m st) range.Zero + |> List.fold (fun st (SynField (range = m)) -> unionRangesChecked m st) range.Zero | SynUnionCaseKind.FullType (ty, _) -> ty.Range let bodyRange mBody decls = @@ -292,7 +292,7 @@ module NavigationImpl = | SynTypeDefnSimpleRepr.Record (_, fields, mBody) -> let fields = [ - for SynField (_, _, id, _, _, _, _, m) in fields do + for SynField (idOpt = id; range = m) in fields do match id with | Some ident -> yield createMember (ident, NavigationItemKind.Field, FSharpGlyph.Field, m, NavigationEntityKind.Record, false, access) | _ -> () @@ -328,7 +328,7 @@ module NavigationImpl = | SynMemberDefn.GetSetMember (Some bind, None, _, _) | SynMemberDefn.GetSetMember (None, Some bind, _, _) | SynMemberDefn.Member (bind, _) -> processBinding true enclosingEntityKind false bind - | SynMemberDefn.ValField (SynField (_, _, Some (rcid), _, _, _, access, range), _) -> + | SynMemberDefn.ValField(fieldInfo = SynField (idOpt = Some rcid; accessibility = access; range = range)) -> [ createMember (rcid, NavigationItemKind.Field, FSharpGlyph.Field, range, enclosingEntityKind, false, access) ] @@ -534,7 +534,7 @@ module NavigationImpl = | SynTypeDefnSimpleRepr.Record (_, fields, mBody) -> let fields = [ - for SynField (_, _, id, _, _, _, _, m) in fields do + for SynField (idOpt = id; range = m) in fields do match id with | Some ident -> yield createMember (ident, NavigationItemKind.Field, FSharpGlyph.Field, m, NavigationEntityKind.Record, false, access) | _ -> () @@ -559,7 +559,7 @@ module NavigationImpl = match memb with | SynMemberSig.Member (SynValSig.SynValSig (ident = SynIdent (id, _); accessibility = access; range = m), _, _) -> createMember (id, NavigationItemKind.Method, FSharpGlyph.Method, m, NavigationEntityKind.Class, false, access) - | SynMemberSig.ValField (SynField (_, _, Some (rcid), ty, _, _, access, _), _) -> + | SynMemberSig.ValField (SynField (idOpt = Some rcid; fieldType = ty; accessibility = access), _) -> createMember (rcid, NavigationItemKind.Field, FSharpGlyph.Field, ty.Range, NavigationEntityKind.Class, false, access) | _ -> () ] @@ -767,7 +767,7 @@ module NavigateTo = addIdent kind id isSig container let addField synField isSig container = - let (SynField (_, _, id, _, _, _, _, _)) = synField + let (SynField (idOpt = id)) = synField match id with | Some id -> addIdent NavigableItemKind.Field id isSig container @@ -993,7 +993,7 @@ module NavigateTo = Option.iter (fun b -> addBinding b None container) getBinding Option.iter (fun b -> addBinding b None container) setBinding | SynMemberDefn.NestedType (typeDef, _, _) -> walkSynTypeDefn typeDef container - | SynMemberDefn.ValField (field, _) -> addField field false container + | SynMemberDefn.ValField (fieldInfo = field) -> addField field false container | SynMemberDefn.LetBindings (bindings, _, _, _) -> bindings |> List.iter (fun binding -> addBinding binding (Some NavigableItemKind.Field) container) diff --git a/src/Compiler/Service/ServiceParseTreeWalk.fs b/src/Compiler/Service/ServiceParseTreeWalk.fs index 274d2741365..25e7544fb03 100755 --- a/src/Compiler/Service/ServiceParseTreeWalk.fs +++ b/src/Compiler/Service/ServiceParseTreeWalk.fs @@ -941,7 +941,7 @@ module SyntaxTraversal = |> pick x | ok -> ok | SynMemberDefn.Inherit (synType, _identOption, range) -> traverseInherit (synType, range) - | SynMemberDefn.ValField (_synField, _range) -> None + | SynMemberDefn.ValField _ -> None | SynMemberDefn.NestedType (synTypeDefn, _synAccessOption, _range) -> traverseSynTypeDefn path synTypeDefn and traverseSynMatchClause origPath mc = diff --git a/src/Compiler/Service/ServiceParsedInputOps.fs b/src/Compiler/Service/ServiceParsedInputOps.fs index 3ff647478a8..7317df67378 100644 --- a/src/Compiler/Service/ServiceParsedInputOps.fs +++ b/src/Compiler/Service/ServiceParsedInputOps.fs @@ -857,7 +857,7 @@ module ParsedInput = | _ -> None and walkField synField = - let (SynField (Attributes attrs, _, _, t, _, _, _, _)) = synField + let (SynField (attributes = Attributes attrs; fieldType = t)) = synField List.tryPick walkAttribute attrs |> Option.orElseWith (fun () -> walkType t) and walkValSig synValSig = @@ -906,7 +906,7 @@ module ParsedInput = | SynMemberDefn.Inherit (t, _, _) -> walkType t - | SynMemberDefn.ValField (field, _) -> walkField field + | SynMemberDefn.ValField (fieldInfo = field) -> walkField field | SynMemberDefn.NestedType (tdef, _, _) -> walkTypeDefn tdef @@ -1853,7 +1853,7 @@ module ParsedInput = walkType t | _ -> () - and walkField (SynField (Attributes attrs, _, _, t, _, _, _, _)) = + and walkField (SynField (attributes = Attributes attrs; fieldType = t)) = List.iter walkAttribute attrs walkType t @@ -1904,7 +1904,7 @@ module ParsedInput = walkType t members |> Option.iter (List.iter walkMember) | SynMemberDefn.Inherit (t, _, _) -> walkType t - | SynMemberDefn.ValField (field, _) -> walkField field + | SynMemberDefn.ValField (fieldInfo = field) -> walkField field | SynMemberDefn.NestedType (tdef, _, _) -> walkTypeDefn tdef | SynMemberDefn.AutoProperty (attributes = Attributes attrs; typeOpt = t; synExpr = e) -> List.iter walkAttribute attrs diff --git a/src/Compiler/Service/ServiceStructure.fs b/src/Compiler/Service/ServiceStructure.fs index 210f3f4f9e8..5e381130ed8 100644 --- a/src/Compiler/Service/ServiceStructure.fs +++ b/src/Compiler/Service/ServiceStructure.fs @@ -639,7 +639,7 @@ module Structure = | SynTypeDefnSimpleRepr.Record (_, fields, rr) -> rcheck Scope.RecordDefn Collapse.Same rr rr - for SynField (attrs, _, _, _, _, _, _, fr) in fields do + for SynField (attributes = attrs; range = fr) in fields do rcheck Scope.RecordField Collapse.Below fr fr parseAttributes attrs @@ -893,7 +893,7 @@ module Structure = | SynMemberSig.Member (valSigs, _, r) -> let collapse = Range.endToEnd valSigs.RangeOfId r rcheck Scope.Member Collapse.Below r collapse - | SynMemberSig.ValField (SynField (attrs, _, _, _, _, _, _, fr), mFull) -> + | SynMemberSig.ValField (SynField (attributes = attrs; range = fr), mFull) -> let collapse = Range.endToEnd fr mFull rcheck Scope.Val Collapse.Below mFull collapse parseAttributes attrs diff --git a/src/Compiler/SyntaxTree/ParseHelpers.fs b/src/Compiler/SyntaxTree/ParseHelpers.fs index ca0b858a0ba..b97bfe2f7c8 100644 --- a/src/Compiler/SyntaxTree/ParseHelpers.fs +++ b/src/Compiler/SyntaxTree/ParseHelpers.fs @@ -428,7 +428,7 @@ let mkSynMemberDefnGetSet (propertyNameBindingPat: SynPat) (optPropertyType: SynReturnInfo option) (visNoLongerUsed: SynAccess option) - (memFlagsBuilder: SynMemberKind -> SynMemberFlags) + flagsBuilderAndLeadingKeyword (attrs: SynAttributeList list) (rangeStart: range) : SynMemberDefn list = @@ -436,6 +436,7 @@ let mkSynMemberDefnGetSet let mutable hasGet = false let mutable hasSet = false + let memFlagsBuilder, leadingKeyword = flagsBuilderAndLeadingKeyword let xmlDoc = grabXmlDocAtRangeStart (parseState, attrs, rangeStart) let tryMkSynMemberDefnMember @@ -467,9 +468,8 @@ let mkSynMemberDefnGetSet let trivia: SynBindingTrivia = { - LetKeyword = None + LeadingKeyword = leadingKeyword EqualsRange = mEquals - ExternKeyword = None } let binding = @@ -540,13 +540,6 @@ let mkSynMemberDefnGetSet | _ -> optReturnType // REDO with the correct member kind - let trivia: SynBindingTrivia = - { - LetKeyword = None - EqualsRange = mEquals - ExternKeyword = None - } - let binding = mkSynBinding (PreXmlDoc.Empty, bindingPat) @@ -627,14 +620,6 @@ let mkSynMemberDefnGetSet // replacing the get/set identifier. A little gross. let (bindingPatAdjusted, getOrSetIdentOpt), xmlDocAdjusted = - - let trivia: SynBindingTrivia = - { - LetKeyword = None - EqualsRange = mEquals - ExternKeyword = None - } - let bindingOuter = mkSynBinding (xmlDoc, propertyNameBindingPat) @@ -894,7 +879,7 @@ let mkUnderscoreRecdField m = let mkRecdField (lidwd: SynLongIdent) = lidwd, true // Used for 'do expr' in a class. -let mkSynDoBinding (vis: SynAccess option, expr, m) = +let mkSynDoBinding (vis: SynAccess option, mDo, expr, m) = match vis with | Some vis -> errorR (Error(FSComp.SR.parsDoCannotHaveVisibilityDeclarations (vis.ToString()), m)) | None -> () @@ -912,7 +897,10 @@ let mkSynDoBinding (vis: SynAccess option, expr, m) = expr, m, DebugPointAtBinding.NoneAtDo, - SynBindingTrivia.Zero + { + LeadingKeyword = SynLeadingKeyword.Do mDo + EqualsRange = None + } ) let mkSynExprDecl (e: SynExpr) = SynModuleDecl.Expr(e, e.Range) @@ -997,6 +985,30 @@ let mkClassMemberLocalBindings if isUse then errorR (Error(FSComp.SR.parsUseBindingsIllegalInImplicitClassConstructors (), mWhole)) + let decls = + match initialRangeOpt, decls with + | _, [] -> [] + | Some mStatic, SynBinding (a0, k, il, im, a, x, v, h, ri, e, m, dp, trivia) :: rest -> + // prepend static keyword to existing leading keyword. + let trivia = + match trivia.LeadingKeyword with + | SynLeadingKeyword.LetRec (mLet, mRec) -> + { trivia with + LeadingKeyword = SynLeadingKeyword.StaticLetRec(mStatic, mLet, mRec) + } + | SynLeadingKeyword.Let mLet -> + { trivia with + LeadingKeyword = SynLeadingKeyword.StaticLet(mStatic, mLet) + } + | SynLeadingKeyword.Do mDo -> + { trivia with + LeadingKeyword = SynLeadingKeyword.StaticDo(mStatic, mDo) + } + | _ -> trivia + + SynBinding(a0, k, il, im, a, x, v, h, ri, e, m, dp, trivia) :: rest + | None, decls -> decls + SynMemberDefn.LetBindings(decls, isStatic, isRec, mWhole) let mkLocalBindings (mWhole, BindingSetPreAttrs (_, isRec, isUse, declsPreAttrs, _), mIn, body: SynExpr) = @@ -1056,3 +1068,11 @@ let checkForMultipleAugmentations m a1 a2 = let rangeOfLongIdent (lid: LongIdent) = System.Diagnostics.Debug.Assert(not lid.IsEmpty, "the parser should never produce a long-id that is the empty list") (lid.Head.idRange, lid) ||> unionRangeWithListBy (fun id -> id.idRange) + +let appendValToLeadingKeyword mVal leadingKeyword = + match leadingKeyword with + | SynLeadingKeyword.StaticMember (mStatic, mMember) -> SynLeadingKeyword.StaticMemberVal(mStatic, mMember, mVal) + | SynLeadingKeyword.Member mMember -> SynLeadingKeyword.MemberVal(mMember, mVal) + | SynLeadingKeyword.Override mOverride -> SynLeadingKeyword.OverrideVal(mOverride, mVal) + | SynLeadingKeyword.Default (mDefault) -> SynLeadingKeyword.DefaultVal(mDefault, mVal) + | _ -> leadingKeyword diff --git a/src/Compiler/SyntaxTree/ParseHelpers.fsi b/src/Compiler/SyntaxTree/ParseHelpers.fsi index b5f9bac57f9..1192608dbfb 100644 --- a/src/Compiler/SyntaxTree/ParseHelpers.fsi +++ b/src/Compiler/SyntaxTree/ParseHelpers.fsi @@ -4,6 +4,7 @@ module internal FSharp.Compiler.ParseHelpers open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler.Syntax +open FSharp.Compiler.SyntaxTrivia open FSharp.Compiler.Features open FSharp.Compiler.Text open FSharp.Compiler.Xml @@ -84,7 +85,7 @@ module LexbufIfdefStore = val SaveEndIfHash: lexbuf: UnicodeLexing.Lexbuf * lexed: string * range: range -> unit - val GetTrivia: lexbuf: UnicodeLexing.Lexbuf -> SyntaxTrivia.ConditionalDirectiveTrivia list + val GetTrivia: lexbuf: UnicodeLexing.Lexbuf -> ConditionalDirectiveTrivia list module LexbufCommentStore = @@ -92,7 +93,7 @@ module LexbufCommentStore = val SaveBlockComment: lexbuf: UnicodeLexing.Lexbuf * startRange: range * endRange: range -> unit - val GetComments: lexbuf: UnicodeLexing.Lexbuf -> SyntaxTrivia.CommentTrivia list + val GetComments: lexbuf: UnicodeLexing.Lexbuf -> CommentTrivia list val ClearComments: lexbuf: UnicodeLexing.Lexbuf -> unit @@ -171,10 +172,10 @@ val mkSynMemberDefnGetSet: propertyNameBindingPat: SynPat -> optPropertyType: SynReturnInfo option -> visNoLongerUsed: SynAccess option -> - memFlagsBuilder: (SynMemberKind -> SynMemberFlags) -> - attrs: SynAttributeList list -> - rangeStart: range -> - SynMemberDefn list + flagsBuilderAndLeadingKeyword: (SynMemberKind -> SynMemberFlags) * SynLeadingKeyword -> + attrs: SynAttributeList list -> + rangeStart: range -> + SynMemberDefn list /// Incorporate a '^' for an qualified access to a generic type parameter val adjustHatPrefixToTyparLookup: mFull: range -> rightExpr: SynExpr -> SynExpr @@ -201,7 +202,7 @@ val mkUnderscoreRecdField: m: range -> SynLongIdent * bool val mkRecdField: lidwd: SynLongIdent -> SynLongIdent * bool -val mkSynDoBinding: vis: SynAccess option * expr: SynExpr * m: range -> SynBinding +val mkSynDoBinding: vis: SynAccess option * mDo: range * expr: SynExpr * m: range -> SynBinding val mkSynExprDecl: e: SynExpr -> SynModuleDecl @@ -233,3 +234,5 @@ val idOfPat: parseState: IParseState -> m: range -> p: SynPat -> Ident val checkForMultipleAugmentations: m: range -> a1: 'a list -> a2: 'a list -> 'a list val rangeOfLongIdent: lid: LongIdent -> range + +val appendValToLeadingKeyword: mVal: range -> leadingKeyword: SynLeadingKeyword -> SynLeadingKeyword diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fs b/src/Compiler/SyntaxTree/SyntaxTree.fs index 051bb1e7af8..bdbf10665d0 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fs +++ b/src/Compiler/SyntaxTree/SyntaxTree.fs @@ -1082,8 +1082,6 @@ type SynMemberFlags = GetterOrSetterIsCompilerGenerated: bool MemberKind: SynMemberKind - - Trivia: SynMemberFlagsTrivia } override this.Equals other = @@ -1273,7 +1271,8 @@ type SynField = isMutable: bool * xmlDoc: PreXmlDoc * accessibility: SynAccess option * - range: range + range: range * + trivia: SynFieldTrivia [] type SynComponentInfo = @@ -1440,11 +1439,9 @@ type SynMemberDefn = memberFlagsForSet: SynMemberFlags * xmlDoc: PreXmlDoc * accessibility: SynAccess option * - equalsRange: range * synExpr: SynExpr * - withKeyword: range option * - getSetRange: range option * - range: range + range: range * + trivia: SynMemberDefnAutoPropertyTrivia member d.Range = match d with diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fsi b/src/Compiler/SyntaxTree/SyntaxTree.fsi index 4ecffe92ef4..eeee35985e0 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTree.fsi @@ -1232,9 +1232,6 @@ type SynMemberFlags = /// The kind of the member MemberKind: SynMemberKind - - /// Additional information - Trivia: SynMemberFlagsTrivia } /// Note the member kind is actually computed partially by a syntax tree transformation in tc.fs @@ -1429,7 +1426,8 @@ type SynField = isMutable: bool * xmlDoc: PreXmlDoc * accessibility: SynAccess option * - range: range + range: range * + trivia: SynFieldTrivia /// Represents the syntax tree associated with the name of a type definition or module /// in signature or implementation. @@ -1623,11 +1621,9 @@ type SynMemberDefn = memberFlagsForSet: SynMemberFlags * xmlDoc: PreXmlDoc * accessibility: SynAccess option * - equalsRange: range * synExpr: SynExpr * - withKeyword: range option * - getSetRange: range option * - range: range + range: range * + trivia: SynMemberDefnAutoPropertyTrivia /// Gets the syntax range of this construct member Range: range diff --git a/src/Compiler/SyntaxTree/SyntaxTreeOps.fs b/src/Compiler/SyntaxTree/SyntaxTreeOps.fs index fda76bc0e47..56eb08fee4f 100644 --- a/src/Compiler/SyntaxTree/SyntaxTreeOps.fs +++ b/src/Compiler/SyntaxTree/SyntaxTreeOps.fs @@ -172,10 +172,10 @@ let inline unionRangeWithXmlDoc (xmlDoc: PreXmlDoc) range = unionRanges xmlDoc.Range range let mkSynAnonField (ty: SynType, xmlDoc) = - SynField([], false, None, ty, false, xmlDoc, None, unionRangeWithXmlDoc xmlDoc ty.Range) + SynField([], false, None, ty, false, xmlDoc, None, unionRangeWithXmlDoc xmlDoc ty.Range, SynFieldTrivia.Zero) let mkSynNamedField (ident, ty: SynType, xmlDoc, m) = - SynField([], false, Some ident, ty, false, xmlDoc, None, m) + SynField([], false, Some ident, ty, false, xmlDoc, None, m, SynFieldTrivia.Zero) let mkSynPatVar vis (id: Ident) = SynPat.Named(SynIdent(id, None), false, vis, id.idRange) @@ -690,7 +690,7 @@ let mkSynBinding let mBind = unionRangeWithXmlDoc xmlDoc mBind SynBinding(vis, SynBindingKind.Normal, isInline, isMutable, attrs, xmlDoc, info, headPat, retTyOpt, rhsExpr, mBind, spBind, trivia) -let NonVirtualMemberFlags trivia k : SynMemberFlags = +let NonVirtualMemberFlags k : SynMemberFlags = { MemberKind = k IsInstance = true @@ -698,10 +698,9 @@ let NonVirtualMemberFlags trivia k : SynMemberFlags = IsOverrideOrExplicitImpl = false IsFinal = false GetterOrSetterIsCompilerGenerated = false - Trivia = trivia } -let CtorMemberFlags trivia : SynMemberFlags = +let CtorMemberFlags: SynMemberFlags = { MemberKind = SynMemberKind.Constructor IsInstance = false @@ -709,10 +708,9 @@ let CtorMemberFlags trivia : SynMemberFlags = IsOverrideOrExplicitImpl = false IsFinal = false GetterOrSetterIsCompilerGenerated = false - Trivia = trivia } -let ClassCtorMemberFlags trivia : SynMemberFlags = +let ClassCtorMemberFlags: SynMemberFlags = { MemberKind = SynMemberKind.ClassConstructor IsInstance = false @@ -720,10 +718,9 @@ let ClassCtorMemberFlags trivia : SynMemberFlags = IsOverrideOrExplicitImpl = false IsFinal = false GetterOrSetterIsCompilerGenerated = false - Trivia = trivia } -let OverrideMemberFlags trivia k : SynMemberFlags = +let OverrideMemberFlags k : SynMemberFlags = { MemberKind = k IsInstance = true @@ -731,10 +728,9 @@ let OverrideMemberFlags trivia k : SynMemberFlags = IsOverrideOrExplicitImpl = true IsFinal = false GetterOrSetterIsCompilerGenerated = false - Trivia = trivia } -let AbstractMemberFlags isInstance trivia k : SynMemberFlags = +let AbstractMemberFlags isInstance k : SynMemberFlags = { MemberKind = k IsInstance = isInstance @@ -742,10 +738,9 @@ let AbstractMemberFlags isInstance trivia k : SynMemberFlags = IsOverrideOrExplicitImpl = false IsFinal = false GetterOrSetterIsCompilerGenerated = false - Trivia = trivia } -let StaticMemberFlags trivia k : SynMemberFlags = +let StaticMemberFlags k : SynMemberFlags = { MemberKind = k IsInstance = false @@ -753,10 +748,9 @@ let StaticMemberFlags trivia k : SynMemberFlags = IsOverrideOrExplicitImpl = false IsFinal = false GetterOrSetterIsCompilerGenerated = false - Trivia = trivia } -let ImplementStaticMemberFlags trivia k : SynMemberFlags = +let ImplementStaticMemberFlags k : SynMemberFlags = { MemberKind = k IsInstance = false @@ -764,79 +758,6 @@ let ImplementStaticMemberFlags trivia k : SynMemberFlags = IsOverrideOrExplicitImpl = true IsFinal = false GetterOrSetterIsCompilerGenerated = false - Trivia = trivia - } - -let MemberSynMemberFlagsTrivia (mMember: range) : SynMemberFlagsTrivia = - { - MemberRange = Some mMember - OverrideRange = None - AbstractRange = None - StaticRange = None - DefaultRange = None - } - -let OverrideSynMemberFlagsTrivia (mOverride: range) : SynMemberFlagsTrivia = - { - MemberRange = None - OverrideRange = Some mOverride - AbstractRange = None - StaticRange = None - DefaultRange = None - } - -let StaticMemberSynMemberFlagsTrivia (mStatic: range) (mMember: range) : SynMemberFlagsTrivia = - { - MemberRange = Some mMember - OverrideRange = None - AbstractRange = None - StaticRange = Some mStatic - DefaultRange = None - } - -let DefaultSynMemberFlagsTrivia (mDefault: range) : SynMemberFlagsTrivia = - { - MemberRange = None - OverrideRange = None - AbstractRange = None - StaticRange = None - DefaultRange = Some mDefault - } - -let AbstractSynMemberFlagsTrivia (mAbstract: range) : SynMemberFlagsTrivia = - { - MemberRange = None - OverrideRange = None - AbstractRange = Some mAbstract - StaticRange = None - DefaultRange = None - } - -let AbstractMemberSynMemberFlagsTrivia (mAbstract: range) (mMember: range) : SynMemberFlagsTrivia = - { - MemberRange = Some mMember - OverrideRange = None - AbstractRange = Some mAbstract - StaticRange = None - DefaultRange = None - } - -let StaticAbstractSynMemberFlagsTrivia mStatic mAbstract = - { - MemberRange = None - OverrideRange = None - AbstractRange = Some mAbstract - StaticRange = Some mStatic - DefaultRange = None - } - -let StaticAbstractMemberSynMemberFlagsTrivia mStatic mAbstract mMember = - { - MemberRange = Some mMember - OverrideRange = None - AbstractRange = Some mAbstract - StaticRange = Some mStatic - DefaultRange = None } let inferredTyparDecls = SynValTyparDecls(None, true) diff --git a/src/Compiler/SyntaxTree/SyntaxTreeOps.fsi b/src/Compiler/SyntaxTree/SyntaxTreeOps.fsi index bb72345971e..5c9df2c48d7 100644 --- a/src/Compiler/SyntaxTree/SyntaxTreeOps.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTreeOps.fsi @@ -288,36 +288,19 @@ val mkSynBinding: trivia: SynBindingTrivia -> SynBinding -val NonVirtualMemberFlags: trivia: SynMemberFlagsTrivia -> k: SynMemberKind -> SynMemberFlags +val NonVirtualMemberFlags: k: SynMemberKind -> SynMemberFlags -val CtorMemberFlags: trivia: SynMemberFlagsTrivia -> SynMemberFlags +val CtorMemberFlags: SynMemberFlags -val ClassCtorMemberFlags: trivia: SynMemberFlagsTrivia -> SynMemberFlags +val ClassCtorMemberFlags: SynMemberFlags -val OverrideMemberFlags: trivia: SynMemberFlagsTrivia -> k: SynMemberKind -> SynMemberFlags +val OverrideMemberFlags: k: SynMemberKind -> SynMemberFlags -val AbstractMemberFlags: isInstance: bool -> trivia: SynMemberFlagsTrivia -> k: SynMemberKind -> SynMemberFlags +val AbstractMemberFlags: isInstance: bool -> k: SynMemberKind -> SynMemberFlags -val StaticMemberFlags: trivia: SynMemberFlagsTrivia -> k: SynMemberKind -> SynMemberFlags +val StaticMemberFlags: k: SynMemberKind -> SynMemberFlags -val ImplementStaticMemberFlags: SynMemberFlagsTrivia -> k: SynMemberKind -> SynMemberFlags - -val MemberSynMemberFlagsTrivia: mMember: range -> SynMemberFlagsTrivia - -val OverrideSynMemberFlagsTrivia: mOverride: range -> SynMemberFlagsTrivia - -val StaticMemberSynMemberFlagsTrivia: mStatic: range -> mMember: range -> SynMemberFlagsTrivia - -val DefaultSynMemberFlagsTrivia: mDefault: range -> SynMemberFlagsTrivia - -val AbstractSynMemberFlagsTrivia: mAbstract: range -> SynMemberFlagsTrivia - -val AbstractMemberSynMemberFlagsTrivia: mAbstract: range -> mMember: range -> SynMemberFlagsTrivia - -val StaticAbstractSynMemberFlagsTrivia: mStatic: range -> mAbstract: range -> SynMemberFlagsTrivia - -val StaticAbstractMemberSynMemberFlagsTrivia: - mStatic: range -> mAbstract: range -> mMember: range -> SynMemberFlagsTrivia +val ImplementStaticMemberFlags: k: SynMemberKind -> SynMemberFlags val inferredTyparDecls: SynValTyparDecls diff --git a/src/Compiler/SyntaxTree/SyntaxTrivia.fs b/src/Compiler/SyntaxTree/SyntaxTrivia.fs index 7c15170e74f..5fe77d929a1 100644 --- a/src/Compiler/SyntaxTree/SyntaxTrivia.fs +++ b/src/Compiler/SyntaxTree/SyntaxTrivia.fs @@ -155,40 +155,77 @@ type SynTypeDefnSigTrivia = WithKeyword = None } +[] +type SynLeadingKeyword = + | Let of letRange: range + | LetRec of letRange: range * recRange: range + | And of andRange: range + | Use of useRange: range + | UseRec of useRange: range * recRange: range + | Extern of externRange: range + | Member of memberRange: range + | MemberVal of memberRange: range * valRange: range + | Override of overrideRange: range + | OverrideVal of overrideRange: range * valRange: range + | Abstract of abstractRange: range + | AbstractMember of abstractRange: range * memberRange: range + | StaticMember of staticRange: range * memberRange: range + | StaticMemberVal of staticRange: range * memberRange: range * valRange: range + | StaticAbstract of staticRange: range * abstractRange: range + | StaticAbstractMember of staticRange: range * abstractMember: range * memberRange: range + | StaticVal of staticRange: range * valRange: range + | StaticLet of staticRange: range * letRange: range + | StaticLetRec of staticRange: range * letRange: range * recRange: range + | StaticDo of staticRange: range * doRange: range + | Default of defaultRange: range + | DefaultVal of defaultRange: range * valRange: range + | Val of valRange: range + | New of newRange: range + | Do of doRange: range + | Synthetic + + member this.Range = + match this with + | Let m + | And m + | Use m + | Extern m + | Member m + | Override m + | Abstract m + | Default m + | Val m + | New m + | Do m -> m + | LetRec (m1, m2) + | UseRec (m1, m2) + | AbstractMember (m1, m2) + | StaticMember (m1, m2) + | StaticAbstract (m1, m2) + | StaticAbstractMember (m1, _, m2) + | StaticVal (m1, m2) + | StaticLet (m1, m2) + | StaticLetRec (m1, _, m2) + | StaticDo (m1, m2) + | DefaultVal (m1, m2) + | MemberVal (m1, m2) + | OverrideVal (m1, m2) + | StaticMemberVal (m1, _, m2) -> Range.unionRanges m1 m2 + | Synthetic -> Range.Zero + [] type SynBindingTrivia = { - LetKeyword: range option - ExternKeyword: range option + LeadingKeyword: SynLeadingKeyword EqualsRange: range option } static member Zero: SynBindingTrivia = { - LetKeyword = None - ExternKeyword = None + LeadingKeyword = SynLeadingKeyword.Synthetic EqualsRange = None } -[] -type SynMemberFlagsTrivia = - { - MemberRange: range option - OverrideRange: range option - AbstractRange: range option - StaticRange: range option - DefaultRange: range option - } - - static member Zero: SynMemberFlagsTrivia = - { - MemberRange = None - OverrideRange = None - AbstractRange = None - StaticRange = None - DefaultRange = None - } - [] type SynExprAndBangTrivia = { @@ -239,14 +276,14 @@ type SynModuleOrNamespaceSigTrivia = [] type SynValSigTrivia = { - ValKeyword: range option + LeadingKeyword: SynLeadingKeyword WithKeyword: range option EqualsRange: range option } static member Zero: SynValSigTrivia = { - ValKeyword = None + LeadingKeyword = SynLeadingKeyword.Synthetic WithKeyword = None EqualsRange = None } @@ -267,4 +304,20 @@ type SynMemberGetSetTrivia = type SynArgPatsNamePatPairsTrivia = { ParenRange: range } [] +type SynMemberDefnAutoPropertyTrivia = + { + LeadingKeyword: SynLeadingKeyword + WithKeyword: range option + EqualsRange: range option + GetSetKeyword: range option + } + +[] +type SynFieldTrivia = + { + LeadingKeyword: SynLeadingKeyword option + } + + static member Zero: SynFieldTrivia = { LeadingKeyword = None } + type SynTypeOrTrivia = { OrKeyword: range } diff --git a/src/Compiler/SyntaxTree/SyntaxTrivia.fsi b/src/Compiler/SyntaxTree/SyntaxTrivia.fsi index c52cacea7b2..cae5db553e6 100644 --- a/src/Compiler/SyntaxTree/SyntaxTrivia.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTrivia.fsi @@ -239,15 +239,44 @@ type SynTypeDefnSigTrivia = static member Zero: SynTypeDefnSigTrivia +/// Represents the leading keyword in a SynBinding or SynValSig +[] +type SynLeadingKeyword = + | Let of letRange: range + | LetRec of letRange: range * recRange: range + | And of andRange: range + | Use of useRange: range + | UseRec of useRange: range * recRange: range + | Extern of externRange: range + | Member of memberRange: range + | MemberVal of memberRange: range * valRange: range + | Override of overrideRange: range + | OverrideVal of overrideRange: range * valRange: range + | Abstract of abstractRange: range + | AbstractMember of abstractRange: range * memberRange: range + | StaticMember of staticRange: range * memberRange: range + | StaticMemberVal of staticRange: range * memberRange: range * valRange: range + | StaticAbstract of staticRange: range * abstractRange: range + | StaticAbstractMember of staticRange: range * abstractMember: range * memberRange: range + | StaticVal of staticRange: range * valRange: range + | StaticLet of staticRange: range * letRange: range + | StaticLetRec of staticRange: range * letRange: range * recRange: range + | StaticDo of staticRange: range * doRange: range + | Default of defaultRange: range + | DefaultVal of defaultRange: range * valRange: range + | Val of valRange: range + | New of newRange: range + | Do of doRange: range + | Synthetic + + member Range: range + /// Represents additional information for SynBinding [] type SynBindingTrivia = { - /// The syntax range of the `let` keyword. - LetKeyword: range option - - /// The syntax range of the `extern` keyword. - ExternKeyword: range option + /// Used leading keyword of SynBinding + LeadingKeyword: SynLeadingKeyword /// The syntax range of the `=` token. EqualsRange: range option @@ -255,28 +284,6 @@ type SynBindingTrivia = static member Zero: SynBindingTrivia -/// Represents additional information for SynMemberFlags -[] -type SynMemberFlagsTrivia = - { - /// The syntax range of the `member` keyword - MemberRange: range option - - /// The syntax range of the `override` keyword - OverrideRange: range option - - /// The syntax range of the `abstract` keyword - AbstractRange: range option - - /// The syntax range of the `member` keyword - StaticRange: range option - - /// The syntax range of the `default` keyword - DefaultRange: range option - } - - static member Zero: SynMemberFlagsTrivia - /// Represents additional information for SynExprAndBang [] type SynExprAndBangTrivia = @@ -340,8 +347,10 @@ type SynModuleOrNamespaceSigTrivia = [] type SynValSigTrivia = { - /// The syntax range of the `val` keyword - ValKeyword: range option + /// Used leading keyword of SynValSig + /// In most cases this will be `val`, + /// but in case of `SynMemberDefn.AutoProperty` or `SynMemberDefn.AbstractSlot` it could be something else. + LeadingKeyword: SynLeadingKeyword /// The syntax range of the `with` keyword WithKeyword: range option @@ -385,6 +394,33 @@ type SynArgPatsNamePatPairsTrivia = ParenRange: range } +/// Represents additional information for SynMemberDefn.AutoProperty +[] +type SynMemberDefnAutoPropertyTrivia = + { + /// Used leading keyword of AutoProperty + LeadingKeyword: SynLeadingKeyword + + /// The syntax range of the `with` keyword + WithKeyword: range option + + /// The syntax range of the `=` token + EqualsRange: range option + + /// The syntax range of 'get, set' + GetSetKeyword: range option + } + +/// Represents additional information for SynField +[] +type SynFieldTrivia = + { + /// Used leading keyword of SynField + LeadingKeyword: SynLeadingKeyword option + } + + static member Zero: SynFieldTrivia + /// Represents additional information for SynType.Or [] type SynTypeOrTrivia = diff --git a/src/Compiler/TypedTree/TypedTreePickle.fs b/src/Compiler/TypedTree/TypedTreePickle.fs index c367865dbc2..90fd15fa1e2 100644 --- a/src/Compiler/TypedTree/TypedTreePickle.fs +++ b/src/Compiler/TypedTree/TypedTreePickle.fs @@ -21,7 +21,6 @@ open FSharp.Compiler.DiagnosticsLogger open FSharp.Compiler.Text.Position open FSharp.Compiler.Text.Range open FSharp.Compiler.Syntax -open FSharp.Compiler.SyntaxTrivia open FSharp.Compiler.SyntaxTreeOps open FSharp.Compiler.Text open FSharp.Compiler.Xml @@ -1500,8 +1499,7 @@ let u_MemberFlags st : SynMemberFlags= IsOverrideOrExplicitImpl=x5 IsFinal=x6 GetterOrSetterIsCompilerGenerated=false - MemberKind=x7 - Trivia = SynMemberFlagsTrivia.Zero } + MemberKind=x7 } let fill_u_Expr_hole, u_expr_fwd = u_hole() let fill_p_Expr_hole, p_expr_fwd = p_hole() diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index 1dc110accee..3114c476616 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -702,7 +702,8 @@ valSpfn: | None -> m | Some e -> unionRanges m e.Range let mVal = rhs parseState 3 - let valSpfn = SynValSig((attr1@attr2), id, explicitValTyparDecls, ty, arity, isInline, isMutable, doc, vis2, konst, m, { ValKeyword = Some mVal; WithKeyword = None; EqualsRange = mEquals }) + let trivia: SynValSigTrivia = { LeadingKeyword = SynLeadingKeyword.Val mVal; WithKeyword = None; EqualsRange = mEquals } + let valSpfn = SynValSig((attr1@attr2), id, explicitValTyparDecls, ty, arity, isInline, isMutable, doc, vis2, konst, m, trivia) SynModuleSigDecl.Val(valSpfn, m) } @@ -832,7 +833,7 @@ tyconSpfnRhs: | DELEGATE OF topType { let m = lhs parseState let ty, arity = $3 - let flags = AbstractMemberFlags true SynMemberFlagsTrivia.Zero SynMemberKind.Member + let flags = AbstractMemberFlags true SynMemberKind.Member let valSig = SynValSig([], (SynIdent(mkSynId m "Invoke", None)), inferredTyparDecls, ty, arity, false, false, PreXmlDoc.Empty, None, None, m, SynValSigTrivia.Zero) let invoke = SynMemberSig.Member(valSig, flags, m) (fun nameRange nameInfo mEquals augmentation -> @@ -921,9 +922,11 @@ classMemberSpfn: match optLiteralValue with | None -> m | Some e -> unionRanges m e.Range - let trivia = { ValKeyword = None; WithKeyword = mWith; EqualsRange = mEquals } + + let flags, leadingKeyword = $3 + let flags = flags (getSetAdjuster arity) + let trivia = { LeadingKeyword = leadingKeyword; WithKeyword = mWith; EqualsRange = mEquals } let valSpfn = SynValSig($1, id, explicitValTyparDecls, ty, arity, isInline, false, doc, vis2, optLiteralValue, mWhole, trivia) - let flags = $3 (getSetAdjuster arity) SynMemberSig.Member(valSpfn, flags, mWhole) } | opt_attributes opt_access interfaceMember appType @@ -937,14 +940,17 @@ classMemberSpfn: | opt_attributes opt_access VAL fieldDecl { let mWhole = rhs2 parseState 1 4 if Option.isSome $2 then errorR (Error (FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier (), rhs parseState 2)) - let (SynField(_, _, _, _, _, xmlDoc, _, _)) as field = $4 $1 false mWhole + let mVal = rhs parseState 3 + let (SynField(xmlDoc = xmlDoc)) as field = $4 $1 false mWhole (Some (SynLeadingKeyword.Val mVal)) let mWhole = unionRangeWithXmlDoc xmlDoc mWhole SynMemberSig.ValField (field, mWhole) } | opt_attributes opt_access STATIC VAL fieldDecl { let mWhole = rhs2 parseState 1 5 if Option.isSome $2 then errorR (Error (FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier (), rhs parseState 2)) - let (SynField(_, _, _, _, _, xmlDoc, _, _)) as field = $5 $1 true mWhole + let mStatic = rhs parseState 3 + let mVal = rhs parseState 4 + let (SynField(xmlDoc = xmlDoc)) as field = $5 $1 true mWhole (Some (SynLeadingKeyword.StaticVal(mStatic, mVal))) let mWhole = unionRangeWithXmlDoc xmlDoc mWhole SynMemberSig.ValField(field, mWhole) } @@ -954,10 +960,12 @@ classMemberSpfn: | opt_attributes opt_access NEW COLON topTypeWithTypeConstraints { let vis, doc, (ty, valSynInfo) = $2, grabXmlDoc(parseState, $1, 1), $5 + let mNew = rhs parseState 3 let m = unionRanges (rhs parseState 1) ty.Range |> unionRangeWithXmlDoc doc - let isInline = false - let valSpfn = SynValSig ($1, (SynIdent(mkSynId (rhs parseState 3) "new", None)), noInferredTypars, ty, valSynInfo, isInline, false, doc, vis, None, m, SynValSigTrivia.Zero) - SynMemberSig.Member(valSpfn, CtorMemberFlags SynMemberFlagsTrivia.Zero, m) } + let isInline = false + let trivia: SynValSigTrivia = { LeadingKeyword = SynLeadingKeyword.New mNew; WithKeyword = None; EqualsRange = None } + let valSpfn = SynValSig ($1, (SynIdent(mkSynId (rhs parseState 3) "new", None)), noInferredTypars, ty, valSynInfo, isInline, false, doc, vis, None, m, trivia) + SynMemberSig.Member(valSpfn, CtorMemberFlags, m) } /* The optional "with get, set" on a member in a signature */ @@ -1438,16 +1446,16 @@ memberFlags: | STATIC MEMBER { let mStatic = rhs parseState 1 let mMember = rhs parseState 2 - StaticMemberFlags(StaticMemberSynMemberFlagsTrivia mStatic mMember) } + StaticMemberFlags, (SynLeadingKeyword.StaticMember(mStatic, mMember)) } | MEMBER { let mMember = rhs parseState 1 - NonVirtualMemberFlags(MemberSynMemberFlagsTrivia mMember) } + NonVirtualMemberFlags, (SynLeadingKeyword.Member mMember) } | OVERRIDE { let mOverride = rhs parseState 1 - OverrideMemberFlags(OverrideSynMemberFlagsTrivia mOverride) } + OverrideMemberFlags, (SynLeadingKeyword.Override mOverride) } | DEFAULT { let mDefault = rhs parseState 1 - OverrideMemberFlags(DefaultSynMemberFlagsTrivia mDefault) } + OverrideMemberFlags, (SynLeadingKeyword.Default mDefault) } /* The name of a type in a signature or implementation, possibly with type parameters and constraints */ typeNameInfo: @@ -1584,7 +1592,7 @@ tyconDefnRhs: let ty, arity = $3 (fun nameRange augmentation -> let valSig = SynValSig([], (SynIdent(mkSynId m "Invoke", None)), inferredTyparDecls, ty, arity, false, false, PreXmlDoc.Empty, None, None, m, SynValSigTrivia.Zero) - let flags = AbstractMemberFlags true SynMemberFlagsTrivia.Zero SynMemberKind.Member + let flags = AbstractMemberFlags true SynMemberKind.Member let invoke = SynMemberDefn.AbstractSlot(valSig, flags, m) if not (isNil augmentation) then raiseParseErrorAt m (FSComp.SR.parsAugmentationsIllegalOnDelegateType()) SynTypeDefnRepr.ObjectModel (SynTypeDefnKind.Delegate (ty, arity), [invoke], m), []) } @@ -1702,12 +1710,13 @@ memberCore: let optReturnType = $3 let mEquals = rhs parseState 4 let bindingPat, mBindLhs = $2 - (fun vis memFlagsBuilder attrs rangeStart -> + (fun vis flagsBuilderAndLeadingKeyword attrs rangeStart -> let xmlDoc = grabXmlDocAtRangeStart(parseState, attrs, rangeStart) - let memberFlags = Some (memFlagsBuilder SynMemberKind.Member) + let memFlagsBuilder, leadingKeyword = flagsBuilderAndLeadingKeyword + let memberFlags = memFlagsBuilder SynMemberKind.Member let mWholeBindLhs = (mBindLhs, attrs) ||> unionRangeWithListBy (fun (a: SynAttributeList) -> a.Range) - let trivia: SynBindingTrivia = { LetKeyword = None; EqualsRange = Some mEquals; ExternKeyword = None } - let binding = mkSynBinding (xmlDoc, bindingPat) (vis, $1, false, mWholeBindLhs, DebugPointAtBinding.NoneAtInvisible, optReturnType, $5, mRhs, [], attrs, memberFlags, trivia) + let trivia: SynBindingTrivia = { LeadingKeyword = leadingKeyword; EqualsRange = Some mEquals } + let binding = mkSynBinding (xmlDoc, bindingPat) (vis, $1, false, mWholeBindLhs, DebugPointAtBinding.NoneAtInvisible, optReturnType, $5, mRhs, [], attrs, Some memberFlags, trivia) let memberRange = unionRanges rangeStart mRhs |> unionRangeWithXmlDoc xmlDoc [ SynMemberDefn.Member (binding, memberRange) ]) } @@ -1717,17 +1726,26 @@ memberCore: let mWhole = (rhs parseState 2, classDefnMemberGetSetElements) ||> unionRangeWithListBy (fun (_, _, _, _, _, _, m2) -> m2) let propertyNameBindingPat, _ = $2 let optPropertyType = $3 - mkSynMemberDefnGetSet parseState $1 mWith classDefnMemberGetSetElements mAnd mWhole propertyNameBindingPat optPropertyType } + + mkSynMemberDefnGetSet + parseState + $1 + mWith + classDefnMemberGetSetElements + mAnd + mWhole + propertyNameBindingPat + optPropertyType } abstractMemberFlags: | ABSTRACT { let mAbstract = rhs parseState 1 - AbstractMemberFlags true (AbstractSynMemberFlagsTrivia mAbstract) } + AbstractMemberFlags true, SynLeadingKeyword.Abstract mAbstract } | ABSTRACT MEMBER { let mAbstract = rhs parseState 1 let mMember = rhs parseState 2 - AbstractMemberFlags true (AbstractMemberSynMemberFlagsTrivia mAbstract mMember) } + AbstractMemberFlags true, SynLeadingKeyword.AbstractMember(mAbstract, mMember) } | STATIC ABSTRACT { let mWhole = rhs2 parseState 1 2 @@ -1736,7 +1754,7 @@ abstractMemberFlags: warning(Error(FSComp.SR.tcUsingInterfacesWithStaticAbstractMethods(), mWhole)) let mStatic = rhs parseState 1 let mAbstract = rhs parseState 2 - AbstractMemberFlags false (StaticAbstractSynMemberFlagsTrivia mStatic mAbstract) } + AbstractMemberFlags false, SynLeadingKeyword.StaticAbstract(mStatic, mAbstract) } | STATIC ABSTRACT MEMBER { let mWhole = rhs2 parseState 1 2 @@ -1746,7 +1764,7 @@ abstractMemberFlags: let mStatic = rhs parseState 1 let mAbstract = rhs parseState 2 let mMember = rhs parseState 3 - AbstractMemberFlags false (StaticAbstractMemberSynMemberFlagsTrivia mStatic mAbstract mMember) } + AbstractMemberFlags false, SynLeadingKeyword.StaticAbstractMember(mStatic, mAbstract, mMember) } /* A member definition */ classDefnMember: @@ -1786,9 +1804,11 @@ classDefnMember: | Some m2 -> unionRanges m m2 |> unionRangeWithXmlDoc doc if Option.isSome $2 then errorR(Error(FSComp.SR.parsAccessibilityModsIllegalForAbstract(), mWhole)) - let trivia = { ValKeyword = None; WithKeyword = mWith; EqualsRange = None } + let mkFlags, leadingKeyword = $3 + let trivia = { LeadingKeyword = leadingKeyword; WithKeyword = mWith; EqualsRange = None } let valSpfn = SynValSig($1, id, explicitValTyparDecls, ty, arity, isInline, false, doc, None, None, mWhole, trivia) - [ SynMemberDefn.AbstractSlot(valSpfn, $3 (getSetAdjuster arity), mWhole) ] } + + [ SynMemberDefn.AbstractSlot(valSpfn, mkFlags (getSetAdjuster arity), mWhole) ] } | opt_attributes opt_access inheritsDefn { if not (isNil $1) then errorR(Error(FSComp.SR.parsAttributesIllegalOnInherit(), rhs parseState 1)) @@ -1798,12 +1818,13 @@ classDefnMember: | opt_attributes opt_access valDefnDecl opt_ODECLEND { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(), rhs parseState 2)) let rangeStart = rhs parseState 1 - $3 rangeStart $1 false } + $3 rangeStart $1 None } | opt_attributes opt_access STATIC valDefnDecl opt_ODECLEND { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(), rhs parseState 2)) + let mStatic = rhs parseState 3 let rangeStart = rhs parseState 1 - $4 rangeStart $1 true } + $4 rangeStart $1 (Some mStatic) } | opt_attributes opt_access memberFlags autoPropsDefnDecl opt_ODECLEND { let rangeStart = rhs parseState 1 @@ -1814,16 +1835,17 @@ classDefnMember: | opt_attributes opt_access NEW atomicPattern optAsSpec EQUALS typedSequentialExprBlock opt_ODECLEND { let mWholeBindLhs = rhs2 parseState 1 (if Option.isSome $5 then 5 else 4) + let mNew = rhs parseState 3 let xmlDoc = grabXmlDoc(parseState, $1, 1) let m = unionRanges mWholeBindLhs $7.Range |> unionRangeWithXmlDoc xmlDoc let mEquals = rhs parseState 6 let expr = $7 - let valSynData = SynValData (Some (CtorMemberFlags SynMemberFlagsTrivia.Zero), SynValInfo([SynInfo.InferSynArgInfoFromPat $4], SynInfo.unnamedRetVal), $5) + let valSynData = SynValData (Some CtorMemberFlags, SynValInfo([SynInfo.InferSynArgInfoFromPat $4], SynInfo.unnamedRetVal), $5) let vis = $2 let declPat = SynPat.LongIdent (SynLongIdent([mkSynId (rhs parseState 3) "new"], [], [None]), None, Some noInferredTypars, SynArgPats.Pats [$4], vis, rhs parseState 3) // Check that 'SynPatForConstructorDecl' matches this correctly assert (match declPat with SynPatForConstructorDecl _ -> true | _ -> false) - let synBindingTrivia: SynBindingTrivia = { LetKeyword = None; EqualsRange = Some mEquals; ExternKeyword = None } + let synBindingTrivia: SynBindingTrivia = { LeadingKeyword = SynLeadingKeyword.New mNew; EqualsRange = Some mEquals } [ SynMemberDefn.Member(SynBinding (None, SynBindingKind.Normal, false, false, $1, xmlDoc, valSynData, declPat, None, expr, mWholeBindLhs, DebugPointAtBinding.NoneAtInvisible, synBindingTrivia), m) ] } | opt_attributes opt_access STATIC typeKeyword tyconDefn @@ -1834,29 +1856,39 @@ classDefnMember: /* A 'val' definition in an object type definition */ valDefnDecl: | VAL opt_mutable opt_access ident COLON typ - { let mRhs = rhs2 parseState 4 6 + { let mVal = rhs parseState 1 + let mRhs = rhs2 parseState 4 6 let mValDecl = rhs2 parseState 1 6 - (fun rangeStart attribs isStatic -> + (fun rangeStart attribs mStaticOpt -> + let isStatic = Option.isSome mStaticOpt let xmlDoc = grabXmlDocAtRangeStart(parseState, attribs, rangeStart) let mValDecl = unionRanges rangeStart mValDecl |> unionRangeWithXmlDoc xmlDoc - let fld = SynField(attribs, isStatic, Some $4, $6, $2, xmlDoc, $3, mRhs) + let leadingKeyword = + match mStaticOpt with + | None -> SynLeadingKeyword.Val mVal + | Some mStatic -> SynLeadingKeyword.StaticVal(mStatic, mVal) + let fld = SynField(attribs, isStatic, Some $4, $6, $2, xmlDoc, $3, mRhs, { LeadingKeyword = Some leadingKeyword }) [ SynMemberDefn.ValField(fld, mValDecl) ]) } /* An auto-property definition in an object type definition */ autoPropsDefnDecl: | VAL opt_mutable opt_access ident opt_typ EQUALS typedSequentialExprBlock classMemberSpfnGetSet - { let mWith, mGetSetOpt, getSet = $8 + { let mVal = rhs parseState 1 + let mWith, mGetSetOpt, getSet = $8 let mEquals = rhs parseState 6 if $2 then errorR (Error (FSComp.SR.parsMutableOnAutoPropertyShouldBeGetSet (), rhs parseState 3)) (fun attribs flags rangeStart -> let xmlDoc = grabXmlDocAtRangeStart(parseState, attribs, rangeStart) let memberRange = unionRanges rangeStart $7.Range |> unionRangeWithXmlDoc xmlDoc + let flags, leadingKeyword = flags + let leadingKeyword = appendValToLeadingKeyword mVal leadingKeyword let memberFlags = flags SynMemberKind.Member let memberFlagsForSet = flags SynMemberKind.PropertySet let isStatic = not memberFlags.IsInstance - [ SynMemberDefn.AutoProperty(attribs, isStatic, $4, $5, getSet, memberFlags, memberFlagsForSet, xmlDoc, $3, mEquals, $7, mWith, mGetSetOpt, memberRange) ]) } + let trivia = { LeadingKeyword = leadingKeyword; WithKeyword = mWith; EqualsRange = Some mEquals; GetSetKeyword = mGetSetOpt } + [ SynMemberDefn.AutoProperty(attribs, isStatic, $4, $5, getSet, memberFlags, memberFlagsForSet, xmlDoc, $3, $7, memberRange, trivia) ]) } /* An optional type on an auto-property definition */ opt_typ: @@ -2026,13 +2058,13 @@ staticMemberOrMemberOrOverride: | STATIC MEMBER { let mStatic = rhs parseState 1 let mMember = rhs parseState 2 - ImplementStaticMemberFlags(StaticMemberSynMemberFlagsTrivia mStatic mMember) } + ImplementStaticMemberFlags, (SynLeadingKeyword.StaticMember(mStatic, mMember)) } | MEMBER { let mMember = rhs parseState 1 - OverrideMemberFlags(MemberSynMemberFlagsTrivia mMember) } + OverrideMemberFlags, (SynLeadingKeyword.Member mMember) } | OVERRIDE { let mOverride = rhs parseState 1 - OverrideMemberFlags(OverrideSynMemberFlagsTrivia mOverride) } + OverrideMemberFlags, (SynLeadingKeyword.Override mOverride) } /* The core of the right-hand-side of a simple type definition */ @@ -2415,18 +2447,18 @@ recdFieldDeclList: recdFieldDecl: | opt_attributes fieldDecl { let mWhole = rhs2 parseState 1 2 - let fld = $2 $1 false mWhole - let (SynField (a, b, c, d, e, xmlDoc, vis, mWhole)) = fld + let fld = $2 $1 false mWhole None + let (SynField (a, b, c, d, e, xmlDoc, vis, mWhole, trivia)) = fld if Option.isSome vis then errorR (Error (FSComp.SR.parsRecordFieldsCannotHaveVisibilityDeclarations (), rhs parseState 2)) let mWhole = unionRangeWithXmlDoc xmlDoc mWhole - SynField (a, b, c, d, e, xmlDoc, None, mWhole) } + SynField (a, b, c, d, e, xmlDoc, None, mWhole, trivia) } /* Part of a field or val declaration in a record type or object type */ fieldDecl: | opt_mutable opt_access ident COLON typ - { fun attrs stat mWhole -> + { fun attrs stat mWhole leadingKeyword -> let xmlDoc = grabXmlDocAtRangeStart(parseState, attrs, mWhole) - SynField(attrs, stat, Some $3, $5, $1, xmlDoc, $2, mWhole) } + SynField(attrs, stat, Some $3, $5, $1, xmlDoc, $2, mWhole, { LeadingKeyword = leadingKeyword }) } /* An exception definition */ exconDefn: @@ -2465,7 +2497,13 @@ defnBindings: | LET opt_rec localBindings { let mLetKwd = rhs parseState 1 let isUse = $1 - let isRec = $2 + let isRec = $2 + let leadingKeyword = + if isRec then + SynLeadingKeyword.LetRec(mLetKwd, rhs parseState 2) + else + SynLeadingKeyword.Let(mLetKwd) + let localBindingsLastRangeOpt, localBindingsBuilder = $3 // Calculate the precise range of the binding set, up to the end of the last r.h.s. expression @@ -2479,7 +2517,7 @@ defnBindings: (fun attrs vis -> let xmlDoc = grabXmlDoc(parseState, attrs, 1) // apply the builder - let binds = localBindingsBuilder xmlDoc attrs vis mLetKwd + let binds = localBindingsBuilder xmlDoc attrs vis leadingKeyword if not isRec && not (isNilOrSingleton binds) then reportParseErrorAt mLetKwd (FSComp.SR.parsLetAndForNonRecBindings()) [], binds), @@ -2497,7 +2535,7 @@ doBinding: let mWhole = unionRanges mDoKwd $2.Range // any attributes prior to the 'let' are left free, e.g. become top-level attributes // associated with the module, 'main' function or assembly depending on their target - BindingSetPreAttrs(mDoKwd, false, false, (fun attrs vis -> attrs, [mkSynDoBinding (vis, $2, mWhole)]), mWhole) } + BindingSetPreAttrs(mDoKwd, false, false, (fun attrs vis -> attrs, [mkSynDoBinding (vis, mDoKwd, $2, mWhole)]), mWhole) } /* A 'let ....' binding in the #light syntax */ @@ -2506,6 +2544,16 @@ hardwhiteLetBindings: { let mLetKwd = rhs parseState 1 let isUse = $1 let isRec = $2 + let leadingKeyword = + if not isUse && isRec then + SynLeadingKeyword.LetRec(mLetKwd, rhs parseState 2) + elif isUse && not isRec then + SynLeadingKeyword.Use mLetKwd + elif isUse && isRec then + SynLeadingKeyword.UseRec(mLetKwd, rhs parseState 2) + else + SynLeadingKeyword.Let(mLetKwd) + let report, mIn = $4 report (if isUse then "use" else "let") mLetKwd // report unterminated error @@ -2521,7 +2569,7 @@ hardwhiteLetBindings: BindingSetPreAttrs(mLetKwd, isRec, isUse, (fun attrs vis -> let xmlDoc = grabXmlDoc(parseState, attrs, 1) - let binds = localBindingsBuilder xmlDoc attrs vis mLetKwd + let binds = localBindingsBuilder xmlDoc attrs vis leadingKeyword if not isRec && not (isNilOrSingleton binds) then reportParseErrorAt mLetKwd (FSComp.SR.parsLetAndForNonRecBindings()) [], binds), @@ -2533,12 +2581,12 @@ hardwhiteLetBindings: /* A 'do ...' statement */ hardwhiteDoBinding: | ODO typedSequentialExprBlock hardwhiteDefnBindingsTerminator - { let mLetKwd = rhs parseState 1 - let bindingSetRange = unionRanges mLetKwd $2.Range + { let mDoKwd = rhs parseState 1 + let bindingSetRange = unionRanges mDoKwd $2.Range let seqPt = DebugPointAtBinding.NoneAtDo // any attributes prior to the 'let' are left free, e.g. become top-level attributes // associated with the module, 'main' function or assembly depending on their target - BindingSetPreAttrs(mLetKwd, false, false, (fun attrs vis -> attrs, [mkSynDoBinding (vis, $2, bindingSetRange)]), bindingSetRange), $2 } + BindingSetPreAttrs(mDoKwd, false, false, (fun attrs vis -> attrs, [mkSynDoBinding (vis, mDoKwd, $2, bindingSetRange)]), bindingSetRange), $2 } /* The bindings in a class type definition */ @@ -2595,7 +2643,7 @@ cPrototype: let bindingPat = SynPat.LongIdent (SynLongIdent([nm], [], [None]), None, Some noInferredTypars, SynArgPats.Pats [SynPat.Tuple(false, args, argsm)], vis, nmm) let mWholeBindLhs = (mBindLhs, attrs) ||> unionRangeWithListBy (fun (a: SynAttributeList) -> a.Range) let xmlDoc = grabXmlDoc(parseState, attrs, 1) - let trivia = { LetKeyword = None; ExternKeyword = Some mExtern; EqualsRange = None } + let trivia = { LeadingKeyword = SynLeadingKeyword.Extern mExtern; EqualsRange = None } let binding = mkSynBinding (xmlDoc, bindingPat) @@ -2673,19 +2721,19 @@ localBindings: match moreLocalBindingsLastRange with | None -> localBindingRange | Some m -> m - Some lastRange, (fun xmlDoc attrs vis mLetKwd -> attrLocalBindingBuilder xmlDoc attrs vis mLetKwd true :: moreBindings) + Some lastRange, (fun xmlDoc attrs vis leadingKeyword -> attrLocalBindingBuilder xmlDoc attrs vis leadingKeyword true :: moreBindings) | None -> - moreLocalBindingsLastRange, (fun _xmlDoc _attrs _vis _letm -> moreBindings) } + moreLocalBindingsLastRange, (fun _xmlDoc _attrs _vis _leadingKeyword -> moreBindings) } moreLocalBindings: | AND attr_localBinding moreLocalBindings - { let mLetKwd = rhs parseState 1 + { let leadingKeyword = SynLeadingKeyword.And(rhs parseState 1) (match $2 with | Some (localBindingRange, attrLocalBindingBuilder) -> let xmlDoc = grabXmlDoc(parseState, [], 1) let xmlDoc = if xmlDoc.IsEmpty then grabXmlDoc(parseState, [], 2) else xmlDoc - (attrLocalBindingBuilder xmlDoc [] None mLetKwd false, localBindingRange) :: $3 + (attrLocalBindingBuilder xmlDoc [] None leadingKeyword false, localBindingRange) :: $3 | None -> $3) } | %prec prec_no_more_attr_bindings @@ -2697,7 +2745,7 @@ attr_localBinding: | opt_attributes localBinding { let attrs2 = $1 let localBindingRange, localBindingBuilder = $2 - let attrLocalBindingBuilder = (fun xmlDoc attrs vis mLetKwd _ -> localBindingBuilder xmlDoc (attrs@attrs2) vis mLetKwd) + let attrLocalBindingBuilder = (fun xmlDoc attrs vis leadingKeyword _ -> localBindingBuilder xmlDoc (attrs@attrs2) vis leadingKeyword) Some(localBindingRange, attrLocalBindingBuilder) } | error @@ -2714,11 +2762,11 @@ localBinding: let bindingPat, mBindLhs = $3 let localBindingRange = unionRanges (rhs2 parseState 1 5) mRhs let localBindingBuilder = - (fun xmlDoc attrs vis mLetKwd -> - let mWhole = (unionRanges mLetKwd mRhs, attrs) ||> unionRangeWithListBy (fun (a: SynAttributeList) -> a.Range) + (fun xmlDoc attrs vis (leadingKeyword: SynLeadingKeyword) -> + let mWhole = (unionRanges leadingKeyword.Range mRhs, attrs) ||> unionRangeWithListBy (fun (a: SynAttributeList) -> a.Range) let spBind = if IsDebugPointBinding bindingPat expr then DebugPointAtBinding.Yes mWhole else DebugPointAtBinding.NoneAtLet let mWholeBindLhs = (mBindLhs, attrs) ||> unionRangeWithListBy (fun (a: SynAttributeList) -> a.Range) - let trivia: SynBindingTrivia = { LetKeyword = Some mLetKwd; EqualsRange = Some mEquals; ExternKeyword = None } + let trivia: SynBindingTrivia = { LeadingKeyword = leadingKeyword; EqualsRange = Some mEquals } mkSynBinding (xmlDoc, bindingPat) (vis, $1, $2, mWholeBindLhs, spBind, optReturnType, expr, mRhs, opts, attrs, None, trivia)) localBindingRange, localBindingBuilder } @@ -2728,12 +2776,12 @@ localBinding: let optReturnType = $4 let bindingPat, mBindLhs = $3 let localBindingBuilder = - (fun xmlDoc attrs vis mLetKwd -> + (fun xmlDoc attrs vis leadingKeyword -> let mEquals = rhs parseState 5 let zeroWidthAtEnd = mEquals.EndRange let rhsExpr = arbExpr("localBinding1", zeroWidthAtEnd) let spBind = if IsDebugPointBinding bindingPat rhsExpr then DebugPointAtBinding.Yes mWhole else DebugPointAtBinding.NoneAtLet - let trivia: SynBindingTrivia = { LetKeyword = Some mLetKwd; EqualsRange = Some mEquals; ExternKeyword = None } + let trivia: SynBindingTrivia = { LeadingKeyword = leadingKeyword; EqualsRange = Some mEquals } mkSynBinding (xmlDoc, bindingPat) (vis, $1, $2, mBindLhs, spBind, optReturnType, rhsExpr, mRhs, [], attrs, None, trivia)) mWhole, localBindingBuilder } @@ -2744,9 +2792,9 @@ localBinding: let mRhs = mWhole.EndRange // zero-width range at end of last good token let bindingPat, mBindLhs = $3 let localBindingBuilder = - (fun xmlDoc attrs vis mLetKwd -> - let spBind = DebugPointAtBinding.Yes (unionRanges mLetKwd mRhs) - let trivia = { LetKeyword = Some mLetKwd; EqualsRange = None; ExternKeyword = None } + (fun xmlDoc attrs vis (leadingKeyword: SynLeadingKeyword) -> + let spBind = DebugPointAtBinding.Yes (unionRanges leadingKeyword.Range mRhs) + let trivia = { LeadingKeyword = leadingKeyword; EqualsRange = None } let rhsExpr = arbExpr("localBinding2", mRhs) mkSynBinding (xmlDoc, bindingPat) (vis, $1, $2, mBindLhs, spBind, optReturnType, rhsExpr, mRhs, [], attrs, None, trivia)) mWhole, localBindingBuilder } @@ -4793,12 +4841,12 @@ objExprBindings: | WITH localBindings { let mWithKwd = (rhs parseState 1) let _localBindingsLastRange, localBindingsBuilder = $2 - mWithKwd, (localBindingsBuilder PreXmlDoc.Empty [] None mWithKwd), [] } + mWithKwd, (localBindingsBuilder PreXmlDoc.Empty [] None SynLeadingKeyword.Synthetic), [] } | OWITH localBindings OEND { let mWithKwd = (rhs parseState 1) let _localBindingsLastRange, localBindingsBuilder = $2 - mWithKwd, (localBindingsBuilder PreXmlDoc.Empty [] None mWithKwd), [] } + mWithKwd, (localBindingsBuilder PreXmlDoc.Empty [] None SynLeadingKeyword.Synthetic), [] } | WITH objectImplementationBlock opt_declEnd { let mWithKwd = rhs parseState 1 @@ -5252,7 +5300,7 @@ atomTypeOrAnonRecdType: { let flds, isStruct = $1 let flds2 = flds |> List.choose (function - | (SynField([], false, Some id, ty, false, _xmldoc, None, _m)) -> Some (id, ty) + | (SynField([], false, Some id, ty, false, _xmldoc, None, _m, _trivia)) -> Some (id, ty) | _ -> reportParseErrorAt (rhs parseState 1) (FSComp.SR.parsInvalidAnonRecdType()); None) SynType.AnonRecd (isStruct, flds2, rhs parseState 1) } diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj index c5b206ed9e6..279296ec02c 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -128,6 +128,9 @@ SyntaxTree\ExternTests.fs + + SyntaxTree\LeadingKeywordTests.fs + FileSystemTests.fs diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected b/tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected index d7f8a490d26..66c52c10aed 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected @@ -7157,9 +7157,11 @@ FSharp.Compiler.Syntax.SynField: Boolean get_isMutable() FSharp.Compiler.Syntax.SynField: Boolean get_isStatic() FSharp.Compiler.Syntax.SynField: Boolean isMutable FSharp.Compiler.Syntax.SynField: Boolean isStatic -FSharp.Compiler.Syntax.SynField: FSharp.Compiler.Syntax.SynField NewSynField(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList], Boolean, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.Ident], FSharp.Compiler.Syntax.SynType, Boolean, FSharp.Compiler.Xml.PreXmlDoc, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynAccess], FSharp.Compiler.Text.Range) +FSharp.Compiler.Syntax.SynField: FSharp.Compiler.Syntax.SynField NewSynField(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList], Boolean, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.Ident], FSharp.Compiler.Syntax.SynType, Boolean, FSharp.Compiler.Xml.PreXmlDoc, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynAccess], FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynFieldTrivia) FSharp.Compiler.Syntax.SynField: FSharp.Compiler.Syntax.SynType fieldType FSharp.Compiler.Syntax.SynField: FSharp.Compiler.Syntax.SynType get_fieldType() +FSharp.Compiler.Syntax.SynField: FSharp.Compiler.SyntaxTrivia.SynFieldTrivia get_trivia() +FSharp.Compiler.Syntax.SynField: FSharp.Compiler.SyntaxTrivia.SynFieldTrivia trivia FSharp.Compiler.Syntax.SynField: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynField: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynField: FSharp.Compiler.Xml.PreXmlDoc get_xmlDoc() @@ -7374,8 +7376,8 @@ FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: FSharp.Compiler.Syntax.SynMem FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: FSharp.Compiler.Syntax.SynMemberFlags memberFlagsForSet FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: FSharp.Compiler.Syntax.SynMemberKind get_propKind() FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: FSharp.Compiler.Syntax.SynMemberKind propKind -FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: FSharp.Compiler.Text.Range equalsRange -FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: FSharp.Compiler.Text.Range get_equalsRange() +FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: FSharp.Compiler.SyntaxTrivia.SynMemberDefnAutoPropertyTrivia get_trivia() +FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: FSharp.Compiler.SyntaxTrivia.SynMemberDefnAutoPropertyTrivia trivia FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: FSharp.Compiler.Text.Range get_range() FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: FSharp.Compiler.Text.Range range FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: FSharp.Compiler.Xml.PreXmlDoc get_xmlDoc() @@ -7386,10 +7388,6 @@ FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: Microsoft.FSharp.Core.FSharpO FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynAccess] get_accessibility() FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynType] get_typeOpt() FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynType] typeOpt -FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] getSetRange -FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_getSetRange() -FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_withKeyword() -FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] withKeyword FSharp.Compiler.Syntax.SynMemberDefn+GetSetMember: FSharp.Compiler.SyntaxTrivia.SynMemberGetSetTrivia get_trivia() FSharp.Compiler.Syntax.SynMemberDefn+GetSetMember: FSharp.Compiler.SyntaxTrivia.SynMemberGetSetTrivia trivia FSharp.Compiler.Syntax.SynMemberDefn+GetSetMember: FSharp.Compiler.Text.Range get_range() @@ -7495,7 +7493,7 @@ FSharp.Compiler.Syntax.SynMemberDefn: Boolean get_IsNestedType() FSharp.Compiler.Syntax.SynMemberDefn: Boolean get_IsOpen() FSharp.Compiler.Syntax.SynMemberDefn: Boolean get_IsValField() FSharp.Compiler.Syntax.SynMemberDefn: FSharp.Compiler.Syntax.SynMemberDefn NewAbstractSlot(FSharp.Compiler.Syntax.SynValSig, FSharp.Compiler.Syntax.SynMemberFlags, FSharp.Compiler.Text.Range) -FSharp.Compiler.Syntax.SynMemberDefn: FSharp.Compiler.Syntax.SynMemberDefn NewAutoProperty(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList], Boolean, FSharp.Compiler.Syntax.Ident, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynType], FSharp.Compiler.Syntax.SynMemberKind, FSharp.Compiler.Syntax.SynMemberFlags, FSharp.Compiler.Syntax.SynMemberFlags, FSharp.Compiler.Xml.PreXmlDoc, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynAccess], FSharp.Compiler.Text.Range, FSharp.Compiler.Syntax.SynExpr, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], FSharp.Compiler.Text.Range) +FSharp.Compiler.Syntax.SynMemberDefn: FSharp.Compiler.Syntax.SynMemberDefn NewAutoProperty(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList], Boolean, FSharp.Compiler.Syntax.Ident, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynType], FSharp.Compiler.Syntax.SynMemberKind, FSharp.Compiler.Syntax.SynMemberFlags, FSharp.Compiler.Syntax.SynMemberFlags, FSharp.Compiler.Xml.PreXmlDoc, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynAccess], FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynMemberDefnAutoPropertyTrivia) FSharp.Compiler.Syntax.SynMemberDefn: FSharp.Compiler.Syntax.SynMemberDefn NewGetSetMember(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynBinding], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynBinding], FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynMemberGetSetTrivia) FSharp.Compiler.Syntax.SynMemberDefn: FSharp.Compiler.Syntax.SynMemberDefn NewImplicitCtor(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynAccess], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList], FSharp.Compiler.Syntax.SynSimplePats, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.Ident], FSharp.Compiler.Xml.PreXmlDoc, FSharp.Compiler.Text.Range) FSharp.Compiler.Syntax.SynMemberDefn: FSharp.Compiler.Syntax.SynMemberDefn NewImplicitInherit(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynExpr, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.Ident], FSharp.Compiler.Text.Range) @@ -7538,11 +7536,9 @@ FSharp.Compiler.Syntax.SynMemberFlags: Boolean get_IsInstance() FSharp.Compiler.Syntax.SynMemberFlags: Boolean get_IsOverrideOrExplicitImpl() FSharp.Compiler.Syntax.SynMemberFlags: FSharp.Compiler.Syntax.SynMemberKind MemberKind FSharp.Compiler.Syntax.SynMemberFlags: FSharp.Compiler.Syntax.SynMemberKind get_MemberKind() -FSharp.Compiler.Syntax.SynMemberFlags: FSharp.Compiler.SyntaxTrivia.SynMemberFlagsTrivia Trivia -FSharp.Compiler.Syntax.SynMemberFlags: FSharp.Compiler.SyntaxTrivia.SynMemberFlagsTrivia get_Trivia() FSharp.Compiler.Syntax.SynMemberFlags: Int32 GetHashCode() FSharp.Compiler.Syntax.SynMemberFlags: System.String ToString() -FSharp.Compiler.Syntax.SynMemberFlags: Void .ctor(Boolean, Boolean, Boolean, Boolean, Boolean, FSharp.Compiler.Syntax.SynMemberKind, FSharp.Compiler.SyntaxTrivia.SynMemberFlagsTrivia) +FSharp.Compiler.Syntax.SynMemberFlags: Void .ctor(Boolean, Boolean, Boolean, Boolean, Boolean, FSharp.Compiler.Syntax.SynMemberKind) FSharp.Compiler.Syntax.SynMemberKind FSharp.Compiler.Syntax.SynMemberKind+Tags: Int32 ClassConstructor FSharp.Compiler.Syntax.SynMemberKind+Tags: Int32 Constructor @@ -9417,14 +9413,12 @@ FSharp.Compiler.SyntaxTrivia.SynArgPatsNamePatPairsTrivia: Void .ctor(FSharp.Com FSharp.Compiler.SyntaxTrivia.SynBindingTrivia FSharp.Compiler.SyntaxTrivia.SynBindingTrivia: FSharp.Compiler.SyntaxTrivia.SynBindingTrivia Zero FSharp.Compiler.SyntaxTrivia.SynBindingTrivia: FSharp.Compiler.SyntaxTrivia.SynBindingTrivia get_Zero() +FSharp.Compiler.SyntaxTrivia.SynBindingTrivia: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword LeadingKeyword +FSharp.Compiler.SyntaxTrivia.SynBindingTrivia: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword get_LeadingKeyword() FSharp.Compiler.SyntaxTrivia.SynBindingTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] EqualsRange -FSharp.Compiler.SyntaxTrivia.SynBindingTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] ExternKeyword -FSharp.Compiler.SyntaxTrivia.SynBindingTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] LetKeyword FSharp.Compiler.SyntaxTrivia.SynBindingTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_EqualsRange() -FSharp.Compiler.SyntaxTrivia.SynBindingTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_ExternKeyword() -FSharp.Compiler.SyntaxTrivia.SynBindingTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_LetKeyword() FSharp.Compiler.SyntaxTrivia.SynBindingTrivia: System.String ToString() -FSharp.Compiler.SyntaxTrivia.SynBindingTrivia: Void .ctor(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range]) +FSharp.Compiler.SyntaxTrivia.SynBindingTrivia: Void .ctor(FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range]) FSharp.Compiler.SyntaxTrivia.SynEnumCaseTrivia FSharp.Compiler.SyntaxTrivia.SynEnumCaseTrivia: FSharp.Compiler.Text.Range EqualsRange FSharp.Compiler.SyntaxTrivia.SynEnumCaseTrivia: FSharp.Compiler.Text.Range get_EqualsRange() @@ -9503,6 +9497,234 @@ FSharp.Compiler.SyntaxTrivia.SynExprTryWithTrivia: FSharp.Compiler.Text.Range ge FSharp.Compiler.SyntaxTrivia.SynExprTryWithTrivia: FSharp.Compiler.Text.Range get_WithToEndRange() FSharp.Compiler.SyntaxTrivia.SynExprTryWithTrivia: System.String ToString() FSharp.Compiler.SyntaxTrivia.SynExprTryWithTrivia: Void .ctor(FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynFieldTrivia +FSharp.Compiler.SyntaxTrivia.SynFieldTrivia: FSharp.Compiler.SyntaxTrivia.SynFieldTrivia Zero +FSharp.Compiler.SyntaxTrivia.SynFieldTrivia: FSharp.Compiler.SyntaxTrivia.SynFieldTrivia get_Zero() +FSharp.Compiler.SyntaxTrivia.SynFieldTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword] LeadingKeyword +FSharp.Compiler.SyntaxTrivia.SynFieldTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword] get_LeadingKeyword() +FSharp.Compiler.SyntaxTrivia.SynFieldTrivia: System.String ToString() +FSharp.Compiler.SyntaxTrivia.SynFieldTrivia: Void .ctor(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword]) +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Abstract: FSharp.Compiler.Text.Range abstractRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Abstract: FSharp.Compiler.Text.Range get_abstractRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+AbstractMember: FSharp.Compiler.Text.Range abstractRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+AbstractMember: FSharp.Compiler.Text.Range get_abstractRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+AbstractMember: FSharp.Compiler.Text.Range get_memberRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+AbstractMember: FSharp.Compiler.Text.Range memberRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+And: FSharp.Compiler.Text.Range andRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+And: FSharp.Compiler.Text.Range get_andRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Default: FSharp.Compiler.Text.Range defaultRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Default: FSharp.Compiler.Text.Range get_defaultRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+DefaultVal: FSharp.Compiler.Text.Range defaultRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+DefaultVal: FSharp.Compiler.Text.Range get_defaultRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+DefaultVal: FSharp.Compiler.Text.Range get_valRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+DefaultVal: FSharp.Compiler.Text.Range valRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Do: FSharp.Compiler.Text.Range doRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Do: FSharp.Compiler.Text.Range get_doRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Extern: FSharp.Compiler.Text.Range externRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Extern: FSharp.Compiler.Text.Range get_externRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Let: FSharp.Compiler.Text.Range get_letRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Let: FSharp.Compiler.Text.Range letRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+LetRec: FSharp.Compiler.Text.Range get_letRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+LetRec: FSharp.Compiler.Text.Range get_recRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+LetRec: FSharp.Compiler.Text.Range letRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+LetRec: FSharp.Compiler.Text.Range recRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Member: FSharp.Compiler.Text.Range get_memberRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Member: FSharp.Compiler.Text.Range memberRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+MemberVal: FSharp.Compiler.Text.Range get_memberRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+MemberVal: FSharp.Compiler.Text.Range get_valRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+MemberVal: FSharp.Compiler.Text.Range memberRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+MemberVal: FSharp.Compiler.Text.Range valRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+New: FSharp.Compiler.Text.Range get_newRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+New: FSharp.Compiler.Text.Range newRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Override: FSharp.Compiler.Text.Range get_overrideRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Override: FSharp.Compiler.Text.Range overrideRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+OverrideVal: FSharp.Compiler.Text.Range get_overrideRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+OverrideVal: FSharp.Compiler.Text.Range get_valRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+OverrideVal: FSharp.Compiler.Text.Range overrideRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+OverrideVal: FSharp.Compiler.Text.Range valRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticAbstract: FSharp.Compiler.Text.Range abstractRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticAbstract: FSharp.Compiler.Text.Range get_abstractRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticAbstract: FSharp.Compiler.Text.Range get_staticRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticAbstract: FSharp.Compiler.Text.Range staticRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticAbstractMember: FSharp.Compiler.Text.Range abstractMember +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticAbstractMember: FSharp.Compiler.Text.Range get_abstractMember() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticAbstractMember: FSharp.Compiler.Text.Range get_memberRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticAbstractMember: FSharp.Compiler.Text.Range get_staticRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticAbstractMember: FSharp.Compiler.Text.Range memberRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticAbstractMember: FSharp.Compiler.Text.Range staticRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticDo: FSharp.Compiler.Text.Range doRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticDo: FSharp.Compiler.Text.Range get_doRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticDo: FSharp.Compiler.Text.Range get_staticRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticDo: FSharp.Compiler.Text.Range staticRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticLet: FSharp.Compiler.Text.Range get_letRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticLet: FSharp.Compiler.Text.Range get_staticRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticLet: FSharp.Compiler.Text.Range letRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticLet: FSharp.Compiler.Text.Range staticRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticLetRec: FSharp.Compiler.Text.Range get_letRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticLetRec: FSharp.Compiler.Text.Range get_recRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticLetRec: FSharp.Compiler.Text.Range get_staticRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticLetRec: FSharp.Compiler.Text.Range letRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticLetRec: FSharp.Compiler.Text.Range recRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticLetRec: FSharp.Compiler.Text.Range staticRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticMember: FSharp.Compiler.Text.Range get_memberRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticMember: FSharp.Compiler.Text.Range get_staticRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticMember: FSharp.Compiler.Text.Range memberRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticMember: FSharp.Compiler.Text.Range staticRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticMemberVal: FSharp.Compiler.Text.Range get_memberRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticMemberVal: FSharp.Compiler.Text.Range get_staticRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticMemberVal: FSharp.Compiler.Text.Range get_valRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticMemberVal: FSharp.Compiler.Text.Range memberRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticMemberVal: FSharp.Compiler.Text.Range staticRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticMemberVal: FSharp.Compiler.Text.Range valRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticVal: FSharp.Compiler.Text.Range get_staticRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticVal: FSharp.Compiler.Text.Range get_valRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticVal: FSharp.Compiler.Text.Range staticRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticVal: FSharp.Compiler.Text.Range valRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Tags: Int32 Abstract +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Tags: Int32 AbstractMember +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Tags: Int32 And +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Tags: Int32 Default +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Tags: Int32 DefaultVal +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Tags: Int32 Do +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Tags: Int32 Extern +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Tags: Int32 Let +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Tags: Int32 LetRec +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Tags: Int32 Member +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Tags: Int32 MemberVal +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Tags: Int32 New +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Tags: Int32 Override +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Tags: Int32 OverrideVal +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Tags: Int32 StaticAbstract +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Tags: Int32 StaticAbstractMember +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Tags: Int32 StaticDo +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Tags: Int32 StaticLet +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Tags: Int32 StaticLetRec +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Tags: Int32 StaticMember +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Tags: Int32 StaticMemberVal +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Tags: Int32 StaticVal +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Tags: Int32 Synthetic +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Tags: Int32 Use +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Tags: Int32 UseRec +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Tags: Int32 Val +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Use: FSharp.Compiler.Text.Range get_useRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Use: FSharp.Compiler.Text.Range useRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+UseRec: FSharp.Compiler.Text.Range get_recRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+UseRec: FSharp.Compiler.Text.Range get_useRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+UseRec: FSharp.Compiler.Text.Range recRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+UseRec: FSharp.Compiler.Text.Range useRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Val: FSharp.Compiler.Text.Range get_valRange() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Val: FSharp.Compiler.Text.Range valRange +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean IsAbstract +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean IsAbstractMember +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean IsAnd +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean IsDefault +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean IsDefaultVal +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean IsDo +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean IsExtern +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean IsLet +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean IsLetRec +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean IsMember +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean IsMemberVal +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean IsNew +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean IsOverride +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean IsOverrideVal +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean IsStaticAbstract +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean IsStaticAbstractMember +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean IsStaticDo +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean IsStaticLet +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean IsStaticLetRec +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean IsStaticMember +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean IsStaticMemberVal +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean IsStaticVal +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean IsSynthetic +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean IsUse +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean IsUseRec +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean IsVal +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean get_IsAbstract() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean get_IsAbstractMember() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean get_IsAnd() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean get_IsDefault() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean get_IsDefaultVal() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean get_IsDo() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean get_IsExtern() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean get_IsLet() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean get_IsLetRec() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean get_IsMember() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean get_IsMemberVal() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean get_IsNew() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean get_IsOverride() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean get_IsOverrideVal() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean get_IsStaticAbstract() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean get_IsStaticAbstractMember() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean get_IsStaticDo() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean get_IsStaticLet() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean get_IsStaticLetRec() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean get_IsStaticMember() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean get_IsStaticMemberVal() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean get_IsStaticVal() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean get_IsSynthetic() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean get_IsUse() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean get_IsUseRec() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Boolean get_IsVal() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword NewAbstract(FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword NewAbstractMember(FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword NewAnd(FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword NewDefault(FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword NewDefaultVal(FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword NewDo(FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword NewExtern(FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword NewLet(FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword NewLetRec(FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword NewMember(FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword NewMemberVal(FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword NewNew(FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword NewOverride(FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword NewOverrideVal(FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword NewStaticAbstract(FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword NewStaticAbstractMember(FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword NewStaticDo(FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword NewStaticLet(FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword NewStaticLetRec(FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword NewStaticMember(FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword NewStaticMemberVal(FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword NewStaticVal(FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword NewUse(FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword NewUseRec(FSharp.Compiler.Text.Range, FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword NewVal(FSharp.Compiler.Text.Range) +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword Synthetic +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword get_Synthetic() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Abstract +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+AbstractMember +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+And +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Default +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+DefaultVal +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Do +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Extern +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Let +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+LetRec +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Member +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+MemberVal +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+New +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Override +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+OverrideVal +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticAbstract +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticAbstractMember +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticDo +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticLet +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticLetRec +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticMember +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticMemberVal +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+StaticVal +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Tags +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Use +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+UseRec +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword+Val +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.Text.Range Range +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: FSharp.Compiler.Text.Range get_Range() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Int32 Tag +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: Int32 get_Tag() +FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword: System.String ToString() FSharp.Compiler.SyntaxTrivia.SynMatchClauseTrivia FSharp.Compiler.SyntaxTrivia.SynMatchClauseTrivia: FSharp.Compiler.SyntaxTrivia.SynMatchClauseTrivia Zero FSharp.Compiler.SyntaxTrivia.SynMatchClauseTrivia: FSharp.Compiler.SyntaxTrivia.SynMatchClauseTrivia get_Zero() @@ -9512,21 +9734,17 @@ FSharp.Compiler.SyntaxTrivia.SynMatchClauseTrivia: Microsoft.FSharp.Core.FSharpO FSharp.Compiler.SyntaxTrivia.SynMatchClauseTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_BarRange() FSharp.Compiler.SyntaxTrivia.SynMatchClauseTrivia: System.String ToString() FSharp.Compiler.SyntaxTrivia.SynMatchClauseTrivia: Void .ctor(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range]) -FSharp.Compiler.SyntaxTrivia.SynMemberFlagsTrivia -FSharp.Compiler.SyntaxTrivia.SynMemberFlagsTrivia: FSharp.Compiler.SyntaxTrivia.SynMemberFlagsTrivia Zero -FSharp.Compiler.SyntaxTrivia.SynMemberFlagsTrivia: FSharp.Compiler.SyntaxTrivia.SynMemberFlagsTrivia get_Zero() -FSharp.Compiler.SyntaxTrivia.SynMemberFlagsTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] AbstractRange -FSharp.Compiler.SyntaxTrivia.SynMemberFlagsTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] DefaultRange -FSharp.Compiler.SyntaxTrivia.SynMemberFlagsTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] MemberRange -FSharp.Compiler.SyntaxTrivia.SynMemberFlagsTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] OverrideRange -FSharp.Compiler.SyntaxTrivia.SynMemberFlagsTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] StaticRange -FSharp.Compiler.SyntaxTrivia.SynMemberFlagsTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_AbstractRange() -FSharp.Compiler.SyntaxTrivia.SynMemberFlagsTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_DefaultRange() -FSharp.Compiler.SyntaxTrivia.SynMemberFlagsTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_MemberRange() -FSharp.Compiler.SyntaxTrivia.SynMemberFlagsTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_OverrideRange() -FSharp.Compiler.SyntaxTrivia.SynMemberFlagsTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_StaticRange() -FSharp.Compiler.SyntaxTrivia.SynMemberFlagsTrivia: System.String ToString() -FSharp.Compiler.SyntaxTrivia.SynMemberFlagsTrivia: Void .ctor(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range]) +FSharp.Compiler.SyntaxTrivia.SynMemberDefnAutoPropertyTrivia +FSharp.Compiler.SyntaxTrivia.SynMemberDefnAutoPropertyTrivia: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword LeadingKeyword +FSharp.Compiler.SyntaxTrivia.SynMemberDefnAutoPropertyTrivia: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword get_LeadingKeyword() +FSharp.Compiler.SyntaxTrivia.SynMemberDefnAutoPropertyTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] EqualsRange +FSharp.Compiler.SyntaxTrivia.SynMemberDefnAutoPropertyTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] GetSetKeyword +FSharp.Compiler.SyntaxTrivia.SynMemberDefnAutoPropertyTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] WithKeyword +FSharp.Compiler.SyntaxTrivia.SynMemberDefnAutoPropertyTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_EqualsRange() +FSharp.Compiler.SyntaxTrivia.SynMemberDefnAutoPropertyTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_GetSetKeyword() +FSharp.Compiler.SyntaxTrivia.SynMemberDefnAutoPropertyTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_WithKeyword() +FSharp.Compiler.SyntaxTrivia.SynMemberDefnAutoPropertyTrivia: System.String ToString() +FSharp.Compiler.SyntaxTrivia.SynMemberDefnAutoPropertyTrivia: Void .ctor(FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range]) FSharp.Compiler.SyntaxTrivia.SynMemberGetSetTrivia FSharp.Compiler.SyntaxTrivia.SynMemberGetSetTrivia: FSharp.Compiler.Text.Range WithKeyword FSharp.Compiler.SyntaxTrivia.SynMemberGetSetTrivia: FSharp.Compiler.Text.Range get_WithKeyword() @@ -9608,8 +9826,13 @@ FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia: FSharp.Compiler.Text.Range get_Ar FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia: System.String ToString() FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia: Void .ctor(FSharp.Compiler.Text.Range) FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia +FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia: Boolean Equals(FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia) +FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia: Boolean Equals(System.Object) +FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia: Boolean Equals(System.Object, System.Collections.IEqualityComparer) FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia: FSharp.Compiler.Text.Range OrKeyword FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia: FSharp.Compiler.Text.Range get_OrKeyword() +FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia: Int32 GetHashCode() +FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia: Int32 GetHashCode(System.Collections.IEqualityComparer) FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia: System.String ToString() FSharp.Compiler.SyntaxTrivia.SynTypeOrTrivia: Void .ctor(FSharp.Compiler.Text.Range) FSharp.Compiler.SyntaxTrivia.SynUnionCaseTrivia @@ -9618,16 +9841,16 @@ FSharp.Compiler.SyntaxTrivia.SynUnionCaseTrivia: Microsoft.FSharp.Core.FSharpOpt FSharp.Compiler.SyntaxTrivia.SynUnionCaseTrivia: System.String ToString() FSharp.Compiler.SyntaxTrivia.SynUnionCaseTrivia: Void .ctor(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range]) FSharp.Compiler.SyntaxTrivia.SynValSigTrivia +FSharp.Compiler.SyntaxTrivia.SynValSigTrivia: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword LeadingKeyword +FSharp.Compiler.SyntaxTrivia.SynValSigTrivia: FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword get_LeadingKeyword() FSharp.Compiler.SyntaxTrivia.SynValSigTrivia: FSharp.Compiler.SyntaxTrivia.SynValSigTrivia Zero FSharp.Compiler.SyntaxTrivia.SynValSigTrivia: FSharp.Compiler.SyntaxTrivia.SynValSigTrivia get_Zero() FSharp.Compiler.SyntaxTrivia.SynValSigTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] EqualsRange -FSharp.Compiler.SyntaxTrivia.SynValSigTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] ValKeyword FSharp.Compiler.SyntaxTrivia.SynValSigTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] WithKeyword FSharp.Compiler.SyntaxTrivia.SynValSigTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_EqualsRange() -FSharp.Compiler.SyntaxTrivia.SynValSigTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_ValKeyword() FSharp.Compiler.SyntaxTrivia.SynValSigTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_WithKeyword() FSharp.Compiler.SyntaxTrivia.SynValSigTrivia: System.String ToString() -FSharp.Compiler.SyntaxTrivia.SynValSigTrivia: Void .ctor(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range]) +FSharp.Compiler.SyntaxTrivia.SynValSigTrivia: Void .ctor(FSharp.Compiler.SyntaxTrivia.SynLeadingKeyword, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range]) FSharp.Compiler.Text.ISourceText FSharp.Compiler.Text.ISourceText: Boolean ContentEquals(FSharp.Compiler.Text.ISourceText) FSharp.Compiler.Text.ISourceText: Boolean SubTextEquals(System.String, Int32) diff --git a/tests/service/SyntaxTreeTests/BindingTests.fs b/tests/service/SyntaxTreeTests/BindingTests.fs index 95ea6685947..5a05af975e2 100644 --- a/tests/service/SyntaxTreeTests/BindingTests.fs +++ b/tests/service/SyntaxTreeTests/BindingTests.fs @@ -2,6 +2,7 @@ module FSharp.Compiler.Service.Tests.SyntaxTreeTests.BindingTestsTests open FSharp.Compiler.Service.Tests.Common open FSharp.Compiler.Syntax +open FSharp.Compiler.SyntaxTrivia open NUnit.Framework [] @@ -329,7 +330,7 @@ let ``Range of let keyword should be present in SynModuleDecl.Let binding`` () = match parseResults with | ParsedInput.ImplFile (ParsedImplFileInput (contents = [ SynModuleOrNamespace.SynModuleOrNamespace(decls = [ - SynModuleDecl.Let(bindings = [SynBinding(trivia={ LetKeyword = Some mLet })]) + SynModuleDecl.Let(bindings = [SynBinding(trivia={ LeadingKeyword = SynLeadingKeyword.Let mLet })]) ]) ])) -> assertRange (1, 0) (1, 3) mLet | _ -> Assert.Fail "Could not get valid AST" @@ -346,7 +347,7 @@ let v = 12 match parseResults with | ParsedInput.ImplFile (ParsedImplFileInput (contents = [ SynModuleOrNamespace.SynModuleOrNamespace(decls = [ - SynModuleDecl.Let(bindings = [SynBinding(trivia={ LetKeyword = Some mLet })]) + SynModuleDecl.Let(bindings = [SynBinding(trivia={ LeadingKeyword = SynLeadingKeyword.Let mLet })]) ]) ])) -> assertRange (5, 0) (5, 3) mLet | _ -> Assert.Fail "Could not get valid AST" @@ -362,7 +363,7 @@ let a = match parseResults with | ParsedInput.ImplFile (ParsedImplFileInput (contents = [ SynModuleOrNamespace.SynModuleOrNamespace(decls = [ - SynModuleDecl.Let(bindings = [SynBinding(expr=SynExpr.LetOrUse(bindings=[SynBinding(trivia={ LetKeyword = Some mLet })]))]) + SynModuleDecl.Let(bindings = [SynBinding(expr=SynExpr.LetOrUse(bindings=[SynBinding(trivia={ LeadingKeyword = SynLeadingKeyword.Let mLet })]))]) ]) ])) -> assertRange (3, 4) (3, 7) mLet | _ -> Assert.Fail "Could not get valid AST" diff --git a/tests/service/SyntaxTreeTests/ExternTests.fs b/tests/service/SyntaxTreeTests/ExternTests.fs index 0599307d994..43ea6e5435a 100644 --- a/tests/service/SyntaxTreeTests/ExternTests.fs +++ b/tests/service/SyntaxTreeTests/ExternTests.fs @@ -13,7 +13,7 @@ let ``extern keyword is present in trivia`` () = | ParsedInput.ImplFile(ParsedImplFileInput(contents = [ SynModuleOrNamespace.SynModuleOrNamespace(decls = [ SynModuleDecl.Let(bindings = [ - SynBinding(trivia = { ExternKeyword = Some mExtern }) + SynBinding(trivia = { LeadingKeyword = SynLeadingKeyword.Extern mExtern }) ]) ]) ])) -> diff --git a/tests/service/SyntaxTreeTests/LeadingKeywordTests.fs b/tests/service/SyntaxTreeTests/LeadingKeywordTests.fs new file mode 100644 index 00000000000..c247376436b --- /dev/null +++ b/tests/service/SyntaxTreeTests/LeadingKeywordTests.fs @@ -0,0 +1,561 @@ +module FSharp.Compiler.Service.Tests.SyntaxTreeTests.LeadingKeywordTests + +open FSharp.Compiler.Service.Tests.Common +open FSharp.Compiler.Syntax +open FSharp.Compiler.SyntaxTrivia +open NUnit.Framework + +[] +let ``let keyword`` () = + let parseResults = getParseResults "let a b = b + 1" + + match parseResults with + | ParsedInput.ImplFile(ParsedImplFileInput(contents = [ + SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Let(bindings = [ + SynBinding(trivia = { LeadingKeyword = SynLeadingKeyword.Let mLet }) + ]) + ]) + ])) -> + assertRange (1, 0) (1, 3) mLet + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``let rec keyword`` () = + let parseResults = getParseResults "let rec a b = b + 1" + + match parseResults with + | ParsedInput.ImplFile(ParsedImplFileInput(contents = [ + SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Let(bindings = [ + SynBinding(trivia = { LeadingKeyword = SynLeadingKeyword.LetRec(mLet, mRec) }) + ]) + ]) + ])) -> + assertRange (1, 0) (1, 3) mLet + assertRange (1, 4) (1, 7) mRec + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``and keyword`` () = + let parseResults = + getParseResults """ +let rec a b = b + 1 +and d e = e + 1 +""" + + match parseResults with + | ParsedInput.ImplFile(ParsedImplFileInput(contents = [ + SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Let(bindings = [ + SynBinding _ + SynBinding(trivia = { LeadingKeyword = SynLeadingKeyword.And mAnd }) + ]) + ]) + ])) -> + assertRange (3, 0) (3, 3) mAnd + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``use keyword`` () = + let parseResults = + getParseResults """ +do + use x = X() + () +""" + + match parseResults with + | ParsedInput.ImplFile(ParsedImplFileInput(contents = [ + SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Expr(expr = + SynExpr.Do(expr = + SynExpr.LetOrUse(bindings = [ + SynBinding(trivia = { LeadingKeyword = SynLeadingKeyword.Use mUse }) + ]) + ) + ) + ]) + ])) -> + assertRange (3, 4) (3, 7) mUse + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``use rec keyword`` () = + let parseResults = + getParseResults """ +do + use rec x = X() + () +""" + + match parseResults with + | ParsedInput.ImplFile(ParsedImplFileInput(contents = [ + SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Expr(expr = + SynExpr.Do(expr = + SynExpr.LetOrUse(bindings = [ + SynBinding(trivia = { LeadingKeyword = SynLeadingKeyword.UseRec(mUse, mRec) }) + ]) + ) + ) + ]) + ])) -> + assertRange (3, 4) (3, 7) mUse + assertRange (3, 8) (3, 11) mRec + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``extern keyword`` () = + let parseResults = getParseResults "extern void Meh()" + + match parseResults with + | ParsedInput.ImplFile(ParsedImplFileInput(contents = [ + SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Let(bindings = [ + SynBinding(trivia = { LeadingKeyword = SynLeadingKeyword.Extern mExtern }) + ]) + ]) + ])) -> + assertRange (1, 0) (1, 6) mExtern + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``member keyword`` () = + let parseResults = getParseResults """ +type X = + member this.Y () = () +""" + + match parseResults with + | ParsedInput.ImplFile(ParsedImplFileInput(contents = [ + SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Types(typeDefns = [ + SynTypeDefn(typeRepr = SynTypeDefnRepr.ObjectModel(members = [ + SynMemberDefn.Member(memberDefn = SynBinding(trivia = { LeadingKeyword = SynLeadingKeyword.Member mMember })) + ])) + ]) + ]) + ])) -> + assertRange (3, 4) (3, 10) mMember + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``member val keyword`` () = + let parseResults = getParseResults """ +type X = + member val Y : int = 1 +""" + + match parseResults with + | ParsedInput.ImplFile(ParsedImplFileInput(contents = [ + SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Types(typeDefns = [ + SynTypeDefn(typeRepr = SynTypeDefnRepr.ObjectModel(members = [ + SynMemberDefn.AutoProperty(trivia = { LeadingKeyword = SynLeadingKeyword.MemberVal(mMember, mVal) }) + ])) + ]) + ]) + ])) -> + assertRange (3, 4) (3, 10) mMember + assertRange (3, 11) (3, 14) mVal + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``override keyword`` () = + let parseResults = getParseResults """ +type D = + override E : string = "" +""" + + match parseResults with + | ParsedInput.ImplFile(ParsedImplFileInput(contents = [ + SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Types(typeDefns = [ + SynTypeDefn(typeRepr = SynTypeDefnRepr.ObjectModel(members = [ + SynMemberDefn.Member(memberDefn = SynBinding(trivia = { LeadingKeyword = SynLeadingKeyword.Override(mOverride) })) + ])) + ]) + ]) + ])) -> + assertRange (3, 4) (3, 12) mOverride + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``override val keyword`` () = + let parseResults = getParseResults """ +type X = + override val Y : int = 1 +""" + + match parseResults with + | ParsedInput.ImplFile(ParsedImplFileInput(contents = [ + SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Types(typeDefns = [ + SynTypeDefn(typeRepr = SynTypeDefnRepr.ObjectModel(members = [ + SynMemberDefn.AutoProperty(trivia = { LeadingKeyword = SynLeadingKeyword.OverrideVal(mOverride, mVal) }) + ])) + ]) + ]) + ])) -> + assertRange (3, 4) (3, 12) mOverride + assertRange (3, 13) (3, 16) mVal + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``abstract keyword`` () = + let parseResults = getParseResults """ +type X = + abstract Y : int +""" + + match parseResults with + | ParsedInput.ImplFile(ParsedImplFileInput(contents = [ + SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Types(typeDefns = [ + SynTypeDefn(typeRepr = SynTypeDefnRepr.ObjectModel(members = [ + SynMemberDefn.AbstractSlot(slotSig = SynValSig(trivia = { LeadingKeyword = SynLeadingKeyword.Abstract mAbstract })) + ])) + ]) + ]) + ])) -> + assertRange (3, 4) (3, 12) mAbstract + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``abstract member keyword`` () = + let parseResults = getParseResults """ +type X = + abstract member Y : int +""" + + match parseResults with + | ParsedInput.ImplFile(ParsedImplFileInput(contents = [ + SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Types(typeDefns = [ + SynTypeDefn(typeRepr = SynTypeDefnRepr.ObjectModel(members = [ + SynMemberDefn.AbstractSlot(slotSig = SynValSig(trivia = { LeadingKeyword = SynLeadingKeyword.AbstractMember(mAbstract, mMember) })) + ])) + ]) + ]) + ])) -> + assertRange (3, 4) (3, 12) mAbstract + assertRange (3, 13) (3, 19) mMember + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``static member keyword`` () = + let parseResults = getParseResults """ +type X = + static member Y : int = 1 +""" + + match parseResults with + | ParsedInput.ImplFile(ParsedImplFileInput(contents = [ + SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Types(typeDefns = [ + SynTypeDefn(typeRepr = SynTypeDefnRepr.ObjectModel(members = [ + SynMemberDefn.Member(memberDefn = SynBinding(trivia = { LeadingKeyword = SynLeadingKeyword.StaticMember(mStatic, mMember) })) + ])) + ]) + ]) + ])) -> + assertRange (3, 4) (3, 10) mStatic + assertRange (3, 11) (3, 17) mMember + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``static member val keyword`` () = + let parseResults = getParseResults """ +type X = + static member val Y : int = 1 +""" + + match parseResults with + | ParsedInput.ImplFile(ParsedImplFileInput(contents = [ + SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Types(typeDefns = [ + SynTypeDefn(typeRepr = SynTypeDefnRepr.ObjectModel(members = [ + SynMemberDefn.AutoProperty(trivia = { LeadingKeyword = SynLeadingKeyword.StaticMemberVal(mStatic, mMember, mVal) }) + ])) + ]) + ]) + ])) -> + assertRange (3, 4) (3, 10) mStatic + assertRange (3, 11) (3, 17) mMember + assertRange (3, 18) (3, 21) mVal + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``static abstract keyword`` () = + let parseResults = getParseResults """ +type X = + static abstract Y : int -> int +""" + + match parseResults with + | ParsedInput.ImplFile(ParsedImplFileInput(contents = [ + SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Types(typeDefns = [ + SynTypeDefn(typeRepr = SynTypeDefnRepr.ObjectModel(members = [ + SynMemberDefn.AbstractSlot(slotSig = SynValSig(trivia = { LeadingKeyword = SynLeadingKeyword.StaticAbstract(mStatic, mAbstract) })) + ])) + ]) + ]) + ])) -> + assertRange (3, 4) (3, 10) mStatic + assertRange (3, 11) (3, 19) mAbstract + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``static abstract member keyword`` () = + let parseResults = getParseResults """ +type X = + static abstract member Y : int -> int +""" + + match parseResults with + | ParsedInput.ImplFile(ParsedImplFileInput(contents = [ + SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Types(typeDefns = [ + SynTypeDefn(typeRepr = SynTypeDefnRepr.ObjectModel(members = [ + SynMemberDefn.AbstractSlot(slotSig = SynValSig(trivia = { + LeadingKeyword = SynLeadingKeyword.StaticAbstractMember(mStatic, mAbstract, mMember) + })) + ])) + ]) + ]) + ])) -> + assertRange (3, 4) (3, 10) mStatic + assertRange (3, 11) (3, 19) mAbstract + assertRange (3,20) (3, 26) mMember + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``static val keyword`` () = + let parseResults = getParseResultsOfSignatureFile """ +namespace Meh + +type X = + static val Y : int -> int +""" + + match parseResults with + | ParsedInput.SigFile(ParsedSigFileInput(contents = [ + SynModuleOrNamespaceSig(decls = [ + SynModuleSigDecl.Types(types = [ + SynTypeDefnSig(typeRepr = SynTypeDefnSigRepr.ObjectModel(memberSigs = [ + SynMemberSig.ValField(field = + SynField(trivia = { LeadingKeyword = Some (SynLeadingKeyword.StaticVal(mStatic, mVal)) })) + ])) + ]) + ]) + ])) -> + assertRange (5, 4) (5, 10) mStatic + assertRange (5, 11) (5, 14) mVal + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``default keyword`` () = + let parseResults = + getParseResultsOfSignatureFile + """ +namespace X + +type Y = + default F : int +""" + + match parseResults with + | ParsedInput.SigFile (ParsedSigFileInput (contents = [ SynModuleOrNamespaceSig(decls = [ + SynModuleSigDecl.Types(types =[ + SynTypeDefnSig(typeRepr=SynTypeDefnSigRepr.ObjectModel(memberSigs=[ + SynMemberSig.Member(memberSig = SynValSig(trivia = { LeadingKeyword = SynLeadingKeyword.Default mDefault })) + ])) + ]) + ]) ])) -> + assertRange (5, 4) (5, 11) mDefault + | _ -> Assert.Fail "Could not get valid AST" + +[] +let ``default val keyword`` () = + let ast = """ +type Foo = + default val A : int = 1 +""" + |> getParseResults + + match ast with + | ParsedInput.ImplFile(ParsedImplFileInput(contents = [ + SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Types ([ + SynTypeDefn.SynTypeDefn (typeRepr = SynTypeDefnRepr.ObjectModel (members=[ + SynMemberDefn.AutoProperty(trivia = { LeadingKeyword = SynLeadingKeyword.DefaultVal(mDefault , mVal) }) + ])) + ], _) + ]) + ])) -> + assertRange (3, 4) (3, 11) mDefault + assertRange (3, 12) (3, 15) mVal + | _ -> + Assert.Fail "Could not get valid AST" + +[] +let ``val keyword`` () = + let parseResults = + getParseResultsOfSignatureFile + """ +namespace X + +type Y = + val F : int +""" + + match parseResults with + | ParsedInput.SigFile (ParsedSigFileInput (contents = [ SynModuleOrNamespaceSig(decls = [ + SynModuleSigDecl.Types(types =[ + SynTypeDefnSig(typeRepr=SynTypeDefnSigRepr.ObjectModel(memberSigs=[ + SynMemberSig.ValField(field = SynField(trivia = { LeadingKeyword = Some (SynLeadingKeyword.Val mVal) })) + ])) + ]) + ]) ])) -> + assertRange (5, 4) (5, 7) mVal + | _ -> Assert.Fail "Could not get valid AST" + +[] +let ``new keyword`` () = + let parseResults = getParseResults """ +type Y() = + new (message:string) = Y() +""" + + match parseResults with + | ParsedInput.ImplFile(ParsedImplFileInput(contents = [ + SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Types(typeDefns = [ + SynTypeDefn(typeRepr = SynTypeDefnRepr.ObjectModel(members = [ + SynMemberDefn.ImplicitCtor _ + SynMemberDefn.Member(memberDefn = SynBinding(trivia = { LeadingKeyword = SynLeadingKeyword.New mNew })) + ])) + ]) + ]) + ])) -> + assertRange (3, 4) (3, 7) mNew + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let ``synthetic keyword`` () = + let parseResults = + getParseResults """ +{ new ISomething with + a = () } +""" + + match parseResults with + | ParsedInput.ImplFile(ParsedImplFileInput(contents = [ + SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Expr(expr = + SynExpr.ObjExpr(bindings = [ + SynBinding(trivia = { LeadingKeyword = SynLeadingKeyword.Synthetic }) + ]) + ) + ]) + ])) -> + Assert.Pass() + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let `` static let keyword`` () = + let parseResults = + getParseResults """ +type X = + static let PI = 3.14 +""" + + match parseResults with + | ParsedInput.ImplFile(ParsedImplFileInput(contents = [ + SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Types(typeDefns = [ + SynTypeDefn(typeRepr = SynTypeDefnRepr.ObjectModel(members = [ + SynMemberDefn.LetBindings(bindings = [ + SynBinding(trivia = { LeadingKeyword = SynLeadingKeyword.StaticLet(mStatic, mLet) }) + ]) + ])) + ]) + ]) + ])) -> + assertRange (3, 4) (3, 10) mStatic + assertRange (3, 11) (3, 14) mLet + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let `` static let rec keyword`` () = + let parseResults = + getParseResults """ +type X = + static let rec forever () = forever() +""" + + match parseResults with + | ParsedInput.ImplFile(ParsedImplFileInput(contents = [ + SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Types(typeDefns = [ + SynTypeDefn(typeRepr = SynTypeDefnRepr.ObjectModel(members = [ + SynMemberDefn.LetBindings(bindings = [ + SynBinding(trivia = { LeadingKeyword = SynLeadingKeyword.StaticLetRec(mStatic, mLet, mRec) }) + ]) + ])) + ]) + ]) + ])) -> + assertRange (3, 4) (3, 10) mStatic + assertRange (3, 11) (3, 14) mLet + assertRange (3, 15) (3, 18) mRec + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let `` do keyword`` () = + let parseResults = + getParseResults """ +type X = + do () +""" + + match parseResults with + | ParsedInput.ImplFile(ParsedImplFileInput(contents = [ + SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Types(typeDefns = [ + SynTypeDefn(typeRepr = SynTypeDefnRepr.ObjectModel(members = [ + SynMemberDefn.LetBindings(bindings = [ + SynBinding(trivia = { LeadingKeyword = SynLeadingKeyword.Do(mDo) }) + ]) + ])) + ]) + ]) + ])) -> + assertRange (3, 4) (3, 6) mDo + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" + +[] +let `` do static keyword`` () = + let parseResults = + getParseResults """ +type X = + static do () +""" + + match parseResults with + | ParsedInput.ImplFile(ParsedImplFileInput(contents = [ + SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Types(typeDefns = [ + SynTypeDefn(typeRepr = SynTypeDefnRepr.ObjectModel(members = [ + SynMemberDefn.LetBindings(bindings = [ + SynBinding(trivia = { LeadingKeyword = SynLeadingKeyword.StaticDo(mStatic, mDo) }) + ]) + ])) + ]) + ]) + ])) -> + assertRange (3, 4) (3, 10) mStatic + assertRange (3, 11) (3, 13) mDo + | _ -> Assert.Fail $"Could not get valid AST, got {parseResults}" diff --git a/tests/service/SyntaxTreeTests/MemberFlagTests.fs b/tests/service/SyntaxTreeTests/MemberFlagTests.fs index c29aad29300..c1c55b3a07c 100644 --- a/tests/service/SyntaxTreeTests/MemberFlagTests.fs +++ b/tests/service/SyntaxTreeTests/MemberFlagTests.fs @@ -2,6 +2,7 @@ module FSharp.Compiler.Service.Tests.SyntaxTreeTests.MemberFlagTestsTests open FSharp.Compiler.Service.Tests.Common open FSharp.Compiler.Syntax +open FSharp.Compiler.SyntaxTrivia open NUnit.Framework @@ -25,14 +26,12 @@ type Y = | ParsedInput.SigFile (ParsedSigFileInput (contents = [ SynModuleOrNamespaceSig(decls = [ SynModuleSigDecl.Types(types =[ SynTypeDefnSig(typeRepr=SynTypeDefnSigRepr.ObjectModel(memberSigs=[ - SynMemberSig.Member(flags={ Trivia= { AbstractRange = Some mAbstract1 } }) - SynMemberSig.Member(flags={ Trivia= { AbstractRange = Some mAbstract2 - MemberRange = Some mMember1 } }) - SynMemberSig.Member(flags={ Trivia= { StaticRange = Some mStatic3 - MemberRange = Some mMember3 } }) - SynMemberSig.Member(flags={ Trivia= { MemberRange = Some mMember4 } }) - SynMemberSig.Member(flags={ Trivia= { OverrideRange = Some mOverride5 } }) - SynMemberSig.Member(flags={ Trivia= { DefaultRange = Some mDefault6 } }) + SynMemberSig.Member(memberSig = SynValSig(trivia = { LeadingKeyword = SynLeadingKeyword.Abstract mAbstract1 })) + SynMemberSig.Member(memberSig = SynValSig(trivia = { LeadingKeyword = SynLeadingKeyword.AbstractMember(mAbstract2, mMember1) })) + SynMemberSig.Member(memberSig = SynValSig(trivia = { LeadingKeyword = SynLeadingKeyword.StaticMember(mStatic3, mMember3) })) + SynMemberSig.Member(memberSig = SynValSig(trivia = { LeadingKeyword = SynLeadingKeyword.Member mMember4 })) + SynMemberSig.Member(memberSig = SynValSig(trivia = { LeadingKeyword = SynLeadingKeyword.Override mOverride5 })) + SynMemberSig.Member(memberSig = SynValSig(trivia = { LeadingKeyword = SynLeadingKeyword.Default mDefault6 })) ])) ]) ]) ])) -> @@ -60,9 +59,8 @@ type Foo = SynModuleOrNamespace.SynModuleOrNamespace(decls = [ SynModuleDecl.Types ([ SynTypeDefn.SynTypeDefn (typeRepr = SynTypeDefnRepr.ObjectModel (members=[ - SynMemberDefn.AbstractSlot(flags={ Trivia = { AbstractRange = Some mAbstract1 } }) - SynMemberDefn.AbstractSlot(flags={ Trivia = { AbstractRange = Some mAbstract2 - MemberRange = Some mMember2 } }) + SynMemberDefn.AbstractSlot(slotSig = SynValSig(trivia = { LeadingKeyword = SynLeadingKeyword.Abstract mAbstract1 })) + SynMemberDefn.AbstractSlot(slotSig = SynValSig(trivia = { LeadingKeyword = SynLeadingKeyword.AbstractMember(mAbstract2, mMember2) })) ])) ], _) ]) @@ -84,31 +82,36 @@ type Foo = """ |> getParseResults + let (|LeadingKeyword|_|) md = + match md with + | SynMemberDefn.AutoProperty(trivia = { LeadingKeyword = lk }) -> Some lk + | _ -> None + match ast with | ParsedInput.ImplFile(ParsedImplFileInput(contents = [ SynModuleOrNamespace.SynModuleOrNamespace(decls = [ SynModuleDecl.Types ([ SynTypeDefn.SynTypeDefn (typeRepr = SynTypeDefnRepr.ObjectModel (members=[ - SynMemberDefn.AutoProperty(memberFlags= flags1) - SynMemberDefn.AutoProperty(memberFlags= flags2) - SynMemberDefn.AutoProperty(memberFlags= flags3) - SynMemberDefn.AutoProperty(memberFlags= flags4) + LeadingKeyword(SynLeadingKeyword.StaticMemberVal(mStatic1, mMember1, mVal1)) + LeadingKeyword(SynLeadingKeyword.MemberVal(mMember2, mVal2)) + LeadingKeyword(SynLeadingKeyword.OverrideVal(mOverride3, mVal3)) + LeadingKeyword(SynLeadingKeyword.DefaultVal(mDefault4, mVal4)) ])) ], _) ]) ])) -> - let ({ Trivia = flagsTrivia1 } : SynMemberFlags) = flags1 - assertRange (3, 4) (3, 10) flagsTrivia1.StaticRange.Value - assertRange (3, 11) (3, 17) flagsTrivia1.MemberRange.Value + assertRange (3, 4) (3, 10) mStatic1 + assertRange (3, 11) (3, 17) mMember1 + assertRange (3, 18) (3, 21) mVal1 - let ({ Trivia = flagsTrivia2 } : SynMemberFlags) = flags2 - assertRange (4, 4) (4, 10) flagsTrivia2.MemberRange.Value + assertRange (4, 4) (4, 10) mMember2 + assertRange (4, 11) (4, 14) mVal2 - let ({ Trivia = flagsTrivia3 } : SynMemberFlags) = flags3 - assertRange (5, 4) (5, 12) flagsTrivia3.OverrideRange.Value + assertRange (5, 4) (5, 12) mOverride3 + assertRange (5, 13) (5, 16) mVal3 - let ({ Trivia = flagsTrivia4 } : SynMemberFlags) = flags4 - assertRange (6, 4) (6, 11) flagsTrivia4.DefaultRange.Value + assertRange (6, 4) (6, 11) mDefault4 + assertRange (6, 12) (6, 15) mVal4 | _ -> Assert.Fail "Could not get valid AST" @@ -123,16 +126,20 @@ type Foo = """ |> getParseResults + let (|LeadingKeyword|_|) md = + match md with + | SynMemberDefn.Member(memberDefn = SynBinding(trivia = { LeadingKeyword = lk })) -> Some lk + | _ -> None + match ast with | ParsedInput.ImplFile(ParsedImplFileInput(contents = [ SynModuleOrNamespace.SynModuleOrNamespace(decls = [ SynModuleDecl.Types ([ SynTypeDefn.SynTypeDefn (typeRepr = SynTypeDefnRepr.ObjectModel (members=[ - SynMemberDefn.Member(memberDefn=SynBinding(valData=SynValData(memberFlags=Some { Trivia = { StaticRange = Some mStatic1 - MemberRange = Some mMember1 } }))) - SynMemberDefn.Member(memberDefn=SynBinding(valData=SynValData(memberFlags=Some { Trivia = { MemberRange = Some mMember2 } }))) - SynMemberDefn.Member(memberDefn=SynBinding(valData=SynValData(memberFlags=Some { Trivia = { OverrideRange = Some mOverride3 } }))) - SynMemberDefn.Member(memberDefn=SynBinding(valData=SynValData(memberFlags=Some { Trivia = { DefaultRange = Some mDefaultRange4 } }))) + LeadingKeyword(SynLeadingKeyword.StaticMember(mStatic1, mMember1)) + LeadingKeyword(SynLeadingKeyword.Member(mMember2)) + LeadingKeyword(SynLeadingKeyword.Override(mOverride3)) + LeadingKeyword(SynLeadingKeyword.Default mDefaultRange4) ])) ], _) ]) @@ -163,11 +170,11 @@ let meh = SynModuleDecl.Let (bindings = [ SynBinding(expr=SynExpr.ObjExpr( members=[ - SynMemberDefn.Member(memberDefn=SynBinding(valData=SynValData(memberFlags=Some { Trivia = { OverrideRange = Some mOverride1 } }))) - SynMemberDefn.Member(memberDefn=SynBinding(valData=SynValData(memberFlags=Some { Trivia = { MemberRange = Some mMember2 } }))) + SynMemberDefn.Member(memberDefn=SynBinding(trivia = { LeadingKeyword = SynLeadingKeyword.Override mOverride1 })) + SynMemberDefn.Member(memberDefn=SynBinding(trivia = { LeadingKeyword = SynLeadingKeyword.Member mMember2 })) ] extraImpls=[ SynInterfaceImpl(members=[ - SynMemberDefn.Member(memberDefn=SynBinding(valData=SynValData(memberFlags=Some { Trivia = { MemberRange = Some mMember3 } }))) + SynMemberDefn.Member(memberDefn=SynBinding(trivia = { LeadingKeyword = SynLeadingKeyword.Member mMember3 })) ]) ])) ]) ]) ])) -> diff --git a/tests/service/SyntaxTreeTests/MemberTests.fs b/tests/service/SyntaxTreeTests/MemberTests.fs index 084af4bff85..24693fd12bc 100644 --- a/tests/service/SyntaxTreeTests/MemberTests.fs +++ b/tests/service/SyntaxTreeTests/MemberTests.fs @@ -19,7 +19,7 @@ type Person(name : string, age : int) = match parseResults with | ParsedInput.ImplFile (ParsedImplFileInput (contents = [ SynModuleOrNamespace.SynModuleOrNamespace(decls = [ SynModuleDecl.Types( - typeDefns = [ SynTypeDefn(typeRepr = SynTypeDefnRepr.ObjectModel(members = [_ ; SynMemberDefn.AutoProperty(equalsRange = mEquals)])) ] + typeDefns = [ SynTypeDefn(typeRepr = SynTypeDefnRepr.ObjectModel(members = [_ ; SynMemberDefn.AutoProperty(trivia = { EqualsRange = Some mEquals })])) ] ) ]) ])) -> assertRange (5, 20) (5, 21) mEquals @@ -39,8 +39,8 @@ type Foo() = | ParsedInput.ImplFile (ParsedImplFileInput (contents = [ SynModuleOrNamespace.SynModuleOrNamespace(decls = [ SynModuleDecl.Types( typeDefns = [ SynTypeDefn(typeRepr = SynTypeDefnRepr.ObjectModel(members = [_ - SynMemberDefn.AutoProperty(withKeyword=Some mWith) - SynMemberDefn.AutoProperty(withKeyword=None)])) ] + SynMemberDefn.AutoProperty(trivia = { WithKeyword = Some mWith }) + SynMemberDefn.AutoProperty(trivia = { WithKeyword = None })])) ] ) ]) ])) -> assertRange (3, 39) (3, 43) mWith diff --git a/tests/service/SyntaxTreeTests/SignatureTypeTests.fs b/tests/service/SyntaxTreeTests/SignatureTypeTests.fs index 7532e835ca2..8d1d94d450f 100644 --- a/tests/service/SyntaxTreeTests/SignatureTypeTests.fs +++ b/tests/service/SyntaxTreeTests/SignatureTypeTests.fs @@ -2,6 +2,7 @@ module FSharp.Compiler.Service.Tests.SyntaxTreeTests.SignatureTypeTests open FSharp.Compiler.Service.Tests.Common open FSharp.Compiler.Syntax +open FSharp.Compiler.SyntaxTrivia open NUnit.Framework [] @@ -378,7 +379,7 @@ val a : int match parseResults with | ParsedInput.SigFile (ParsedSigFileInput (contents=[ SynModuleOrNamespaceSig(decls=[ - SynModuleSigDecl.Val(valSig = SynValSig(trivia = { ValKeyword = Some mVal })) + SynModuleSigDecl.Val(valSig = SynValSig(trivia = { LeadingKeyword = SynLeadingKeyword.Val mVal })) ] ) ])) -> assertRange (6, 0) (6, 3) mVal | _ -> Assert.Fail "Could not get valid AST" diff --git a/tests/service/TreeVisitorTests.fs b/tests/service/TreeVisitorTests.fs index f9a56bdd16c..9bcfa47796a 100644 --- a/tests/service/TreeVisitorTests.fs +++ b/tests/service/TreeVisitorTests.fs @@ -31,7 +31,7 @@ let ``Visit record definition test`` () = let parseTree = parseSourceCode("C:\\test.fs", source) match SyntaxTraversal.Traverse(pos0, parseTree, visitor) with - | Some [ SynField (_, _, Some id1, _, _, _, _, _); SynField (_, _, Some id2, _, _, _, _, _) ] when id1.idText = "A" && id2.idText = "B" -> () + | Some [ SynField (idOpt = Some id1); SynField (idOpt = Some id2) ] when id1.idText = "A" && id2.idText = "B" -> () | _ -> failwith "Did not visit record definition" [] From 5d69143fbe992d8fa33d5b83d5fdd5f4ed7bb4fc Mon Sep 17 00:00:00 2001 From: "Kevin Ransom (msft)" Date: Thu, 13 Oct 2022 09:43:32 -0700 Subject: [PATCH 7/8] update versions (#14099) --- eng/Versions.props | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/eng/Versions.props b/eng/Versions.props index 0054e122a6a..3670270fcc9 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -15,7 +15,7 @@ 6 0 - 6 + 7 0 @@ -32,14 +32,14 @@ 41 0 - 6 + 7 $(FSRevisionVersion) $(FCSMajorVersion).$(FCSMinorVersion).$(FCSBuildVersion) $(FCSMajorVersion).$(FCSMinorVersion).$(FCSBuildVersion).$(FCSRevisionVersion) $(FCSMajorVersion)$(FCSMinorVersion)$(FCSBuildVersion) - 6.0.3 + 6.0.6 $(FSCorePackageVersionValue)-$(PreReleaseVersionLabel).* @@ -47,7 +47,7 @@ 12 0 - 4 + 5 $(FSRevisionVersion) $(FSToolsMajorVersion).$(FSToolsMinorVersion).$(FSToolsBuildVersion) $(FSToolsMajorVersion)-$(FSToolsMinorVersion)-$(FSToolsBuildVersion) From 823f7d5c55245954f468f1b239a189c3b88af34b Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Fri, 14 Oct 2022 12:24:05 +0300 Subject: [PATCH 8/8] Use MSBuild's logging facilities instead of writing to console. (#13896) * Use MSBuild's logging facilities instead of writing to console. * Changing usage of WriteCodeFragment in tests * Applying cleaner formatting Co-authored-by: Tomas Grosup --- src/FSharp.Build/FSharpEmbedResXSource.fs | 44 +++---- src/FSharp.Build/FSharpEmbedResourceText.fs | 89 +++++++------ src/FSharp.Build/SubstituteText.fs | 118 ++++++++---------- src/FSharp.Build/WriteCodeFragment.fs | 113 ++++++++--------- .../WriteCodeFragmentTests.fs | 6 +- 5 files changed, 177 insertions(+), 193 deletions(-) diff --git a/src/FSharp.Build/FSharpEmbedResXSource.fs b/src/FSharp.Build/FSharpEmbedResXSource.fs index 4b34660b2a8..29a2ceefd19 100644 --- a/src/FSharp.Build/FSharpEmbedResXSource.fs +++ b/src/FSharp.Build/FSharpEmbedResXSource.fs @@ -10,14 +10,20 @@ open System.Xml.Linq open Microsoft.Build.Framework open Microsoft.Build.Utilities -type FSharpEmbedResXSource() = - let mutable _buildEngine: IBuildEngine MaybeNull = null - let mutable _hostObject: ITaskHost MaybeNull = null +type FSharpEmbedResXSource() as this = + inherit Task() let mutable _embeddedText: ITaskItem[] = [||] let mutable _generatedSource: ITaskItem[] = [||] let mutable _outputPath: string = "" let mutable _targetFramework: string = "" + let failTask fmt = + Printf.ksprintf + (fun msg -> + this.Log.LogError msg + raise TaskFailed) + fmt + let boilerplate = @"// @@ -36,7 +42,7 @@ module internal {1} = let generateSource (resx: string) (fullModuleName: string) (generateLegacy: bool) (generateLiteral: bool) = try - let printMessage = printfn "FSharpEmbedResXSource: %s" + let printMessage fmt = Printf.ksprintf this.Log.LogMessage fmt let justFileName = Path.GetFileNameWithoutExtension(resx) let sourcePath = Path.Combine(_outputPath, justFileName + ".fs") @@ -46,7 +52,7 @@ module internal {1} = && File.Exists(sourcePath) && File.GetLastWriteTimeUtc(resx) <= File.GetLastWriteTimeUtc(sourcePath) then - printMessage (sprintf "Skipping generation: '%s' since it is up-to-date." sourcePath) + printMessage "Skipping generation: '%s' since it is up-to-date." sourcePath Some(sourcePath) else let namespaceName, moduleName = @@ -63,7 +69,7 @@ module internal {1} = || _targetFramework.StartsWith("netcoreapp1.") ) - printMessage (sprintf "Generating code for target framework %s" _targetFramework) + printMessage "Generating code for target framework %s" _targetFramework let sb = StringBuilder() @@ -72,7 +78,7 @@ module internal {1} = if generateGetObject then sb.AppendLine(boilerplateGetObject) |> ignore - printMessage <| sprintf "Generating: %s" sourcePath + printMessage "Generating: %s" sourcePath let body = let xname = XName.op_Implicit @@ -82,12 +88,12 @@ module internal {1} = (fun (sb: StringBuilder) (node: XElement) -> let name = match node.Attribute(xname "name") with - | null -> failwith (sprintf "Missing resource name on element '%s'" (node.ToString())) + | null -> failTask "Missing resource name on element '%O'" node | attr -> attr.Value let docComment = match node.Elements(xname "value").FirstOrDefault() with - | null -> failwith <| sprintf "Missing resource value for '%s'" name + | null -> failTask "Missing resource value for '%s'" name | element -> element.Value.Trim() let identifier = @@ -118,7 +124,7 @@ module internal {1} = sb File.WriteAllText(sourcePath, body.ToString()) - printMessage <| sprintf "Done: %s" sourcePath + printMessage "Done: %s" sourcePath Some(sourcePath) with e -> printf "An exception occurred when processing '%s'\n%s" resx (e.ToString()) @@ -141,16 +147,8 @@ module internal {1} = [] member _.GeneratedSource = _generatedSource - interface ITask with - member _.BuildEngine - with get () = _buildEngine - and set (value) = _buildEngine <- value - - member _.HostObject - with get () = _hostObject - and set (value) = _hostObject <- value - - member this.Execute() = + override this.Execute() = + try let getBooleanMetadata (metadataName: string) (defaultValue: bool) (item: ITaskItem) = match item.GetMetadata(metadataName) with | value when String.IsNullOrWhiteSpace(value) -> defaultValue @@ -158,7 +156,7 @@ module internal {1} = match value.ToLowerInvariant() with | "true" -> true | "false" -> false - | _ -> failwith (sprintf "Expected boolean value for '%s' found '%s'" metadataName value) + | _ -> failTask "Expected boolean value for '%s' found '%s'" metadataName value let mutable success = true @@ -181,4 +179,6 @@ module internal {1} = |] _generatedSource <- generatedSource - success + success && not this.Log.HasLoggedErrors + with TaskFailed -> + false diff --git a/src/FSharp.Build/FSharpEmbedResourceText.fs b/src/FSharp.Build/FSharpEmbedResourceText.fs index d8a3848ba27..71dbc791a0c 100644 --- a/src/FSharp.Build/FSharpEmbedResourceText.fs +++ b/src/FSharp.Build/FSharpEmbedResourceText.fs @@ -6,24 +6,32 @@ open System.IO open Microsoft.Build.Framework open Microsoft.Build.Utilities -type FSharpEmbedResourceText() = - let mutable _buildEngine: IBuildEngine MaybeNull = null - let mutable _hostObject: ITaskHost MaybeNull = null +/// A special exception that when thrown signifies that +/// the task should end with failure. It is assumed that +/// the task has already emitted the error message. +exception TaskFailed + +type FSharpEmbedResourceText() as this = + inherit Task() let mutable _embeddedText: ITaskItem[] = [||] let mutable _generatedSource: ITaskItem[] = [||] let mutable _generatedResx: ITaskItem[] = [||] let mutable _outputPath: string = "" let PrintErr (fileName, line, msg) = - printfn "%s(%d): error : %s" fileName line msg + this.Log.LogError(null, null, null, fileName, line, 0, 0, 0, msg, Array.empty) let Err (fileName, line, msg) = PrintErr(fileName, line, msg) - printfn "Note that the syntax of each line is one of these three alternatives:" - printfn "# comment" - printfn "ident,\"string\"" - printfn "errNum,ident,\"string\"" - failwith (sprintf "there were errors in the file '%s'" fileName) + + let hint = + "Note that the syntax of each line is one of these three alternatives: +# comment +ident,\"string\" +errNum,ident,\"string\"" + + this.Log.LogMessage(MessageImportance.High, hint) + raise TaskFailed let xmlBoilerPlateString = @" @@ -192,7 +200,7 @@ type FSharpEmbedResourceText() = if s.StartsWith "\"" && s.EndsWith "\"" then s.Substring(1, s.Length - 2) else - failwith "error message string should be quoted" + Err(null, 0, "error message string should be quoted") let ParseLine fileName lineNum (txt: string) = let mutable errNum = None @@ -361,8 +369,7 @@ open Printf let generateResxAndSource (fileName: string) = try - let printMessage message = - printfn "FSharpEmbedResourceText: %s" message + let printMessage fmt = Printf.ksprintf this.Log.LogMessage fmt let justFileName = Path.GetFileNameWithoutExtension(fileName) // .txt @@ -391,35 +398,33 @@ open Printf && (File.GetLastWriteTimeUtc(fileName) <= File.GetLastWriteTimeUtc(outXmlFileName)) if condition5 then - printMessage (sprintf "Skipping generation of %s and %s from %s since up-to-date" outFileName outXmlFileName fileName) + printMessage "Skipping generation of %s and %s from %s since up-to-date" outFileName outXmlFileName fileName Some(fileName, outFileName, outXmlFileName) else - printMessage ( - sprintf - "Generating %s and %s from %s, because condition %d is false, see FSharpEmbedResourceText.fs in the F# source" - outFileName - outXmlFileName - fileName - (if not condition1 then 1 - elif not condition2 then 2 - elif not condition3 then 3 - elif not condition4 then 4 - else 5) - ) - - printMessage (sprintf "Reading %s" fileName) + printMessage + "Generating %s and %s from %s, because condition %d is false, see FSharpEmbedResourceText.fs in the F# source" + outFileName + outXmlFileName + fileName + (if not condition1 then 1 + elif not condition2 then 2 + elif not condition3 then 3 + elif not condition4 then 4 + else 5) + + printMessage "Reading %s" fileName let lines = File.ReadAllLines(fileName) |> Array.mapi (fun i s -> i, s) // keep line numbers |> Array.filter (fun (i, s) -> not (s.StartsWith "#")) // filter out comments - printMessage (sprintf "Parsing %s" fileName) + printMessage "Parsing %s" fileName let stringInfos = lines |> Array.map (fun (i, s) -> ParseLine fileName i s) // now we have array of (lineNum, ident, str, holes, netFormatString) // str has %d, netFormatString has {0} - printMessage (sprintf "Validating %s" fileName) + printMessage "Validating %s" fileName // validate that all the idents are unique let allIdents = new System.Collections.Generic.Dictionary() @@ -436,7 +441,7 @@ open Printf allIdents.Add(ident, line) - printMessage (sprintf "Validating uniqueness of %s" fileName) + printMessage "Validating uniqueness of %s" fileName // validate that all the strings themselves are unique let allStrs = new System.Collections.Generic.Dictionary() @@ -456,7 +461,7 @@ open Printf allStrs.Add(str, (line, ident)) - printMessage (sprintf "Generating %s" outFileName) + printMessage "Generating %s" outFileName use outStream = File.Create outFileName use out = new StreamWriter(outStream) fprintfn out "// This is a generated file; the original input is '%s'" fileName @@ -466,7 +471,7 @@ open Printf let theResourceName = justFileName fprintfn out "%s" (StringBoilerPlate theResourceName) - printMessage (sprintf "Generating resource methods for %s" outFileName) + printMessage "Generating resource methods for %s" outFileName // gen each resource method stringInfos |> Seq.iter (fun (lineNum, (optErrNum, ident), str, holes, netFormatString) -> @@ -520,7 +525,7 @@ open Printf justPercentsFromFormatString (actualArgs.ToString())) - printMessage (sprintf "Generating .resx for %s" outFileName) + printMessage "Generating .resx for %s" outFileName fprintfn out "" // gen validation method fprintfn out " /// Call this method once to validate that all known resources are valid; throws if not" @@ -548,7 +553,7 @@ open Printf use outXmlStream = File.Create outXmlFileName xd.Save outXmlStream - printMessage (sprintf "Done %s" outFileName) + printMessage "Done %s" outFileName Some(fileName, outFileName, outXmlFileName) with e -> PrintErr(fileName, 0, sprintf "An exception occurred when processing '%s'\n%s" fileName (e.ToString())) @@ -570,17 +575,9 @@ open Printf [] member _.GeneratedResx = _generatedResx - interface ITask with - member _.BuildEngine - with get () = _buildEngine - and set (value) = _buildEngine <- value - - member _.HostObject - with get () = _hostObject - and set (value) = _hostObject <- value - - member this.Execute() = + override this.Execute() = + try let generatedFiles = this.EmbeddedText |> Array.choose (fun item -> generateResxAndSource item.ItemSpec) @@ -609,4 +606,6 @@ open Printf _generatedSource <- generatedSource _generatedResx <- generatedResx - generatedResult + generatedResult && not this.Log.HasLoggedErrors + with TaskFailed -> + false diff --git a/src/FSharp.Build/SubstituteText.fs b/src/FSharp.Build/SubstituteText.fs index 0f036da0a86..2e4950a62b3 100644 --- a/src/FSharp.Build/SubstituteText.fs +++ b/src/FSharp.Build/SubstituteText.fs @@ -5,11 +5,10 @@ namespace FSharp.Build open System open System.IO open Microsoft.Build.Framework +open Microsoft.Build.Utilities type SubstituteText() = - - let mutable _buildEngine: IBuildEngine MaybeNull = null - let mutable _hostObject: ITaskHost MaybeNull = null + inherit Task() let mutable copiedFiles = new ResizeArray() let mutable embeddedResources: ITaskItem[] = [||] @@ -22,74 +21,65 @@ type SubstituteText() = [] member _.CopiedFiles = copiedFiles.ToArray() - interface ITask with - member _.BuildEngine - with get () = _buildEngine - and set (value) = _buildEngine <- value - - member _.HostObject - with get () = _hostObject - and set (value) = _hostObject <- value - - member _.Execute() = - copiedFiles.Clear() - - if not (isNull embeddedResources) then - for item in embeddedResources do - // Update ITaskItem metadata to point to new location - let sourcePath = item.GetMetadata("FullPath") - - let pattern1 = item.GetMetadata("Pattern1") - let pattern2 = item.GetMetadata("Pattern2") - - // Is there any replacement to do? - if not (String.IsNullOrWhiteSpace(pattern1) && String.IsNullOrWhiteSpace(pattern2)) then - if not (String.IsNullOrWhiteSpace(sourcePath)) then - try - let getTargetPathFrom key = - let md = item.GetMetadata(key) - let path = Path.GetDirectoryName(md) - let fileName = Path.GetFileName(md) - let target = Path.Combine(path, @"..\resources", fileName) + override _.Execute() = + copiedFiles.Clear() + + if not (isNull embeddedResources) then + for item in embeddedResources do + // Update ITaskItem metadata to point to new location + let sourcePath = item.GetMetadata("FullPath") + + let pattern1 = item.GetMetadata("Pattern1") + let pattern2 = item.GetMetadata("Pattern2") + + // Is there any replacement to do? + if not (String.IsNullOrWhiteSpace(pattern1) && String.IsNullOrWhiteSpace(pattern2)) then + if not (String.IsNullOrWhiteSpace(sourcePath)) then + try + let getTargetPathFrom key = + let md = item.GetMetadata(key) + let path = Path.GetDirectoryName(md) + let fileName = Path.GetFileName(md) + let target = Path.Combine(path, @"..\resources", fileName) + target + + // Copy from the location specified in Identity + let sourcePath = item.GetMetadata("Identity") + + // Copy to the location specified in TargetPath unless no TargetPath is provided, then use Identity + let targetPath = + let identityPath = getTargetPathFrom "Identity" + let intermediateTargetPath = item.GetMetadata("IntermediateTargetPath") + + if not (String.IsNullOrWhiteSpace(intermediateTargetPath)) then + let fileName = Path.GetFileName(identityPath) + let target = Path.Combine(intermediateTargetPath, fileName) target + else + identityPath - // Copy from the location specified in Identity - let sourcePath = item.GetMetadata("Identity") - - // Copy to the location specified in TargetPath unless no TargetPath is provided, then use Identity - let targetPath = - let identityPath = getTargetPathFrom "Identity" - let intermediateTargetPath = item.GetMetadata("IntermediateTargetPath") - - if not (String.IsNullOrWhiteSpace(intermediateTargetPath)) then - let fileName = Path.GetFileName(identityPath) - let target = Path.Combine(intermediateTargetPath, fileName) - target - else - identityPath - - item.ItemSpec <- targetPath + item.ItemSpec <- targetPath - // Transform file - let mutable contents = File.ReadAllText(sourcePath) + // Transform file + let mutable contents = File.ReadAllText(sourcePath) - if not (String.IsNullOrWhiteSpace(pattern1)) then - let replacement = item.GetMetadata("Replacement1") - contents <- contents.Replace(pattern1, replacement) + if not (String.IsNullOrWhiteSpace(pattern1)) then + let replacement = item.GetMetadata("Replacement1") + contents <- contents.Replace(pattern1, replacement) - if not (String.IsNullOrWhiteSpace(pattern2)) then - let replacement = item.GetMetadata("Replacement2") - contents <- contents.Replace(pattern2, replacement) + if not (String.IsNullOrWhiteSpace(pattern2)) then + let replacement = item.GetMetadata("Replacement2") + contents <- contents.Replace(pattern2, replacement) - let directory = Path.GetDirectoryName(targetPath) + let directory = Path.GetDirectoryName(targetPath) - if not (Directory.Exists(directory)) then - Directory.CreateDirectory(directory) |> ignore + if not (Directory.Exists(directory)) then + Directory.CreateDirectory(directory) |> ignore - File.WriteAllText(targetPath, contents) - with _ -> - () + File.WriteAllText(targetPath, contents) + with _ -> + () - copiedFiles.Add(item) + copiedFiles.Add(item) - true + true diff --git a/src/FSharp.Build/WriteCodeFragment.fs b/src/FSharp.Build/WriteCodeFragment.fs index ab390ae4a59..7df19fad327 100644 --- a/src/FSharp.Build/WriteCodeFragment.fs +++ b/src/FSharp.Build/WriteCodeFragment.fs @@ -9,14 +9,20 @@ open System.Text open Microsoft.Build.Framework open Microsoft.Build.Utilities -type WriteCodeFragment() = - let mutable _buildEngine: IBuildEngine MaybeNull = null - let mutable _hostObject: ITaskHost MaybeNull = null +type WriteCodeFragment() as this = + inherit Task() let mutable _outputDirectory: ITaskItem MaybeNull = null let mutable _outputFile: ITaskItem MaybeNull = null let mutable _language: string = "" let mutable _assemblyAttributes: ITaskItem[] = [||] + let failTask fmt = + Printf.ksprintf + (fun msg -> + this.Log.LogError msg + raise TaskFailed) + fmt + static let escapeString (str: string) = let sb = str.ToCharArray() @@ -37,7 +43,7 @@ type WriteCodeFragment() = sb.Append("\"").ToString() - static member GenerateAttribute(item: ITaskItem, language: string) = + member _.GenerateAttribute(item: ITaskItem, language: string) = let attributeName = item.ItemSpec let args = @@ -70,7 +76,7 @@ type WriteCodeFragment() = match Int32.TryParse indexString with | (true, index) -> (index, value) - | (false, _) -> failwith (sprintf "Unable to parse '%s' as an index" indexString)) + | (false, _) -> failTask "Unable to parse '%s' as an index" indexString) |> List.sortBy fst // assign ordered parameters to array let orderedParametersArray = @@ -96,7 +102,7 @@ type WriteCodeFragment() = | "f#" -> sprintf "[]" attributeName args | "c#" -> sprintf "[assembly: %s(%s)]" attributeName args | "vb" -> sprintf "" attributeName args - | _ -> failwith "Language name must be one of F#, C# or VB" + | _ -> failTask "Language name must be one of F#, C# or VB" // adding this property to maintain API equivalence with the MSBuild task member _.Language @@ -116,56 +122,45 @@ type WriteCodeFragment() = with get () = _outputFile and set (value) = _outputFile <- value - interface ITask with - member _.BuildEngine - with get () = _buildEngine - and set (value) = _buildEngine <- value - - member _.HostObject - with get () = _hostObject - and set (value) = _hostObject <- value - - member _.Execute() = - try - match _outputFile with - | Null -> failwith "Output location must be specified" - | NonNull outputFile -> - let boilerplate = - match _language.ToLowerInvariant() with - | "f#" -> - "// \n// Generated by the FSharp WriteCodeFragment class.\n// \nnamespace FSharp\n\nopen System\nopen System.Reflection\n" - | "c#" -> - "// \n// Generated by the FSharp WriteCodeFragment class.\n// \n\nusing System;\nusing System.Reflection;" - | "vb" -> - "'------------------------------------------------------------------------------\n' \n' Generated by the FSharp WriteCodeFragment class.\n' \n'------------------------------------------------------------------------------\n\nOption Strict Off\nOption Explicit On\n\nImports System\nImports System.Reflection" - | _ -> failwith "Language name must be one of F#, C# or VB" - - let sb = StringBuilder().AppendLine(boilerplate).AppendLine() - - let code = - (sb, _assemblyAttributes) - ||> Array.fold (fun (sb: StringBuilder) (item: ITaskItem) -> - sb.AppendLine(WriteCodeFragment.GenerateAttribute(item, _language.ToLowerInvariant()))) - - if _language.ToLowerInvariant() = "f#" then - code.AppendLine("do()") |> ignore - - let fileName = outputFile.ItemSpec - - let outputFileItem = - match _outputDirectory with - | Null -> outputFile - | NonNull outputDirectory -> - if Path.IsPathRooted(fileName) then - outputFile - else - TaskItem(Path.Combine(outputDirectory.ItemSpec, fileName)) :> ITaskItem - - let codeText = code.ToString() - File.WriteAllText(fileName, codeText) - _outputFile <- outputFileItem - true - - with e -> - printf "Error writing code fragment: %s" (e.ToString()) - false + override this.Execute() = + try + match _outputFile with + | Null -> failTask "Output location must be specified" + | NonNull outputFile -> + let boilerplate = + match _language.ToLowerInvariant() with + | "f#" -> + "// \n// Generated by the FSharp WriteCodeFragment class.\n// \nnamespace FSharp\n\nopen System\nopen System.Reflection\n" + | "c#" -> + "// \n// Generated by the FSharp WriteCodeFragment class.\n// \n\nusing System;\nusing System.Reflection;" + | "vb" -> + "'------------------------------------------------------------------------------\n' \n' Generated by the FSharp WriteCodeFragment class.\n' \n'------------------------------------------------------------------------------\n\nOption Strict Off\nOption Explicit On\n\nImports System\nImports System.Reflection" + | _ -> failTask "Language name must be one of F#, C# or VB" + + let sb = StringBuilder().AppendLine(boilerplate).AppendLine() + + let code = + (sb, _assemblyAttributes) + ||> Array.fold (fun (sb: StringBuilder) (item: ITaskItem) -> + sb.AppendLine(this.GenerateAttribute(item, _language.ToLowerInvariant()))) + + if _language.ToLowerInvariant() = "f#" then + code.AppendLine("do()") |> ignore + + let fileName = outputFile.ItemSpec + + let outputFileItem = + match _outputDirectory with + | Null -> outputFile + | NonNull outputDirectory -> + if Path.IsPathRooted(fileName) then + outputFile + else + TaskItem(Path.Combine(outputDirectory.ItemSpec, fileName)) :> ITaskItem + + let codeText = code.ToString() + File.WriteAllText(fileName, codeText) + _outputFile <- outputFileItem + not this.Log.HasLoggedErrors + with TaskFailed -> + false diff --git a/tests/FSharp.Build.UnitTests/WriteCodeFragmentTests.fs b/tests/FSharp.Build.UnitTests/WriteCodeFragmentTests.fs index d295f60f4ee..49ad920c449 100644 --- a/tests/FSharp.Build.UnitTests/WriteCodeFragmentTests.fs +++ b/tests/FSharp.Build.UnitTests/WriteCodeFragmentTests.fs @@ -13,7 +13,7 @@ type WriteCodeFragmentFSharpTests() = let verifyAttribute (attributeName:string) (parameters:(string*string) list) (expectedAttributeText:string) = let taskItem = TaskItem(attributeName) parameters |> List.iter (fun (key, value) -> taskItem.SetMetadata(key, value)) - let actualAttributeText = WriteCodeFragment.GenerateAttribute (taskItem :> ITaskItem, "f#") + let actualAttributeText = (new WriteCodeFragment()).GenerateAttribute (taskItem :> ITaskItem, "f#") let fullExpectedAttributeText = "[]" Assert.AreEqual(fullExpectedAttributeText, actualAttributeText) @@ -43,7 +43,7 @@ type WriteCodeFragmentCSharpTests() = let verifyAttribute (attributeName:string) (parameters:(string*string) list) (expectedAttributeText:string) = let taskItem = TaskItem(attributeName) parameters |> List.iter (fun (key, value) -> taskItem.SetMetadata(key, value)) - let actualAttributeText = WriteCodeFragment.GenerateAttribute (taskItem :> ITaskItem, "c#") + let actualAttributeText = (new WriteCodeFragment()).GenerateAttribute (taskItem :> ITaskItem, "c#") let fullExpectedAttributeText = "[assembly: " + expectedAttributeText + "]" Assert.AreEqual(fullExpectedAttributeText, actualAttributeText) @@ -75,7 +75,7 @@ type WriteCodeFragmentVisualBasicTests() = let verifyAttribute (attributeName:string) (parameters:(string*string) list) (expectedAttributeText:string) = let taskItem = TaskItem(attributeName) parameters |> List.iter (fun (key, value) -> taskItem.SetMetadata(key, value)) - let actualAttributeText = WriteCodeFragment.GenerateAttribute (taskItem :> ITaskItem, "vb") + let actualAttributeText = (new WriteCodeFragment()).GenerateAttribute (taskItem :> ITaskItem, "vb") let fullExpectedAttributeText = "" Assert.AreEqual(fullExpectedAttributeText, actualAttributeText)