From 35e534736eab52f3f35995c903de2bf90d333cc6 Mon Sep 17 00:00:00 2001 From: "Kevin Ransom (msft)" Date: Thu, 7 Mar 2024 00:36:51 -0800 Subject: [PATCH 01/14] EnableDefaultCompileItems (#16817) --- src/FSharp.Build/Microsoft.FSharp.NetSdk.props | 1 - vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FSharp.Build/Microsoft.FSharp.NetSdk.props b/src/FSharp.Build/Microsoft.FSharp.NetSdk.props index a3c9ee3e2da..8cc3ba76eb9 100644 --- a/src/FSharp.Build/Microsoft.FSharp.NetSdk.props +++ b/src/FSharp.Build/Microsoft.FSharp.NetSdk.props @@ -31,7 +31,6 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and false - false diff --git a/vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj b/vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj index 5510d3dcb9c..56f95a12ba0 100644 --- a/vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj +++ b/vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj @@ -10,6 +10,7 @@ true true true + false false nunit true From efa553729582c1d15cea51ed9f8894c0837ecadd Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Thu, 7 Mar 2024 12:39:28 +0100 Subject: [PATCH 02/14] Create repository_lockdown_check.yml --- .../workflows/repository_lockdown_check.yml | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .github/workflows/repository_lockdown_check.yml diff --git a/.github/workflows/repository_lockdown_check.yml b/.github/workflows/repository_lockdown_check.yml new file mode 100644 index 00000000000..95671a1a338 --- /dev/null +++ b/.github/workflows/repository_lockdown_check.yml @@ -0,0 +1,78 @@ +name: Repository lockdown check +on: + pull_request_target: + types: [opened, synchronize, reopened] + branches: + - 'main' + - 'release/*' +permissions: + issues: write + pull-requests: write +jobs: + repository_lockdown: + permissions: + issues: write + pull-requests: write + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + runs-on: ubuntu-latest + steps: + - name: Check if lockdown is in place + run: | + set -e + if [[ ${{ vars.LOCKDOWN }} == "true" ]]; then + exit 1 + fi + # Did bot already comment the PR? + - name: Find Comment + if: (success() || failure()) + uses: peter-evans/find-comment@v2.4.0 + id: fc + with: + issue-number: ${{github.event.pull_request.number}} + comment-author: 'github-actions[bot]' + body-includes: '' + # If not, create a new comment + - name: Create comment + if: steps.fc.outputs.comment-id == '' && failure() + uses: actions/github-script@v6 + with: + github-token: ${{ github.token }} + script: | + let body = "\n\n> [!CAUTION]\n>Repository is on lockdown for maintenance, all merges are on hold." + const comment = await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: body + }); + return comment.data.id; + # If yes, update the comment + - name: Update comment + if: steps.fc.outputs.comment-id != '' && failure() + uses: actions/github-script@v6 + with: + github-token: ${{ github.token }} + script: | + let body = "\n\n> [!CAUTION]\n>Repository is on lockdown for maintenance, all merges are on hold." + const comment = await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: ${{steps.fc.outputs.comment-id}}, + body: body + }); + return comment.data.id; + # If comment exists, but we are no longer in maintenance mode, delete the comment. + - name: Delete comment + if: steps.fc.outputs.comment-id != '' && success() + uses: actions/github-script@v6 + with: + github-token: ${{ github.token }} + script: | + let body = "\n\n> [!CAUTION]\n>Repository is on lockdown for maintenance, all merges are on hold." + const comment = await github.rest.issues.deleteComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: ${{steps.fc.outputs.comment-id}} + }); + return 0; From c4f7bed26a7ca45beef43f5550a4a3d6560ca31e Mon Sep 17 00:00:00 2001 From: ijklam <43789618+Tangent-90@users.noreply.github.com> Date: Thu, 7 Mar 2024 20:46:48 +0800 Subject: [PATCH 03/14] Allow access modifiers to auto properties getters and setters (#16687) * Allow access modifies to auto properties * move types * update release note * Put it under preview flag * add and update baseline * move checks leave parser * update ServiceNavigation; fantomas * add tests * fix tests * fix tests * fix tests * fix tests * fix * fix * fix * fix * add spaces * fix grammar --------- Co-authored-by: Vlad Zarytovskii --- .../.FSharp.Compiler.Service/8.0.300.md | 1 + docs/release-notes/.Language/preview.md | 1 + src/Compiler/Checking/CheckDeclarations.fs | 52 ++++- src/Compiler/FSComp.txt | 4 +- src/Compiler/Facilities/LanguageFeatures.fs | 4 + src/Compiler/Facilities/LanguageFeatures.fsi | 1 + src/Compiler/Service/ServiceNavigation.fs | 14 +- src/Compiler/SyntaxTree/ParseHelpers.fs | 4 +- src/Compiler/SyntaxTree/ParseHelpers.fsi | 2 +- src/Compiler/SyntaxTree/SyntaxTree.fs | 2 + src/Compiler/SyntaxTree/SyntaxTree.fsi | 2 + src/Compiler/pars.fsy | 52 ++--- src/Compiler/xlf/FSComp.txt.cs.xlf | 10 + src/Compiler/xlf/FSComp.txt.de.xlf | 10 + src/Compiler/xlf/FSComp.txt.es.xlf | 10 + src/Compiler/xlf/FSComp.txt.fr.xlf | 10 + src/Compiler/xlf/FSComp.txt.it.xlf | 10 + src/Compiler/xlf/FSComp.txt.ja.xlf | 10 + src/Compiler/xlf/FSComp.txt.ko.xlf | 10 + src/Compiler/xlf/FSComp.txt.pl.xlf | 10 + src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 10 + src/Compiler/xlf/FSComp.txt.ru.xlf | 10 + src/Compiler/xlf/FSComp.txt.tr.xlf | 10 + src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 10 + src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 10 + .../AutoPropsWithModifierBeforeGetSet.fs | 177 ++++++++++++++++++ .../FSharp.Compiler.ComponentTests.fsproj | 1 + ...vice.SurfaceArea.netstandard20.release.bsl | 6 +- .../LeadingKeyword/DefaultValKeyword.fs.bsl | 3 +- .../LeadingKeyword/MemberValKeyword.fs.bsl | 3 +- .../LeadingKeyword/OverrideValKeyword.fs.bsl | 3 +- .../StaticMemberValKeyword.fs.bsl | 3 +- .../SyntaxTree/Member/Auto property 01.fs.bsl | 3 +- .../SyntaxTree/Member/Auto property 02.fs.bsl | 2 +- .../SyntaxTree/Member/Auto property 03.fs.bsl | 5 +- .../SyntaxTree/Member/Auto property 04.fs.bsl | 6 +- .../SyntaxTree/Member/Auto property 05.fs.bsl | 6 +- .../SyntaxTree/Member/Auto property 06.fs.bsl | 3 +- .../SyntaxTree/Member/Auto property 07.fs.bsl | 3 +- .../SyntaxTree/Member/Auto property 08.fs.bsl | 5 +- .../SyntaxTree/Member/Auto property 09.fs.bsl | 5 +- .../SyntaxTree/Member/Auto property 10.fs.bsl | 5 +- .../SyntaxTree/Member/Auto property 11.fs.bsl | 3 +- .../SyntaxTree/Member/Auto property 12.fs.bsl | 3 +- .../SyntaxTree/Member/Auto property 13.fs.bsl | 3 +- .../SyntaxTree/Member/Auto property 14.fs | 4 + .../SyntaxTree/Member/Auto property 14.fs.bsl | 56 ++++++ .../SyntaxTree/Member/Auto property 15.fs | 4 + .../SyntaxTree/Member/Auto property 15.fs.bsl | 56 ++++++ ...ertyContainsTheRangeOfTheEqualsSign.fs.bsl | 2 +- ...rtyContainsTheRangeOfTheWithKeyword.fs.bsl | 4 +- ...erDefnAutoPropertyHasCorrectKeyword.fs.bsl | 12 +- 52 files changed, 588 insertions(+), 67 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/MemberDefinitions/MethodsAndProperties/AutoPropsWithModifierBeforeGetSet.fs create mode 100644 tests/service/data/SyntaxTree/Member/Auto property 14.fs create mode 100644 tests/service/data/SyntaxTree/Member/Auto property 14.fs.bsl create mode 100644 tests/service/data/SyntaxTree/Member/Auto property 15.fs create mode 100644 tests/service/data/SyntaxTree/Member/Auto property 15.fs.bsl diff --git a/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md b/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md index 148f3734185..2473966f72a 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md +++ b/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md @@ -26,6 +26,7 @@ * Add switch to generate types and members with IL visibility that accurately represents their F# visibility. ([PR #15484](https://github.com/dotnet/fsharp/pull/15484) * Allow returning bool instead of unit option for partial active patterns. ([Language suggestion #1041](https://github.com/fsharp/fslang-suggestions/issues/1041), [PR #16473](https://github.com/dotnet/fsharp/pull/16473)) * Symbols: Add GenericArguments to FSharpEntity ([PR #16470](https://github.com/dotnet/fsharp/pull/16470)) +* Allow access modifies to auto properties getters and setters ([PR 16687](https://github.com/dotnet/fsharp/pull/16687), [Language suggestion #430](https://github.com/fsharp/fslang-suggestions/issues/430)) ### Changed diff --git a/docs/release-notes/.Language/preview.md b/docs/release-notes/.Language/preview.md index eb7ddd08e54..0e34b389ef0 100644 --- a/docs/release-notes/.Language/preview.md +++ b/docs/release-notes/.Language/preview.md @@ -5,6 +5,7 @@ * Bidirectional F#/C# interop for 'unmanaged' constraint. ([PR #12154](https://github.com/dotnet/fsharp/pull/12154)) * Make `.Is*` discriminated union properties visible. ([Language suggestion #222](https://github.com/fsharp/fslang-suggestions/issues/222), [PR #16341](https://github.com/dotnet/fsharp/pull/16341)) * Allow returning bool instead of unit option for partial active patterns. ([Language suggestion #1041](https://github.com/fsharp/fslang-suggestions/issues/1041), [PR #16473](https://github.com/dotnet/fsharp/pull/16473)) +* Allow access modifies to auto properties getters and setters ([PR 16687](https://github.com/dotnet/fsharp/pull/16687), [Language suggestion #430](https://github.com/fsharp/fslang-suggestions/issues/430)) ### Fixed diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index 457a3489576..f02ccdff9a4 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -4309,7 +4309,7 @@ module TcDeclarations = | _ -> () /// Split auto-properties into 'let' and 'member' bindings - let private SplitAutoProps members = + let private SplitAutoProps (g: TcGlobals) members = let membersIncludingAutoProps, vals_Inherits_Abstractslots = members |> List.partition (fun memb -> match memb with @@ -4359,7 +4359,7 @@ module TcDeclarations = let rec postAutoProps memb = match memb with | SynMemberDefn.AutoProperty(ident = id) when String.IsNullOrEmpty(id.idText) -> [] - | SynMemberDefn.AutoProperty(attributes=Attributes attribs; isStatic=isStatic; ident=id; typeOpt=tyOpt; propKind=propKind; memberFlags=memberFlags; memberFlagsForSet=memberFlagsForSet; xmlDoc=xmlDoc; accessibility=access; trivia = { GetSetKeywords = mGetSetOpt }) -> + | SynMemberDefn.AutoProperty(attributes=Attributes attribs; isStatic=isStatic; ident=id; typeOpt=tyOpt; propKind=propKind; memberFlags=memberFlags; memberFlagsForSet=memberFlagsForSet; xmlDoc=xmlDoc; trivia = { GetSetKeywords = mGetSetOpt }; accessibility = access; getterAccessibility = getterAccess; setterAccessibility = setterAccess) -> 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) @@ -4372,7 +4372,41 @@ module TcDeclarations = match propKind, mGetSetOpt with | SynMemberKind.PropertySet, Some getSetKeywords -> errorR(Error(FSComp.SR.parsMutableOnAutoPropertyShouldBeGetSetNotJustSet(), getSetKeywords.Range)) | _ -> () - + + let getterAccess, setterAccess = + match propKind with + | SynMemberKind.PropertyGetSet -> + match access with + | Some _ -> + match getterAccess, setterAccess with + | None, None -> access, access + | Some x, _ + | _, Some x -> + errorR(Error(FSComp.SR.parsMultipleAccessibilitiesForGetSet(), x.Range)) + None, None + | None -> + match getterAccess, setterAccess with + | Some x, _ + | _, Some x -> + checkLanguageFeatureAndRecover g.langVersion LanguageFeature.AllowAccessModifiersToAutoPropertiesGettersAndSetters x.Range + getterAccess, setterAccess + | _, _ -> None, None + | SynMemberKind.PropertySet -> + match access, setterAccess with + | Some _, Some x -> + errorR(Error(FSComp.SR.parsMultipleAccessibilitiesForGetSet(), x.Range)) + None, None + | _, None -> None, access + | None, _ -> None, setterAccess + | SynMemberKind.Member + | SynMemberKind.PropertyGet + | _ -> + match access, getterAccess with + | Some _, Some x -> + errorR(Error(FSComp.SR.parsMultipleAccessibilitiesForGetSet(), x.Range)) + None, None + | _, None -> access, None + | None, _ -> getterAccess, None [ match propKind with | SynMemberKind.Member @@ -4382,7 +4416,7 @@ module TcDeclarations = let rhsExpr = SynExpr.Ident fldId let retInfo = match tyOpt with None -> None | Some ty -> Some (None, SynReturnInfo((ty, SynInfo.unnamedRetVal), ty.Range)) let attribs = mkAttributeList attribs mMemberPortion - let binding = mkSynBinding (xmlDoc, headPat) (access, false, false, mMemberPortion, DebugPointAtBinding.NoneAtInvisible, retInfo, rhsExpr, rhsExpr.Range, [], attribs, Some memberFlags, SynBindingTrivia.Zero) + let binding = mkSynBinding (xmlDoc, headPat) (getterAccess, false, false, mMemberPortion, DebugPointAtBinding.NoneAtInvisible, retInfo, rhsExpr, rhsExpr.Range, [], attribs, Some memberFlags, SynBindingTrivia.Zero) SynMemberDefn.Member (binding, mMemberPortion) yield getter | _ -> () @@ -4394,7 +4428,7 @@ module TcDeclarations = let vId = ident("v", mMemberPortion) let headPat = SynPat.LongIdent (SynLongIdent(headPatIds, [], List.replicate headPatIds.Length None), None, Some noInferredTypars, SynArgPats.Pats [mkSynPatVar None vId], None, mMemberPortion) let rhsExpr = mkSynAssign (SynExpr.Ident fldId) (SynExpr.Ident vId) - let binding = mkSynBinding (xmlDoc, headPat) (access, false, false, mMemberPortion, DebugPointAtBinding.NoneAtInvisible, None, rhsExpr, rhsExpr.Range, [], [], Some memberFlagsForSet, SynBindingTrivia.Zero) + let binding = mkSynBinding (xmlDoc, headPat) (setterAccess, false, false, mMemberPortion, DebugPointAtBinding.NoneAtInvisible, None, rhsExpr, rhsExpr.Range, [], [], Some memberFlagsForSet, SynBindingTrivia.Zero) SynMemberDefn.Member (binding, mMemberPortion) yield setter | _ -> ()] @@ -4418,9 +4452,9 @@ module TcDeclarations = /// where simpleRepr can contain inherit type, declared fields and virtual slots. /// body = members /// where members contain methods/overrides, also implicit ctor, inheritCall and local definitions. - let rec private SplitTyconDefn (SynTypeDefn(typeInfo=synTyconInfo;typeRepr=trepr; members=extraMembers)) = + let rec private SplitTyconDefn g (SynTypeDefn(typeInfo=synTyconInfo;typeRepr=trepr; members=extraMembers)) = let extraMembers = desugarGetSetMembers extraMembers - let extraMembers, extra_vals_Inherits_Abstractslots = SplitAutoProps extraMembers + let extraMembers, extra_vals_Inherits_Abstractslots = SplitAutoProps g extraMembers let implements1 = extraMembers |> List.choose (function SynMemberDefn.Interface (interfaceType=ty) -> Some(ty, ty.Range) | _ -> None) match trepr with @@ -4441,7 +4475,7 @@ module TcDeclarations = let slotsigs = members |> List.choose (function SynMemberDefn.AbstractSlot (slotSig = x; flags = y) -> Some(x, y) | _ -> None) - let members,_vals_Inherits_Abstractslots = SplitAutoProps members + let members,_vals_Inherits_Abstractslots = SplitAutoProps g members let isConcrete = members |> List.exists (function @@ -4503,7 +4537,7 @@ module TcDeclarations = // Split the definitions into "core representations" and "members". The code to process core representations // is shared between processing of signature files and implementation files. - let mutRecDefnsAfterSplit = mutRecDefns |> MutRecShapes.mapTycons SplitTyconDefn + let mutRecDefnsAfterSplit = mutRecDefns |> MutRecShapes.mapTycons (fun i -> SplitTyconDefn g i) // Create the entities for each module and type definition, and process the core representation of each type definition. let tycons, envMutRecPrelim, mutRecDefnsAfterCore = diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 5846712049b..61e280428b2 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1746,4 +1746,6 @@ featureReuseSameFieldsInStructUnions,"Share underlying fields in a [] di 3862,parsStaticMemberImcompleteSyntax,"Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration." 3863,parsExpectingField,"Expecting record field" 3864,tooManyMethodsInDotNetTypeWritingAssembly,"The type '%s' has too many methods. Found: '%d', maximum: '%d'" -3865,parsOnlySimplePatternsAreAllowedInConstructors,"Only simple patterns are allowed in primary constructors" \ No newline at end of file +3865,parsOnlySimplePatternsAreAllowedInConstructors,"Only simple patterns are allowed in primary constructors" +featureAllowAccessModifiersToAutoPropertiesGettersAndSetters,"Allow access modifiers to auto properties getters and setters" +3866,parsAccessModifiersBeforeGettersAndSettersNotAllowedInSigFile,"The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file." \ No newline at end of file diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index 3103d8b159e..f18f41d7e56 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -85,6 +85,7 @@ type LanguageFeature = | WarningIndexedPropertiesGetSetSameType | WarningWhenTailCallAttrOnNonRec | BooleanReturningAndReturnTypeDirectedPartialActivePattern + | AllowAccessModifiersToAutoPropertiesGettersAndSetters | EnforceAttributeTargetsOnFunctions | EnforceAttributeTargetsUnionCaseDeclarations | LowerInterpolatedStringToConcat @@ -201,6 +202,7 @@ type LanguageVersion(versionText) = LanguageFeature.WarningWhenTailCallAttrOnNonRec, previewVersion LanguageFeature.UnionIsPropertiesVisible, previewVersion LanguageFeature.BooleanReturningAndReturnTypeDirectedPartialActivePattern, previewVersion + LanguageFeature.AllowAccessModifiersToAutoPropertiesGettersAndSetters, previewVersion LanguageFeature.EnforceAttributeTargetsOnFunctions, previewVersion LanguageFeature.EnforceAttributeTargetsUnionCaseDeclarations, previewVersion LanguageFeature.LowerInterpolatedStringToConcat, previewVersion @@ -348,6 +350,8 @@ type LanguageVersion(versionText) = | LanguageFeature.WarningWhenTailCallAttrOnNonRec -> FSComp.SR.featureChkTailCallAttrOnNonRec () | LanguageFeature.BooleanReturningAndReturnTypeDirectedPartialActivePattern -> FSComp.SR.featureBooleanReturningAndReturnTypeDirectedPartialActivePattern () + | LanguageFeature.AllowAccessModifiersToAutoPropertiesGettersAndSetters -> + FSComp.SR.featureAllowAccessModifiersToAutoPropertiesGettersAndSetters () | LanguageFeature.EnforceAttributeTargetsOnFunctions -> FSComp.SR.featureEnforceAttributeTargetsOnFunctions () | LanguageFeature.EnforceAttributeTargetsUnionCaseDeclarations -> FSComp.SR.featureEnforceAttributeTargetsUnionCaseDeclarations () | LanguageFeature.LowerInterpolatedStringToConcat -> FSComp.SR.featureLowerInterpolatedStringToConcat () diff --git a/src/Compiler/Facilities/LanguageFeatures.fsi b/src/Compiler/Facilities/LanguageFeatures.fsi index 4f0fe835ffa..84913760e68 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fsi +++ b/src/Compiler/Facilities/LanguageFeatures.fsi @@ -76,6 +76,7 @@ type LanguageFeature = | WarningIndexedPropertiesGetSetSameType | WarningWhenTailCallAttrOnNonRec | BooleanReturningAndReturnTypeDirectedPartialActivePattern + | AllowAccessModifiersToAutoPropertiesGettersAndSetters | EnforceAttributeTargetsOnFunctions | EnforceAttributeTargetsUnionCaseDeclarations | LowerInterpolatedStringToConcat diff --git a/src/Compiler/Service/ServiceNavigation.fs b/src/Compiler/Service/ServiceNavigation.fs index 03afe63b373..bb118ae2c76 100755 --- a/src/Compiler/Service/ServiceNavigation.fs +++ b/src/Compiler/Service/ServiceNavigation.fs @@ -332,9 +332,19 @@ module NavigationImpl = [ createMember (rcid, NavigationItemKind.Field, FSharpGlyph.Field, range, enclosingEntityKind, false, access) ] - | SynMemberDefn.AutoProperty(ident = id; accessibility = access) -> + | SynMemberDefn.AutoProperty( + ident = id; accessibility = access; getterAccessibility = getterAccessibility; setterAccessibility = setterAccessibility; propKind = propKind) -> + let getterAccessibility = getterAccessibility |> Option.orElse access + let setterAccessibility = setterAccessibility |> Option.orElse access + [ - createMember (id, NavigationItemKind.Field, FSharpGlyph.Field, id.idRange, enclosingEntityKind, false, access) + match propKind with + | SynMemberKind.PropertyGetSet -> + yield createMember (id, NavigationItemKind.Field, FSharpGlyph.Field, id.idRange, enclosingEntityKind, false, getterAccessibility) + yield createMember (id, NavigationItemKind.Field, FSharpGlyph.Field, id.idRange, enclosingEntityKind, false, setterAccessibility) + | SynMemberKind.PropertySet -> + yield createMember (id, NavigationItemKind.Field, FSharpGlyph.Field, id.idRange, enclosingEntityKind, false, setterAccessibility) + | _ -> yield createMember (id, NavigationItemKind.Field, FSharpGlyph.Field, id.idRange, enclosingEntityKind, false, getterAccessibility) ] | SynMemberDefn.AbstractSlot(slotSig = SynValSig(ident = SynIdent(id, _); synType = ty; accessibility = access)) -> [ diff --git a/src/Compiler/SyntaxTree/ParseHelpers.fs b/src/Compiler/SyntaxTree/ParseHelpers.fs index d90e395c0c9..b1d44984aaa 100644 --- a/src/Compiler/SyntaxTree/ParseHelpers.fs +++ b/src/Compiler/SyntaxTree/ParseHelpers.fs @@ -1101,7 +1101,7 @@ let mkSynUnionCase attributes (access: SynAccess option) id kind mDecl (xmlDoc, SynUnionCase(attributes, id, kind, xmlDoc, None, mDecl, trivia) let mkAutoPropDefn mVal access ident typ mEquals (expr: SynExpr) accessors xmlDoc attribs flags rangeStart = - let mWith, (getSet, getSetOpt) = accessors + let mWith, (getSet, getSetOpt, getterAccess, setterAccess) = accessors let memberRange = match getSetOpt with @@ -1135,6 +1135,8 @@ let mkAutoPropDefn mVal access ident typ mEquals (expr: SynExpr) accessors xmlDo memberFlagsForSet, xmlDoc, access, + getterAccess, + setterAccess, expr, memberRange, trivia diff --git a/src/Compiler/SyntaxTree/ParseHelpers.fsi b/src/Compiler/SyntaxTree/ParseHelpers.fsi index a8d61f3cb7e..52f4257d4c2 100644 --- a/src/Compiler/SyntaxTree/ParseHelpers.fsi +++ b/src/Compiler/SyntaxTree/ParseHelpers.fsi @@ -272,7 +272,7 @@ val mkAutoPropDefn: typ: SynType option -> mEquals: range option -> expr: SynExpr -> - accessors: range option * (SynMemberKind * GetSetKeywords option) -> + accessors: range option * (SynMemberKind * GetSetKeywords option * SynAccess option * SynAccess option) -> xmlDoc: PreXmlDoc -> attribs: SynAttributes -> flags: (SynMemberKind -> SynMemberFlags) * SynLeadingKeyword -> diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fs b/src/Compiler/SyntaxTree/SyntaxTree.fs index 8b034740be4..a4ba8c601f4 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fs +++ b/src/Compiler/SyntaxTree/SyntaxTree.fs @@ -1463,6 +1463,8 @@ type SynMemberDefn = memberFlagsForSet: SynMemberFlags * xmlDoc: PreXmlDoc * accessibility: SynAccess option * + getterAccessibility: SynAccess option * + setterAccessibility: SynAccess option * synExpr: SynExpr * range: range * trivia: SynMemberDefnAutoPropertyTrivia diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fsi b/src/Compiler/SyntaxTree/SyntaxTree.fsi index 3d9ef06dcad..2f1d1d5776c 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTree.fsi @@ -1656,6 +1656,8 @@ type SynMemberDefn = memberFlagsForSet: SynMemberFlags * xmlDoc: PreXmlDoc * accessibility: SynAccess option * + getterAccessibility: SynAccess option * + setterAccessibility: SynAccess option * synExpr: SynExpr * range: range * trivia: SynMemberDefnAutoPropertyTrivia diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index 4080fc7ec8b..b8871f5a270 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -949,7 +949,14 @@ classMemberSpfn: | opt_attributes opt_access memberSpecFlags opt_inline opt_access nameop opt_explicitValTyparDecls COLON topTypeWithTypeConstraints classMemberSpfnGetSet optLiteralValueSpfn { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(), rhs parseState 2)) let isInline, doc, vis2, id, explicitValTyparDecls, (ty, arity), (mEquals, optLiteralValue) = (Option.isSome $4), grabXmlDoc(parseState, $1, 1), $5, $6, $7, $9, $11 - let mWith, (getSet, getSetRangeOpt) = $10 + let mWith, (getSet, getSetRangeOpt, getterAccess, setterAccess) = $10 + match getterAccess with + | Some(x: SynAccess) -> warning(Error(FSComp.SR.parsAccessModifiersBeforeGettersAndSettersNotAllowedInSigFile(), x.Range)) + | _ -> () + match setterAccess with + | Some(x: SynAccess) -> warning(Error(FSComp.SR.parsAccessModifiersBeforeGettersAndSettersNotAllowedInSigFile(), x.Range)) + | _ -> () + let getSetAdjuster arity = match arity, getSet with SynValInfo([], _), SynMemberKind.Member -> SynMemberKind.PropertyGet | _ -> getSet let mWhole = let m = rhs parseState 3 @@ -1021,7 +1028,7 @@ classMemberSpfn: /* The optional "with get, set" on a member in a signature */ classMemberSpfnGetSet: | /* EMPTY */ - { None, (SynMemberKind.Member, None) } + { None, (SynMemberKind.Member, None, None, None) } | WITH classMemberSpfnGetSetElements { let mWith = rhs parseState 1 @@ -1039,39 +1046,39 @@ classMemberSpfnGetSet: /* The "get, set" on a property member in a signature */ classMemberSpfnGetSetElements: - | nameop - { (let (SynIdent(id:Ident, _)) = $1 + | opt_access nameop + { (let (SynIdent(id:Ident, _)) = $2 if id.idText = "get" then - SynMemberKind.PropertyGet, Some(GetSetKeywords.Get id.idRange) + SynMemberKind.PropertyGet, Some(GetSetKeywords.Get id.idRange), $1, None else if id.idText = "set" then - SynMemberKind.PropertySet, Some(GetSetKeywords.Set id.idRange) + SynMemberKind.PropertySet, Some(GetSetKeywords.Set id.idRange), None, $1 else raiseParseErrorAt (rhs parseState 1) (FSComp.SR.parsGetOrSetRequired())) } - | nameop COMMA nameop - { let (SynIdent(id, _)) = $1 - let (SynIdent(id2, _)) = $3 + | opt_access nameop COMMA opt_access nameop + { let (SynIdent(id, _)) = $2 + let (SynIdent(id2, _)) = $5 if not ((id.idText = "get" && id2.idText = "set") || (id.idText = "set" && id2.idText = "get")) then raiseParseErrorAt (rhs2 parseState 1 3) (FSComp.SR.parsGetOrSetRequired()) if id.idText = "get" then - SynMemberKind.PropertyGetSet, Some(GetSetKeywords.GetSet(id.idRange, id2.idRange)) + SynMemberKind.PropertyGetSet, Some(GetSetKeywords.GetSet(id.idRange, id2.idRange)), $1, $4 else - SynMemberKind.PropertyGetSet, Some(GetSetKeywords.GetSet(id2.idRange, id.idRange)) } + SynMemberKind.PropertyGetSet, Some(GetSetKeywords.GetSet(id2.idRange, id.idRange)), $4, $1 } - | nameop COMMA recover - { (let (SynIdent(id:Ident, _)) = $1 + | opt_access nameop COMMA recover + { (let (SynIdent(id:Ident, _)) = $2 if id.idText = "get" then - SynMemberKind.PropertyGet, Some(GetSetKeywords.Get id.idRange) + SynMemberKind.PropertyGet, Some(GetSetKeywords.Get id.idRange), $1, None else if id.idText = "set" then - SynMemberKind.PropertySet, Some(GetSetKeywords.Set id.idRange) + SynMemberKind.PropertySet, Some(GetSetKeywords.Set id.idRange), None, $1 else - raiseParseErrorAt (rhs parseState 1) (FSComp.SR.parsGetOrSetRequired())) } + raiseParseErrorAt (rhs parseState 2) (FSComp.SR.parsGetOrSetRequired())) } | OBLOCKBEGIN oblockend ODECLEND { reportParseErrorAt (rhs parseState 1) (FSComp.SR.parsIdentifierExpected()) - SynMemberKind.Member, None } + SynMemberKind.Member, None, None, None } memberSpecFlags: | memberFlags { $1 } @@ -2034,7 +2041,7 @@ classDefnMember: | opt_attributes opt_access abstractMemberFlags opt_inline nameop opt_explicitValTyparDecls COLON topTypeWithTypeConstraints classMemberSpfnGetSet opt_ODECLEND { let ty, arity = $8 let isInline, doc, id, explicitValTyparDecls = (Option.isSome $4), grabXmlDoc(parseState, $1, 1), $5, $6 - let mWith, (getSet, getSetRangeOpt) = $9 + let mWith, (getSet, getSetRangeOpt, getterAccess, setterAccess) = $9 let getSetAdjuster arity = match arity, getSet with SynValInfo([], _), SynMemberKind.Member -> SynMemberKind.PropertyGet | _ -> getSet let mWhole = let m = rhs parseState 1 @@ -2042,7 +2049,8 @@ classDefnMember: | None -> unionRanges m ty.Range | Some gs -> unionRanges m gs.Range |> unionRangeWithXmlDoc doc - if Option.isSome $2 then errorR(Error(FSComp.SR.parsAccessibilityModsIllegalForAbstract(), mWhole)) + if Option.isSome $2 || Option.isSome getterAccess || Option.isSome setterAccess + then errorR(Error(FSComp.SR.parsAccessibilityModsIllegalForAbstract(), mWhole)) let mkFlags, leadingKeyword = $3 let trivia = { LeadingKeyword = leadingKeyword; InlineKeyword = $4; WithKeyword = mWith; EqualsRange = None } let valSpfn = SynValSig($1, id, explicitValTyparDecls, ty, arity, isInline, false, doc, None, None, mWhole, trivia) @@ -2181,7 +2189,7 @@ autoPropsDefnDecl: errorR (Error(FSComp.SR.parsMutableOnAutoPropertyShouldBeGetSet (), rhs parseState 2)) fun attribs flags rangeStart -> let xmlDoc = grabXmlDocAtRangeStart (parseState, attribs, rangeStart) - [ mkAutoPropDefn mVal $3 $4 $5 None expr (None, (SynMemberKind.Member, None)) xmlDoc attribs flags rangeStart ] } + [ mkAutoPropDefn mVal $3 $4 $5 None expr (None, (SynMemberKind.Member, None, None, None)) xmlDoc attribs flags rangeStart ] } | VAL opt_mutable opt_access ident opt_typ OBLOCKSEP { let mVal = rhs parseState 1 @@ -2194,7 +2202,7 @@ autoPropsDefnDecl: errorR (Error(FSComp.SR.parsMutableOnAutoPropertyShouldBeGetSet (), rhs parseState 2)) fun attribs flags rangeStart -> let xmlDoc = grabXmlDocAtRangeStart (parseState, attribs, rangeStart) - [ mkAutoPropDefn mVal $3 $4 $5 None expr (None, (SynMemberKind.Member, None)) xmlDoc attribs flags rangeStart ] } + [ mkAutoPropDefn mVal $3 $4 $5 None expr (None, (SynMemberKind.Member, None, None, None)) xmlDoc attribs flags rangeStart ] } | VAL opt_mutable opt_access recover { let mVal = rhs parseState 1 @@ -2204,7 +2212,7 @@ autoPropsDefnDecl: errorR (Error(FSComp.SR.parsMutableOnAutoPropertyShouldBeGetSet (), rhs parseState 2)) fun attribs flags rangeStart -> let xmlDoc = grabXmlDocAtRangeStart(parseState, attribs, rangeStart) - [ mkAutoPropDefn mVal $3 id None None expr (None, (SynMemberKind.Member, None)) xmlDoc attribs flags rangeStart ] } + [ mkAutoPropDefn mVal $3 id None None expr (None, (SynMemberKind.Member, None, None, None)) xmlDoc attribs flags rangeStart ] } /* An optional type on an auto-property definition */ opt_typ: diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 66205091123..509c8bd4ad7 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -227,6 +227,11 @@ další převody orientované na typ + + Allow access modifiers to auto properties getters and setters + Allow access modifiers to auto properties getters and setters + + applicative computation expressions aplikativní výpočetní výrazy @@ -907,6 +912,11 @@ Funkce správy balíčků vyžaduje jazykovou verzi 5.0 nebo vyšší. + + The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. + The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. Syntaxi průniku omezení lze použít pouze s flexibilními typy, například „#IDisposable a #ISomeInterface“. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index f72b6948a76..2635ea818f1 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -227,6 +227,11 @@ zusätzliche typgesteuerte Konvertierungen + + Allow access modifiers to auto properties getters and setters + Allow access modifiers to auto properties getters and setters + + applicative computation expressions applikative Berechnungsausdrücke @@ -907,6 +912,11 @@ Für das „Paketverwaltungsfeature“ ist Sprachversion 5.0 oder höher erforderlich + + The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. + The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. Die Einschränkungsüberschneidungssyntax kann nur mit flexiblen Typen verwendet werden, z. B. "#IDisposable & #ISomeInterface". diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 12f4457f73e..3c81bed6124 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -227,6 +227,11 @@ conversiones adicionales dirigidas a tipos + + Allow access modifiers to auto properties getters and setters + Allow access modifiers to auto properties getters and setters + + applicative computation expressions expresiones de cálculo aplicativas @@ -907,6 +912,11 @@ La característica de "administración de paquetes" requiere la versión de lenguaje 5.0 o superior + + The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. + The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. La sintaxis de intersección de restricciones solo se puede usar con tipos flexibles, por ejemplo, "#IDisposable &#ISomeInterface". diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 9477b8b7680..5162b04d3d8 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -227,6 +227,11 @@ conversions supplémentaires dirigées vers le type + + Allow access modifiers to auto properties getters and setters + Allow access modifiers to auto properties getters and setters + + applicative computation expressions expressions de calcul applicatives @@ -907,6 +912,11 @@ La fonction « gestion des paquets » nécessite une version de langue 5.0 ou supérieure. + + The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. + The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. La syntaxe d'intersection de contraintes ne peut être utilisée qu'avec des types flexibles, par ex. '#IDisposable et #ISomeInterface'. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index b17ab37848d..4050b14cf7f 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -227,6 +227,11 @@ conversioni aggiuntive dirette ai tipi + + Allow access modifiers to auto properties getters and setters + Allow access modifiers to auto properties getters and setters + + applicative computation expressions espressioni di calcolo applicativo @@ -907,6 +912,11 @@ La funzionalità 'gestione pacchetti' richiede la versione del linguaggio 5.0 o superiore + + The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. + The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. La sintassi dell'intersezione dei vincoli può essere usata solo con tipi flessibili, ad esempio '#IDisposable & #ISomeInterface'. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index fa6fb18bda6..2f30491d680 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -227,6 +227,11 @@ その他の型指定された変換 + + Allow access modifiers to auto properties getters and setters + Allow access modifiers to auto properties getters and setters + + applicative computation expressions 適用できる計算式 @@ -907,6 +912,11 @@ 'package management' (パッケージ管理) 機能には、言語バージョン 5.0 以降が必要です + + The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. + The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. 制約交差構文は、"#IDisposable & #ISomeInterface" など、柔軟な型でのみ使用できます。 diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 1cf38ecd52e..9340410bcba 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -227,6 +227,11 @@ 추가 형식-디렉션 변환 + + Allow access modifiers to auto properties getters and setters + Allow access modifiers to auto properties getters and setters + + applicative computation expressions 적용 가능한 계산 식 @@ -907,6 +912,11 @@ '패키지 관리' 기능을 사용하려면 언어 버전 5.0 이상이 필요합니다. + + The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. + The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. 제약 조건 교차 구문은 유연한 형식(예: '#IDisposable &#ISomeInterface')에서만 사용할 수 있습니다. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index a36f1d7cb51..5452bcebf00 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -227,6 +227,11 @@ dodatkowe konwersje ukierunkowane na typ + + Allow access modifiers to auto properties getters and setters + Allow access modifiers to auto properties getters and setters + + applicative computation expressions praktyczne wyrażenia obliczeniowe @@ -907,6 +912,11 @@ Funkcja „Zarządzanie pakietami” wymaga języka w wersji 5.0 lub nowszej + + The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. + The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. Składnia przecięcia ograniczenia może być używana tylko z typami elastycznymi, np. „#IDisposable &#ISomeInterface”. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 129e7cb792e..f90d3d8fa12 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -227,6 +227,11 @@ conversões direcionadas por tipos adicionais + + Allow access modifiers to auto properties getters and setters + Allow access modifiers to auto properties getters and setters + + applicative computation expressions expressões de computação aplicáveis @@ -907,6 +912,11 @@ O recurso 'gerenciamento de pacotes' requer a versão 5.0 ou superior do idioma + + The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. + The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. A sintaxe de interseção de restrição só pode ser usada com tipos flexíveis, por exemplo, "#IDisposable & #ISomeInterface". diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index d0acf9ef585..f4a2e807c60 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -227,6 +227,11 @@ дополнительные преобразования на основе типа + + Allow access modifiers to auto properties getters and setters + Allow access modifiers to auto properties getters and setters + + applicative computation expressions применимые вычислительные выражения @@ -907,6 +912,11 @@ Для функции управления пакетами требуется версия языка 5.0 или более поздняя + + The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. + The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. Синтаксис пересечения ограничений можно использовать только с гибкими типами, например. "#IDisposable & #ISomeInterface". diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 555f737153e..940de471b10 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -227,6 +227,11 @@ ek tür ile yönlendirilen dönüştürmeler + + Allow access modifiers to auto properties getters and setters + Allow access modifiers to auto properties getters and setters + + applicative computation expressions uygulama hesaplama ifadeleri @@ -907,6 +912,11 @@ ‘Paket yönetimi’ özelliği, dil sürümü 5.0 veya üstünü gerektirir + + The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. + The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. Kısıtlama kesişimi söz dizimi yalnızca esnek türlerle kullanılabilir. Ör. '#IDisposable & #ISomeInterface'. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 72e2ea8f447..30e6d6073c0 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -227,6 +227,11 @@ 附加类型定向转换 + + Allow access modifiers to auto properties getters and setters + Allow access modifiers to auto properties getters and setters + + applicative computation expressions 适用的计算表达式 @@ -907,6 +912,11 @@ “包管理”功能需要语言版本 5.0 或更高版本 + + The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. + The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. 约束交集语法只能与灵活类型一起使用,例如 "#IDisposable & #ISomeInterface"。 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 817e803623b..8d79311a0dc 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -227,6 +227,11 @@ 其他類型導向轉換 + + Allow access modifiers to auto properties getters and setters + Allow access modifiers to auto properties getters and setters + + applicative computation expressions 適用的計算運算式 @@ -907,6 +912,11 @@ 「套件管理」功能需要語言版本 5.0 或更新版本 + + The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. + The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. + + Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. 條件約束交集語法只能搭配彈性類型使用,例如「#IDisposable 與 #ISomeInterface'」。 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/MemberDefinitions/MethodsAndProperties/AutoPropsWithModifierBeforeGetSet.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/MemberDefinitions/MethodsAndProperties/AutoPropsWithModifierBeforeGetSet.fs new file mode 100644 index 00000000000..8e1703df5a2 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/MemberDefinitions/MethodsAndProperties/AutoPropsWithModifierBeforeGetSet.fs @@ -0,0 +1,177 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +module Conformance.BasicGrammarElements.AutoPropsWithModifierBeforeGetSet + +open Xunit +open FSharp.Test +open FSharp.Test.Compiler + +let verifyCompile compilation = + compilation + |> asExe + |> withOptions ["--nowarn:988"] + |> compile + +let verifyCompileAndRun compilation = + compilation + |> asExe + |> withOptions ["--nowarn:988"] + |> compileAndRun + +[] +let ``Instance Properties Test`` () = + Fs """type InstancePropertiesTest() = + member val B1: int = 0 with get + // should fail + member val B2: int = 0 with set + member val B3: int = 0 with get, set + member val B4: int = 0 with internal get + // should fail + member val B5: int = 0 with internal set + member val B6: int = 0 with internal get, internal set + member val B7: int = 0 with internal get, set + member val B8: int = 0 with get, internal set + // should fail + member val internal B11: int = 0 with internal get, set + // should fail + member val internal B12: int = 0 with internal get + // should fail + member val internal B13: int = 0 with internal set + member val internal B14: int = 0 with get, set + member val internal B15: int = 0 with get + // should fail + member val internal B16: int = 0 with set""" + |> withLangVersionPreview + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 3135, Line 4, Col 33, Line 4, Col 36, "To indicate that this property can be set, use 'member val PropertyName = expr with get,set'.") + (Error 3135, Line 8, Col 42, Line 8, Col 45, "To indicate that this property can be set, use 'member val PropertyName = expr with get,set'.") + (Error 0558, Line 13, Col 43, Line 13, Col 51, "When the visibility for a property is specified, setting the visibility of the set or get method is not allowed.") + (Error 0558, Line 15, Col 43, Line 15, Col 51, "When the visibility for a property is specified, setting the visibility of the set or get method is not allowed.") + (Error 3135, Line 17, Col 52, Line 17, Col 55, "To indicate that this property can be set, use 'member val PropertyName = expr with get,set'.") + (Error 0558, Line 17, Col 43, Line 17, Col 51, "When the visibility for a property is specified, setting the visibility of the set or get method is not allowed.") + (Error 3135, Line 21, Col 43, Line 21, Col 46, "To indicate that this property can be set, use 'member val PropertyName = expr with get,set'.") + ] + +[] +let ``Static Properties Test`` () = + Fs """type StaticPropertiesTest() = + static member val B1: int = 0 with get + // should fail + static member val B2: int = 0 with set + static member val B3: int = 0 with get, set + static member val B4: int = 0 with internal get + // should fail + static member val B5: int = 0 with internal set + static member val B6: int = 0 with internal get, internal set + static member val B7: int = 0 with internal get, set + static member val B8: int = 0 with get, internal set + // should fail + static member val internal B11: int = 0 with internal get, set + // should fail + static member val internal B12: int = 0 with internal get + // should fail + static member val internal B13: int = 0 with internal set + static member val internal B14: int = 0 with get, set + static member val internal B15: int = 0 with get + // should fail + static member val internal B16: int = 0 with set""" + |> withLangVersionPreview + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 3135, Line 4, Col 40, Line 4, Col 43, "To indicate that this property can be set, use 'member val PropertyName = expr with get,set'.") + (Error 3135, Line 8, Col 49, Line 8, Col 52, "To indicate that this property can be set, use 'member val PropertyName = expr with get,set'.") + (Error 0558, Line 13, Col 50, Line 13, Col 58, "When the visibility for a property is specified, setting the visibility of the set or get method is not allowed.") + (Error 0558, Line 15, Col 50, Line 15, Col 58, "When the visibility for a property is specified, setting the visibility of the set or get method is not allowed.") + (Error 3135, Line 17, Col 59, Line 17, Col 62, "To indicate that this property can be set, use 'member val PropertyName = expr with get,set'.") + (Error 0558, Line 17, Col 50, Line 17, Col 58, "When the visibility for a property is specified, setting the visibility of the set or get method is not allowed.") + (Error 3135, Line 21, Col 50, Line 21, Col 53, "To indicate that this property can be set, use 'member val PropertyName = expr with get,set'.") + ] + +[] +let ``Abstract Properties Test: access modifiers are not allowed`` () = + Fs """type ``Abstract Properties Test`` = + abstract member B1: int with get, set + abstract member B2: int with get + abstract member B3: int with set + // should fail + abstract member B4: int with internal get, set + // should fail + abstract member B5: int with get, internal set + // should fail + abstract member B6: int with internal get, internal set + // should fail + abstract member B7: int with internal get + // should fail + abstract member B8: int with internal set""" + |> withLangVersionPreview + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 0561, Line 6, Col 5, Line 6, Col 51, "Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.") + (Error 0561, Line 8, Col 5, Line 8, Col 51, "Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.") + (Error 0561, Line 10, Col 5, Line 10, Col 60, "Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.") + (Error 0561, Line 12, Col 5, Line 12, Col 46, "Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.") + (Error 0561, Line 14, Col 5, Line 14, Col 46, "Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.") + ] + +[] +let ``Signature File Test: no access modifiers before getter and setter`` () = + Fsi """module Program + +type A = + new: unit -> A + member internal B: int + member internal C: int with get, set + // will warning + member D: int with internal get, private set + abstract E: int with get, set + // will warning + abstract F: int with get, private set""" + |> withLangVersionPreview + |> verifyCompile + |> shouldFail + |> withDiagnostics [ + (Warning 3866, Line 8, Col 24, Line 8, Col 32, "The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file.") + (Warning 3866, Line 8, Col 38, Line 8, Col 45, "The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file.") + (Warning 3866, Line 11, Col 31, Line 11, Col 38, "The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file.") + (Error 240, Line 1, Col 1, Line 11, Col 42, "The signature file 'Program' 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 ``Signature And Implement File Test`` () = + let encodeFs = + FsSource """module Program + +type A() = + member val B: int = 0 with internal get, internal set + member val C: int = 0 with internal get, internal set + member val D: int = 0 with internal get, private set""" + Fsi """module Program + +type A = + new: unit -> A + member internal B: int + member internal C: int with get, set + // will warning + member D: int with internal get, private set""" + |> withAdditionalSourceFile encodeFs + |> withLangVersionPreview + |> compile + |> shouldFail + |> withDiagnostics [ + (Warning 3866, Line 8, Col 24, Line 8, Col 32, "The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file.") + (Warning 3866, Line 8, Col 38, Line 8, Col 45, "The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file.") + (Error 0034, Line 6, Col 16, Line 6, Col 17, "Module 'Program' contains + member private A.D: int with set +but its signature specifies + member A.D: int with set +The accessibility specified in the signature is more than that specified in the implementation") + (Error 0034, Line 6, Col 16, Line 6, Col 17, "Module 'Program' contains + member internal A.D: int +but its signature specifies + member A.D: int +The accessibility specified in the signature is more than that specified in the implementation") + ] diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 4f04946a466..0bb8fd4a34f 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -56,6 +56,7 @@ + diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl index 3c4b22f76c1..51d08041668 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl @@ -7739,6 +7739,10 @@ FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: Microsoft.FSharp.Collections. FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList] get_attributes() FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynAccess] accessibility 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.SynAccess] get_getterAccessibility() +FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynAccess] get_setterAccessibility() +FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynAccess] getterAccessibility +FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynAccess] setterAccessibility 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+GetSetMember: FSharp.Compiler.SyntaxTrivia.SynMemberGetSetTrivia get_trivia() @@ -7848,7 +7852,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.SyntaxTrivia.SynMemberDefnAbstractSlotTrivia) -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 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], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynAccess], 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.SynPat, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.Ident], FSharp.Compiler.Xml.PreXmlDoc, FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynMemberDefnImplicitCtorTrivia) 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) diff --git a/tests/service/data/SyntaxTree/LeadingKeyword/DefaultValKeyword.fs.bsl b/tests/service/data/SyntaxTree/LeadingKeyword/DefaultValKeyword.fs.bsl index 0451b561b92..aae0b57cb0c 100644 --- a/tests/service/data/SyntaxTree/LeadingKeyword/DefaultValKeyword.fs.bsl +++ b/tests/service/data/SyntaxTree/LeadingKeyword/DefaultValKeyword.fs.bsl @@ -28,7 +28,8 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((3,4), FSharp.Compiler.Xml.XmlDocCollector), - None, Const (Int32 1, (3,26--3,27)), (3,4--3,27), + None, None, None, Const (Int32 1, (3,26--3,27)), + (3,4--3,27), { LeadingKeyword = DefaultVal ((3,4--3,11), (3,12--3,15)) WithKeyword = None diff --git a/tests/service/data/SyntaxTree/LeadingKeyword/MemberValKeyword.fs.bsl b/tests/service/data/SyntaxTree/LeadingKeyword/MemberValKeyword.fs.bsl index 7178d569385..a5a5c94bbf8 100644 --- a/tests/service/data/SyntaxTree/LeadingKeyword/MemberValKeyword.fs.bsl +++ b/tests/service/data/SyntaxTree/LeadingKeyword/MemberValKeyword.fs.bsl @@ -28,7 +28,8 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((3,4), FSharp.Compiler.Xml.XmlDocCollector), - None, Const (Int32 1, (3,25--3,26)), (3,4--3,26), + None, None, None, Const (Int32 1, (3,25--3,26)), + (3,4--3,26), { LeadingKeyword = MemberVal ((3,4--3,10), (3,11--3,14)) WithKeyword = None diff --git a/tests/service/data/SyntaxTree/LeadingKeyword/OverrideValKeyword.fs.bsl b/tests/service/data/SyntaxTree/LeadingKeyword/OverrideValKeyword.fs.bsl index 4d3005f29e3..de95a8f3bbb 100644 --- a/tests/service/data/SyntaxTree/LeadingKeyword/OverrideValKeyword.fs.bsl +++ b/tests/service/data/SyntaxTree/LeadingKeyword/OverrideValKeyword.fs.bsl @@ -28,7 +28,8 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((3,4), FSharp.Compiler.Xml.XmlDocCollector), - None, Const (Int32 1, (3,27--3,28)), (3,4--3,28), + None, None, None, Const (Int32 1, (3,27--3,28)), + (3,4--3,28), { LeadingKeyword = OverrideVal ((3,4--3,12), (3,13--3,16)) WithKeyword = None diff --git a/tests/service/data/SyntaxTree/LeadingKeyword/StaticMemberValKeyword.fs.bsl b/tests/service/data/SyntaxTree/LeadingKeyword/StaticMemberValKeyword.fs.bsl index 809096c0c78..2ac6f5d2c39 100644 --- a/tests/service/data/SyntaxTree/LeadingKeyword/StaticMemberValKeyword.fs.bsl +++ b/tests/service/data/SyntaxTree/LeadingKeyword/StaticMemberValKeyword.fs.bsl @@ -28,7 +28,8 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((3,4), FSharp.Compiler.Xml.XmlDocCollector), - None, Const (Int32 1, (3,32--3,33)), (3,4--3,33), + None, None, None, Const (Int32 1, (3,32--3,33)), + (3,4--3,33), { LeadingKeyword = StaticMemberVal ((3,4--3,10), (3,11--3,17), (3,18--3,21)) diff --git a/tests/service/data/SyntaxTree/Member/Auto property 01.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 01.fs.bsl index 5155ca1b3e3..4576c205a95 100644 --- a/tests/service/data/SyntaxTree/Member/Auto property 01.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Auto property 01.fs.bsl @@ -27,7 +27,8 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, Const (Int32 1, (4,20--4,21)), (4,4--4,21), + None, None, None, Const (Int32 1, (4,20--4,21)), + (4,4--4,21), { LeadingKeyword = MemberVal ((4,4--4,10), (4,11--4,14)) WithKeyword = None diff --git a/tests/service/data/SyntaxTree/Member/Auto property 02.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 02.fs.bsl index af2cbcfa598..b8736fd23e2 100644 --- a/tests/service/data/SyntaxTree/Member/Auto property 02.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Auto property 02.fs.bsl @@ -27,7 +27,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, + None, None, None, ArbitraryAfterError ("typedSequentialExprBlock1", (4,19--4,19)), (4,4--4,19), diff --git a/tests/service/data/SyntaxTree/Member/Auto property 03.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 03.fs.bsl index 4dc2510f320..c489efc4380 100644 --- a/tests/service/data/SyntaxTree/Member/Auto property 03.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Auto property 03.fs.bsl @@ -27,7 +27,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, + None, None, None, ArbitraryAfterError ("typedSequentialExprBlock1", (4,19--4,19)), (4,4--4,19), @@ -51,7 +51,8 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((5,4), FSharp.Compiler.Xml.XmlDocCollector), - None, Const (Int32 2, (5,20--5,21)), (5,4--5,21), + None, None, None, Const (Int32 2, (5,20--5,21)), + (5,4--5,21), { LeadingKeyword = MemberVal ((5,4--5,10), (5,11--5,14)) WithKeyword = None diff --git a/tests/service/data/SyntaxTree/Member/Auto property 04.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 04.fs.bsl index 9497c483352..f9c511bfc5e 100644 --- a/tests/service/data/SyntaxTree/Member/Auto property 04.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Auto property 04.fs.bsl @@ -27,7 +27,8 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, ArbitraryAfterError ("autoProp2", (4,17--4,17)), + None, None, None, + ArbitraryAfterError ("autoProp2", (4,17--4,17)), (4,4--4,17), { LeadingKeyword = MemberVal ((4,4--4,10), (4,11--4,14)) @@ -49,7 +50,8 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((5,4), FSharp.Compiler.Xml.XmlDocCollector), - None, Const (Int32 2, (5,20--5,21)), (5,4--5,21), + None, None, None, Const (Int32 2, (5,20--5,21)), + (5,4--5,21), { LeadingKeyword = MemberVal ((5,4--5,10), (5,11--5,14)) WithKeyword = None diff --git a/tests/service/data/SyntaxTree/Member/Auto property 05.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 05.fs.bsl index 84a9f629f6e..541adf1f681 100644 --- a/tests/service/data/SyntaxTree/Member/Auto property 05.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Auto property 05.fs.bsl @@ -27,7 +27,8 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, ArbitraryAfterError ("autoProp3", (4,14--4,14)), + None, None, None, + ArbitraryAfterError ("autoProp3", (4,14--4,14)), (4,4--4,14), { LeadingKeyword = MemberVal ((4,4--4,10), (4,11--4,14)) @@ -49,7 +50,8 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((5,4), FSharp.Compiler.Xml.XmlDocCollector), - None, Const (Int32 2, (5,20--5,21)), (5,4--5,21), + None, None, None, Const (Int32 2, (5,20--5,21)), + (5,4--5,21), { LeadingKeyword = MemberVal ((5,4--5,10), (5,11--5,14)) WithKeyword = None diff --git a/tests/service/data/SyntaxTree/Member/Auto property 06.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 06.fs.bsl index 50d5378bf80..0a7d12909ea 100644 --- a/tests/service/data/SyntaxTree/Member/Auto property 06.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Auto property 06.fs.bsl @@ -27,7 +27,8 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, Const (Int32 1, (4,20--4,21)), (4,4--4,21), + None, None, None, Const (Int32 1, (4,20--4,21)), + (4,4--4,21), { LeadingKeyword = MemberVal ((4,4--4,10), (4,11--4,14)) WithKeyword = None diff --git a/tests/service/data/SyntaxTree/Member/Auto property 07.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 07.fs.bsl index 492124d31f0..84e7a69d193 100644 --- a/tests/service/data/SyntaxTree/Member/Auto property 07.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Auto property 07.fs.bsl @@ -32,7 +32,8 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, Const (Int32 7, (4,24--4,25)), (4,4--4,38), + None, None, None, Const (Int32 7, (4,24--4,25)), + (4,4--4,38), { LeadingKeyword = MemberVal ((4,4--4,10), (4,11--4,14)) WithKeyword = Some (4,26--4,30) diff --git a/tests/service/data/SyntaxTree/Member/Auto property 08.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 08.fs.bsl index 82805ec6df7..982030b64d2 100644 --- a/tests/service/data/SyntaxTree/Member/Auto property 08.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Auto property 08.fs.bsl @@ -27,7 +27,8 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, Const (Int32 1, (4,19--4,20)), (4,4--4,29), + None, None, None, Const (Int32 1, (4,19--4,20)), + (4,4--4,29), { LeadingKeyword = MemberVal ((4,4--4,10), (4,11--4,14)) WithKeyword = Some (4,21--4,25) @@ -45,4 +46,4 @@ ImplFile (6,0)-(6,1) parse error Unexpected syntax or possible incorrect indentation: this token is offside of context started at position (4:22). Try indenting this further. To continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7. -(6,0)-(6,1) parse error Incomplete structured construct at or before this point in member definition. Expected identifier, '(', '(*)' or other token. +(6,0)-(6,1) parse error Incomplete structured construct at or before this point. Expected identifier, '(', '(*)' or other token. diff --git a/tests/service/data/SyntaxTree/Member/Auto property 09.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 09.fs.bsl index 00760cf2537..f4d9b9aa777 100644 --- a/tests/service/data/SyntaxTree/Member/Auto property 09.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Auto property 09.fs.bsl @@ -27,7 +27,8 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, Const (Int32 1, (4,20--4,21)), (4,4--4,30), + None, None, None, Const (Int32 1, (4,20--4,21)), + (4,4--4,30), { LeadingKeyword = MemberVal ((4,4--4,10), (4,11--4,14)) WithKeyword = Some (4,22--4,26) @@ -68,4 +69,4 @@ ImplFile (5,4)-(5,10) parse error Unexpected syntax or possible incorrect indentation: this token is offside of context started at position (4:23). Try indenting this further. To continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7. -(5,4)-(5,10) parse error Incomplete structured construct at or before this point in member definition. Expected identifier, '(', '(*)' or other token. +(5,4)-(5,10) parse error Incomplete structured construct at or before this point. Expected identifier, '(', '(*)' or other token. diff --git a/tests/service/data/SyntaxTree/Member/Auto property 10.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 10.fs.bsl index 1a61306fb2d..aeaf553b54c 100644 --- a/tests/service/data/SyntaxTree/Member/Auto property 10.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Auto property 10.fs.bsl @@ -27,7 +27,8 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, Const (Int32 1, (4,19--4,20)), (4,4--4,29), + None, None, None, Const (Int32 1, (4,19--4,20)), + (4,4--4,29), { LeadingKeyword = MemberVal ((4,4--4,10), (4,11--4,14)) WithKeyword = Some (4,21--4,25) @@ -44,4 +45,4 @@ ImplFile (5,0)-(5,0) parse error Unexpected syntax or possible incorrect indentation: this token is offside of context started at position (4:22). Try indenting this further. To continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7. -(5,0)-(5,0) parse error Incomplete structured construct at or before this point in member definition. Expected identifier, '(', '(*)' or other token. +(5,0)-(5,0) parse error Incomplete structured construct at or before this point. Expected identifier, '(', '(*)' or other token. diff --git a/tests/service/data/SyntaxTree/Member/Auto property 11.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 11.fs.bsl index 14121127b62..b0235cf362a 100644 --- a/tests/service/data/SyntaxTree/Member/Auto property 11.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Auto property 11.fs.bsl @@ -27,7 +27,8 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, Const (Int32 1, (4,19--4,20)), (4,4--4,29), + None, None, None, Const (Int32 1, (4,19--4,20)), + (4,4--4,29), { LeadingKeyword = MemberVal ((4,4--4,10), (4,11--4,14)) WithKeyword = Some (4,21--4,25) diff --git a/tests/service/data/SyntaxTree/Member/Auto property 12.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 12.fs.bsl index d466718e4af..79d41c4f5a0 100644 --- a/tests/service/data/SyntaxTree/Member/Auto property 12.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Auto property 12.fs.bsl @@ -27,7 +27,8 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, Const (Int32 1, (4,19--4,20)), (4,4--4,20), + None, None, None, Const (Int32 1, (4,19--4,20)), + (4,4--4,20), { LeadingKeyword = MemberVal ((4,4--4,10), (4,11--4,14)) WithKeyword = Some (4,21--4,25) diff --git a/tests/service/data/SyntaxTree/Member/Auto property 13.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 13.fs.bsl index d0c7a6c9dbc..a4515894463 100644 --- a/tests/service/data/SyntaxTree/Member/Auto property 13.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Auto property 13.fs.bsl @@ -27,7 +27,8 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, Const (Int32 1, (4,19--4,20)), (4,4--4,20), + None, None, None, Const (Int32 1, (4,19--4,20)), + (4,4--4,20), { LeadingKeyword = MemberVal ((4,4--4,10), (4,11--4,14)) WithKeyword = Some (4,21--4,25) diff --git a/tests/service/data/SyntaxTree/Member/Auto property 14.fs b/tests/service/data/SyntaxTree/Member/Auto property 14.fs new file mode 100644 index 00000000000..c69c16bcfbf --- /dev/null +++ b/tests/service/data/SyntaxTree/Member/Auto property 14.fs @@ -0,0 +1,4 @@ +module A + +type X() = + member val Y: int = 7 with public get, private set diff --git a/tests/service/data/SyntaxTree/Member/Auto property 14.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 14.fs.bsl new file mode 100644 index 00000000000..2235a327002 --- /dev/null +++ b/tests/service/data/SyntaxTree/Member/Auto property 14.fs.bsl @@ -0,0 +1,56 @@ +ImplFile + (ParsedImplFileInput + ("/root/Member/Auto property 14.fs", false, QualifiedNameOfFile A, [], [], + [SynModuleOrNamespace + ([A], false, NamedModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [X], + PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (3,5--3,6)), + ObjectModel + (Unspecified, + [ImplicitCtor + (None, [], Const (Unit, (3,6--3,8)), None, + PreXmlDoc ((3,6), FSharp.Compiler.Xml.XmlDocCollector), + (3,5--3,6), { AsKeyword = None }); + AutoProperty + ([], false, Y, + Some (LongIdent (SynLongIdent ([int], [], [None]))), + PropertyGetSet, + { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = Member }, + { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = PropertySet }, + PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), + None, Some (Public (4,31--4,37)), + Some (Private (4,43--4,50)), + Const (Int32 7, (4,24--4,25)), (4,4--4,54), + { LeadingKeyword = + MemberVal ((4,4--4,10), (4,11--4,14)) + WithKeyword = Some (4,26--4,30) + EqualsRange = Some (4,22--4,23) + GetSetKeywords = + Some (GetSet ((4,38--4,41), (4,51--4,54))) })], + (4,4--4,54)), [], + Some + (ImplicitCtor + (None, [], Const (Unit, (3,6--3,8)), None, + PreXmlDoc ((3,6), FSharp.Compiler.Xml.XmlDocCollector), + (3,5--3,6), { AsKeyword = None })), (3,5--4,54), + { LeadingKeyword = Type (3,0--3,4) + EqualsRange = Some (3,9--3,10) + WithKeyword = None })], (3,0--4,54))], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (1,0--4,54), { LeadingKeyword = Module (1,0--1,6) })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Member/Auto property 15.fs b/tests/service/data/SyntaxTree/Member/Auto property 15.fs new file mode 100644 index 00000000000..aedf83865d3 --- /dev/null +++ b/tests/service/data/SyntaxTree/Member/Auto property 15.fs @@ -0,0 +1,4 @@ +module A + +type X() = + member val internal Y: int = 7 with public get, private set diff --git a/tests/service/data/SyntaxTree/Member/Auto property 15.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 15.fs.bsl new file mode 100644 index 00000000000..457b112dc31 --- /dev/null +++ b/tests/service/data/SyntaxTree/Member/Auto property 15.fs.bsl @@ -0,0 +1,56 @@ +ImplFile + (ParsedImplFileInput + ("/root/Member/Auto property 15.fs", false, QualifiedNameOfFile A, [], [], + [SynModuleOrNamespace + ([A], false, NamedModule, + [Types + ([SynTypeDefn + (SynComponentInfo + ([], None, [], [X], + PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector), + false, None, (3,5--3,6)), + ObjectModel + (Unspecified, + [ImplicitCtor + (None, [], Const (Unit, (3,6--3,8)), None, + PreXmlDoc ((3,6), FSharp.Compiler.Xml.XmlDocCollector), + (3,5--3,6), { AsKeyword = None }); + AutoProperty + ([], false, Y, + Some (LongIdent (SynLongIdent ([int], [], [None]))), + PropertyGetSet, + { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = Member }, + { IsInstance = true + IsDispatchSlot = false + IsOverrideOrExplicitImpl = false + IsFinal = false + GetterOrSetterIsCompilerGenerated = false + MemberKind = PropertySet }, + PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), + Some (Internal (4,15--4,23)), + Some (Public (4,40--4,46)), Some (Private (4,52--4,59)), + Const (Int32 7, (4,33--4,34)), (4,4--4,63), + { LeadingKeyword = + MemberVal ((4,4--4,10), (4,11--4,14)) + WithKeyword = Some (4,35--4,39) + EqualsRange = Some (4,31--4,32) + GetSetKeywords = + Some (GetSet ((4,47--4,50), (4,60--4,63))) })], + (4,4--4,63)), [], + Some + (ImplicitCtor + (None, [], Const (Unit, (3,6--3,8)), None, + PreXmlDoc ((3,6), FSharp.Compiler.Xml.XmlDocCollector), + (3,5--3,6), { AsKeyword = None })), (3,5--4,63), + { LeadingKeyword = Type (3,0--3,4) + EqualsRange = Some (3,9--3,10) + WithKeyword = None })], (3,0--4,63))], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, + (1,0--4,63), { LeadingKeyword = Module (1,0--1,6) })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Member/SynTypeDefnWithAutoPropertyContainsTheRangeOfTheEqualsSign.fs.bsl b/tests/service/data/SyntaxTree/Member/SynTypeDefnWithAutoPropertyContainsTheRangeOfTheEqualsSign.fs.bsl index 7cfa4c283eb..9ebebcbddf1 100644 --- a/tests/service/data/SyntaxTree/Member/SynTypeDefnWithAutoPropertyContainsTheRangeOfTheEqualsSign.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/SynTypeDefnWithAutoPropertyContainsTheRangeOfTheEqualsSign.fs.bsl @@ -51,7 +51,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((5,4), FSharp.Compiler.Xml.XmlDocCollector), - None, Ident name, (4,4--5,40), + None, None, None, Ident name, (4,4--5,40), { LeadingKeyword = MemberVal ((5,4--5,10), (5,11--5,14)) WithKeyword = Some (5,27--5,31) diff --git a/tests/service/data/SyntaxTree/Member/SynTypeDefnWithAutoPropertyContainsTheRangeOfTheWithKeyword.fs.bsl b/tests/service/data/SyntaxTree/Member/SynTypeDefnWithAutoPropertyContainsTheRangeOfTheWithKeyword.fs.bsl index 0bef3c32697..c5a3db03d4d 100644 --- a/tests/service/data/SyntaxTree/Member/SynTypeDefnWithAutoPropertyContainsTheRangeOfTheWithKeyword.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/SynTypeDefnWithAutoPropertyContainsTheRangeOfTheWithKeyword.fs.bsl @@ -34,7 +34,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((3,4), FSharp.Compiler.Xml.XmlDocCollector), - None, Ident autoProp, (3,4--3,52), + None, None, None, Ident autoProp, (3,4--3,52), { LeadingKeyword = MemberVal ((3,4--3,10), (3,11--3,14)) WithKeyword = Some (3,39--3,43) @@ -56,7 +56,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, Ident autoProp, (4,4--4,39), + None, None, None, Ident autoProp, (4,4--4,39), { LeadingKeyword = MemberVal ((4,4--4,10), (4,11--4,14)) WithKeyword = None diff --git a/tests/service/data/SyntaxTree/MemberFlag/SynMemberDefnAutoPropertyHasCorrectKeyword.fs.bsl b/tests/service/data/SyntaxTree/MemberFlag/SynMemberDefnAutoPropertyHasCorrectKeyword.fs.bsl index f3b34e63689..67858fd3916 100644 --- a/tests/service/data/SyntaxTree/MemberFlag/SynMemberDefnAutoPropertyHasCorrectKeyword.fs.bsl +++ b/tests/service/data/SyntaxTree/MemberFlag/SynMemberDefnAutoPropertyHasCorrectKeyword.fs.bsl @@ -28,7 +28,8 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((3,4), FSharp.Compiler.Xml.XmlDocCollector), - None, Const (Int32 1, (3,32--3,33)), (3,4--3,33), + None, None, None, Const (Int32 1, (3,32--3,33)), + (3,4--3,33), { LeadingKeyword = StaticMemberVal ((3,4--3,10), (3,11--3,17), (3,18--3,21)) @@ -51,7 +52,8 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, Const (Int32 1, (4,25--4,26)), (4,4--4,26), + None, None, None, Const (Int32 1, (4,25--4,26)), + (4,4--4,26), { LeadingKeyword = MemberVal ((4,4--4,10), (4,11--4,14)) WithKeyword = None @@ -73,7 +75,8 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((5,4), FSharp.Compiler.Xml.XmlDocCollector), - None, Const (Int32 2, (5,27--5,28)), (5,4--5,28), + None, None, None, Const (Int32 2, (5,27--5,28)), + (5,4--5,28), { LeadingKeyword = OverrideVal ((5,4--5,12), (5,13--5,16)) WithKeyword = None @@ -95,7 +98,8 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((6,4), FSharp.Compiler.Xml.XmlDocCollector), - None, Const (Int32 1, (6,26--6,27)), (6,4--6,27), + None, None, None, Const (Int32 1, (6,26--6,27)), + (6,4--6,27), { LeadingKeyword = DefaultVal ((6,4--6,11), (6,12--6,15)) WithKeyword = None From 2a7de3dea73bd308f3289ba95440ee236e88dce6 Mon Sep 17 00:00:00 2001 From: Petr Date: Thu, 7 Mar 2024 18:17:35 +0100 Subject: [PATCH 04/14] Revert "Allow access modifiers to auto properties getters and setters (#16687)" This reverts commit c4f7bed26a7ca45beef43f5550a4a3d6560ca31e. --- .../.FSharp.Compiler.Service/8.0.300.md | 1 - docs/release-notes/.Language/preview.md | 1 - src/Compiler/Checking/CheckDeclarations.fs | 52 +---- src/Compiler/FSComp.txt | 4 +- src/Compiler/Facilities/LanguageFeatures.fs | 4 - src/Compiler/Facilities/LanguageFeatures.fsi | 1 - src/Compiler/Service/ServiceNavigation.fs | 14 +- src/Compiler/SyntaxTree/ParseHelpers.fs | 4 +- src/Compiler/SyntaxTree/ParseHelpers.fsi | 2 +- src/Compiler/SyntaxTree/SyntaxTree.fs | 2 - src/Compiler/SyntaxTree/SyntaxTree.fsi | 2 - src/Compiler/pars.fsy | 52 +++-- src/Compiler/xlf/FSComp.txt.cs.xlf | 10 - src/Compiler/xlf/FSComp.txt.de.xlf | 10 - src/Compiler/xlf/FSComp.txt.es.xlf | 10 - src/Compiler/xlf/FSComp.txt.fr.xlf | 10 - src/Compiler/xlf/FSComp.txt.it.xlf | 10 - src/Compiler/xlf/FSComp.txt.ja.xlf | 10 - src/Compiler/xlf/FSComp.txt.ko.xlf | 10 - src/Compiler/xlf/FSComp.txt.pl.xlf | 10 - src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 10 - src/Compiler/xlf/FSComp.txt.ru.xlf | 10 - src/Compiler/xlf/FSComp.txt.tr.xlf | 10 - src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 10 - src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 10 - .../AutoPropsWithModifierBeforeGetSet.fs | 177 ------------------ .../FSharp.Compiler.ComponentTests.fsproj | 1 - ...vice.SurfaceArea.netstandard20.release.bsl | 6 +- .../LeadingKeyword/DefaultValKeyword.fs.bsl | 3 +- .../LeadingKeyword/MemberValKeyword.fs.bsl | 3 +- .../LeadingKeyword/OverrideValKeyword.fs.bsl | 3 +- .../StaticMemberValKeyword.fs.bsl | 3 +- .../SyntaxTree/Member/Auto property 01.fs.bsl | 3 +- .../SyntaxTree/Member/Auto property 02.fs.bsl | 2 +- .../SyntaxTree/Member/Auto property 03.fs.bsl | 5 +- .../SyntaxTree/Member/Auto property 04.fs.bsl | 6 +- .../SyntaxTree/Member/Auto property 05.fs.bsl | 6 +- .../SyntaxTree/Member/Auto property 06.fs.bsl | 3 +- .../SyntaxTree/Member/Auto property 07.fs.bsl | 3 +- .../SyntaxTree/Member/Auto property 08.fs.bsl | 5 +- .../SyntaxTree/Member/Auto property 09.fs.bsl | 5 +- .../SyntaxTree/Member/Auto property 10.fs.bsl | 5 +- .../SyntaxTree/Member/Auto property 11.fs.bsl | 3 +- .../SyntaxTree/Member/Auto property 12.fs.bsl | 3 +- .../SyntaxTree/Member/Auto property 13.fs.bsl | 3 +- .../SyntaxTree/Member/Auto property 14.fs | 4 - .../SyntaxTree/Member/Auto property 14.fs.bsl | 56 ------ .../SyntaxTree/Member/Auto property 15.fs | 4 - .../SyntaxTree/Member/Auto property 15.fs.bsl | 56 ------ ...ertyContainsTheRangeOfTheEqualsSign.fs.bsl | 2 +- ...rtyContainsTheRangeOfTheWithKeyword.fs.bsl | 4 +- ...erDefnAutoPropertyHasCorrectKeyword.fs.bsl | 12 +- 52 files changed, 67 insertions(+), 588 deletions(-) delete mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/MemberDefinitions/MethodsAndProperties/AutoPropsWithModifierBeforeGetSet.fs delete mode 100644 tests/service/data/SyntaxTree/Member/Auto property 14.fs delete mode 100644 tests/service/data/SyntaxTree/Member/Auto property 14.fs.bsl delete mode 100644 tests/service/data/SyntaxTree/Member/Auto property 15.fs delete mode 100644 tests/service/data/SyntaxTree/Member/Auto property 15.fs.bsl diff --git a/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md b/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md index 2473966f72a..148f3734185 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md +++ b/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md @@ -26,7 +26,6 @@ * Add switch to generate types and members with IL visibility that accurately represents their F# visibility. ([PR #15484](https://github.com/dotnet/fsharp/pull/15484) * Allow returning bool instead of unit option for partial active patterns. ([Language suggestion #1041](https://github.com/fsharp/fslang-suggestions/issues/1041), [PR #16473](https://github.com/dotnet/fsharp/pull/16473)) * Symbols: Add GenericArguments to FSharpEntity ([PR #16470](https://github.com/dotnet/fsharp/pull/16470)) -* Allow access modifies to auto properties getters and setters ([PR 16687](https://github.com/dotnet/fsharp/pull/16687), [Language suggestion #430](https://github.com/fsharp/fslang-suggestions/issues/430)) ### Changed diff --git a/docs/release-notes/.Language/preview.md b/docs/release-notes/.Language/preview.md index 0e34b389ef0..eb7ddd08e54 100644 --- a/docs/release-notes/.Language/preview.md +++ b/docs/release-notes/.Language/preview.md @@ -5,7 +5,6 @@ * Bidirectional F#/C# interop for 'unmanaged' constraint. ([PR #12154](https://github.com/dotnet/fsharp/pull/12154)) * Make `.Is*` discriminated union properties visible. ([Language suggestion #222](https://github.com/fsharp/fslang-suggestions/issues/222), [PR #16341](https://github.com/dotnet/fsharp/pull/16341)) * Allow returning bool instead of unit option for partial active patterns. ([Language suggestion #1041](https://github.com/fsharp/fslang-suggestions/issues/1041), [PR #16473](https://github.com/dotnet/fsharp/pull/16473)) -* Allow access modifies to auto properties getters and setters ([PR 16687](https://github.com/dotnet/fsharp/pull/16687), [Language suggestion #430](https://github.com/fsharp/fslang-suggestions/issues/430)) ### Fixed diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index f02ccdff9a4..457a3489576 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -4309,7 +4309,7 @@ module TcDeclarations = | _ -> () /// Split auto-properties into 'let' and 'member' bindings - let private SplitAutoProps (g: TcGlobals) members = + let private SplitAutoProps members = let membersIncludingAutoProps, vals_Inherits_Abstractslots = members |> List.partition (fun memb -> match memb with @@ -4359,7 +4359,7 @@ module TcDeclarations = let rec postAutoProps memb = match memb with | SynMemberDefn.AutoProperty(ident = id) when String.IsNullOrEmpty(id.idText) -> [] - | SynMemberDefn.AutoProperty(attributes=Attributes attribs; isStatic=isStatic; ident=id; typeOpt=tyOpt; propKind=propKind; memberFlags=memberFlags; memberFlagsForSet=memberFlagsForSet; xmlDoc=xmlDoc; trivia = { GetSetKeywords = mGetSetOpt }; accessibility = access; getterAccessibility = getterAccess; setterAccessibility = setterAccess) -> + | SynMemberDefn.AutoProperty(attributes=Attributes attribs; isStatic=isStatic; ident=id; typeOpt=tyOpt; propKind=propKind; memberFlags=memberFlags; memberFlagsForSet=memberFlagsForSet; xmlDoc=xmlDoc; accessibility=access; trivia = { GetSetKeywords = 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) @@ -4372,41 +4372,7 @@ module TcDeclarations = match propKind, mGetSetOpt with | SynMemberKind.PropertySet, Some getSetKeywords -> errorR(Error(FSComp.SR.parsMutableOnAutoPropertyShouldBeGetSetNotJustSet(), getSetKeywords.Range)) | _ -> () - - let getterAccess, setterAccess = - match propKind with - | SynMemberKind.PropertyGetSet -> - match access with - | Some _ -> - match getterAccess, setterAccess with - | None, None -> access, access - | Some x, _ - | _, Some x -> - errorR(Error(FSComp.SR.parsMultipleAccessibilitiesForGetSet(), x.Range)) - None, None - | None -> - match getterAccess, setterAccess with - | Some x, _ - | _, Some x -> - checkLanguageFeatureAndRecover g.langVersion LanguageFeature.AllowAccessModifiersToAutoPropertiesGettersAndSetters x.Range - getterAccess, setterAccess - | _, _ -> None, None - | SynMemberKind.PropertySet -> - match access, setterAccess with - | Some _, Some x -> - errorR(Error(FSComp.SR.parsMultipleAccessibilitiesForGetSet(), x.Range)) - None, None - | _, None -> None, access - | None, _ -> None, setterAccess - | SynMemberKind.Member - | SynMemberKind.PropertyGet - | _ -> - match access, getterAccess with - | Some _, Some x -> - errorR(Error(FSComp.SR.parsMultipleAccessibilitiesForGetSet(), x.Range)) - None, None - | _, None -> access, None - | None, _ -> getterAccess, None + [ match propKind with | SynMemberKind.Member @@ -4416,7 +4382,7 @@ module TcDeclarations = let rhsExpr = SynExpr.Ident fldId let retInfo = match tyOpt with None -> None | Some ty -> Some (None, SynReturnInfo((ty, SynInfo.unnamedRetVal), ty.Range)) let attribs = mkAttributeList attribs mMemberPortion - let binding = mkSynBinding (xmlDoc, headPat) (getterAccess, false, false, mMemberPortion, DebugPointAtBinding.NoneAtInvisible, retInfo, rhsExpr, rhsExpr.Range, [], attribs, Some memberFlags, SynBindingTrivia.Zero) + let binding = mkSynBinding (xmlDoc, headPat) (access, false, false, mMemberPortion, DebugPointAtBinding.NoneAtInvisible, retInfo, rhsExpr, rhsExpr.Range, [], attribs, Some memberFlags, SynBindingTrivia.Zero) SynMemberDefn.Member (binding, mMemberPortion) yield getter | _ -> () @@ -4428,7 +4394,7 @@ module TcDeclarations = let vId = ident("v", mMemberPortion) let headPat = SynPat.LongIdent (SynLongIdent(headPatIds, [], List.replicate headPatIds.Length None), None, Some noInferredTypars, SynArgPats.Pats [mkSynPatVar None vId], None, mMemberPortion) let rhsExpr = mkSynAssign (SynExpr.Ident fldId) (SynExpr.Ident vId) - let binding = mkSynBinding (xmlDoc, headPat) (setterAccess, false, false, mMemberPortion, DebugPointAtBinding.NoneAtInvisible, None, rhsExpr, rhsExpr.Range, [], [], Some memberFlagsForSet, SynBindingTrivia.Zero) + let binding = mkSynBinding (xmlDoc, headPat) (access, false, false, mMemberPortion, DebugPointAtBinding.NoneAtInvisible, None, rhsExpr, rhsExpr.Range, [], [], Some memberFlagsForSet, SynBindingTrivia.Zero) SynMemberDefn.Member (binding, mMemberPortion) yield setter | _ -> ()] @@ -4452,9 +4418,9 @@ module TcDeclarations = /// where simpleRepr can contain inherit type, declared fields and virtual slots. /// body = members /// where members contain methods/overrides, also implicit ctor, inheritCall and local definitions. - let rec private SplitTyconDefn g (SynTypeDefn(typeInfo=synTyconInfo;typeRepr=trepr; members=extraMembers)) = + let rec private SplitTyconDefn (SynTypeDefn(typeInfo=synTyconInfo;typeRepr=trepr; members=extraMembers)) = let extraMembers = desugarGetSetMembers extraMembers - let extraMembers, extra_vals_Inherits_Abstractslots = SplitAutoProps g extraMembers + let extraMembers, extra_vals_Inherits_Abstractslots = SplitAutoProps extraMembers let implements1 = extraMembers |> List.choose (function SynMemberDefn.Interface (interfaceType=ty) -> Some(ty, ty.Range) | _ -> None) match trepr with @@ -4475,7 +4441,7 @@ module TcDeclarations = let slotsigs = members |> List.choose (function SynMemberDefn.AbstractSlot (slotSig = x; flags = y) -> Some(x, y) | _ -> None) - let members,_vals_Inherits_Abstractslots = SplitAutoProps g members + let members,_vals_Inherits_Abstractslots = SplitAutoProps members let isConcrete = members |> List.exists (function @@ -4537,7 +4503,7 @@ module TcDeclarations = // Split the definitions into "core representations" and "members". The code to process core representations // is shared between processing of signature files and implementation files. - let mutRecDefnsAfterSplit = mutRecDefns |> MutRecShapes.mapTycons (fun i -> SplitTyconDefn g i) + let mutRecDefnsAfterSplit = mutRecDefns |> MutRecShapes.mapTycons SplitTyconDefn // Create the entities for each module and type definition, and process the core representation of each type definition. let tycons, envMutRecPrelim, mutRecDefnsAfterCore = diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 61e280428b2..5846712049b 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1746,6 +1746,4 @@ featureReuseSameFieldsInStructUnions,"Share underlying fields in a [] di 3862,parsStaticMemberImcompleteSyntax,"Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration." 3863,parsExpectingField,"Expecting record field" 3864,tooManyMethodsInDotNetTypeWritingAssembly,"The type '%s' has too many methods. Found: '%d', maximum: '%d'" -3865,parsOnlySimplePatternsAreAllowedInConstructors,"Only simple patterns are allowed in primary constructors" -featureAllowAccessModifiersToAutoPropertiesGettersAndSetters,"Allow access modifiers to auto properties getters and setters" -3866,parsAccessModifiersBeforeGettersAndSettersNotAllowedInSigFile,"The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file." \ No newline at end of file +3865,parsOnlySimplePatternsAreAllowedInConstructors,"Only simple patterns are allowed in primary constructors" \ No newline at end of file diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index f18f41d7e56..3103d8b159e 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -85,7 +85,6 @@ type LanguageFeature = | WarningIndexedPropertiesGetSetSameType | WarningWhenTailCallAttrOnNonRec | BooleanReturningAndReturnTypeDirectedPartialActivePattern - | AllowAccessModifiersToAutoPropertiesGettersAndSetters | EnforceAttributeTargetsOnFunctions | EnforceAttributeTargetsUnionCaseDeclarations | LowerInterpolatedStringToConcat @@ -202,7 +201,6 @@ type LanguageVersion(versionText) = LanguageFeature.WarningWhenTailCallAttrOnNonRec, previewVersion LanguageFeature.UnionIsPropertiesVisible, previewVersion LanguageFeature.BooleanReturningAndReturnTypeDirectedPartialActivePattern, previewVersion - LanguageFeature.AllowAccessModifiersToAutoPropertiesGettersAndSetters, previewVersion LanguageFeature.EnforceAttributeTargetsOnFunctions, previewVersion LanguageFeature.EnforceAttributeTargetsUnionCaseDeclarations, previewVersion LanguageFeature.LowerInterpolatedStringToConcat, previewVersion @@ -350,8 +348,6 @@ type LanguageVersion(versionText) = | LanguageFeature.WarningWhenTailCallAttrOnNonRec -> FSComp.SR.featureChkTailCallAttrOnNonRec () | LanguageFeature.BooleanReturningAndReturnTypeDirectedPartialActivePattern -> FSComp.SR.featureBooleanReturningAndReturnTypeDirectedPartialActivePattern () - | LanguageFeature.AllowAccessModifiersToAutoPropertiesGettersAndSetters -> - FSComp.SR.featureAllowAccessModifiersToAutoPropertiesGettersAndSetters () | LanguageFeature.EnforceAttributeTargetsOnFunctions -> FSComp.SR.featureEnforceAttributeTargetsOnFunctions () | LanguageFeature.EnforceAttributeTargetsUnionCaseDeclarations -> FSComp.SR.featureEnforceAttributeTargetsUnionCaseDeclarations () | LanguageFeature.LowerInterpolatedStringToConcat -> FSComp.SR.featureLowerInterpolatedStringToConcat () diff --git a/src/Compiler/Facilities/LanguageFeatures.fsi b/src/Compiler/Facilities/LanguageFeatures.fsi index 84913760e68..4f0fe835ffa 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fsi +++ b/src/Compiler/Facilities/LanguageFeatures.fsi @@ -76,7 +76,6 @@ type LanguageFeature = | WarningIndexedPropertiesGetSetSameType | WarningWhenTailCallAttrOnNonRec | BooleanReturningAndReturnTypeDirectedPartialActivePattern - | AllowAccessModifiersToAutoPropertiesGettersAndSetters | EnforceAttributeTargetsOnFunctions | EnforceAttributeTargetsUnionCaseDeclarations | LowerInterpolatedStringToConcat diff --git a/src/Compiler/Service/ServiceNavigation.fs b/src/Compiler/Service/ServiceNavigation.fs index bb118ae2c76..03afe63b373 100755 --- a/src/Compiler/Service/ServiceNavigation.fs +++ b/src/Compiler/Service/ServiceNavigation.fs @@ -332,19 +332,9 @@ module NavigationImpl = [ createMember (rcid, NavigationItemKind.Field, FSharpGlyph.Field, range, enclosingEntityKind, false, access) ] - | SynMemberDefn.AutoProperty( - ident = id; accessibility = access; getterAccessibility = getterAccessibility; setterAccessibility = setterAccessibility; propKind = propKind) -> - let getterAccessibility = getterAccessibility |> Option.orElse access - let setterAccessibility = setterAccessibility |> Option.orElse access - + | SynMemberDefn.AutoProperty(ident = id; accessibility = access) -> [ - match propKind with - | SynMemberKind.PropertyGetSet -> - yield createMember (id, NavigationItemKind.Field, FSharpGlyph.Field, id.idRange, enclosingEntityKind, false, getterAccessibility) - yield createMember (id, NavigationItemKind.Field, FSharpGlyph.Field, id.idRange, enclosingEntityKind, false, setterAccessibility) - | SynMemberKind.PropertySet -> - yield createMember (id, NavigationItemKind.Field, FSharpGlyph.Field, id.idRange, enclosingEntityKind, false, setterAccessibility) - | _ -> yield createMember (id, NavigationItemKind.Field, FSharpGlyph.Field, id.idRange, enclosingEntityKind, false, getterAccessibility) + createMember (id, NavigationItemKind.Field, FSharpGlyph.Field, id.idRange, enclosingEntityKind, false, access) ] | SynMemberDefn.AbstractSlot(slotSig = SynValSig(ident = SynIdent(id, _); synType = ty; accessibility = access)) -> [ diff --git a/src/Compiler/SyntaxTree/ParseHelpers.fs b/src/Compiler/SyntaxTree/ParseHelpers.fs index b1d44984aaa..d90e395c0c9 100644 --- a/src/Compiler/SyntaxTree/ParseHelpers.fs +++ b/src/Compiler/SyntaxTree/ParseHelpers.fs @@ -1101,7 +1101,7 @@ let mkSynUnionCase attributes (access: SynAccess option) id kind mDecl (xmlDoc, SynUnionCase(attributes, id, kind, xmlDoc, None, mDecl, trivia) let mkAutoPropDefn mVal access ident typ mEquals (expr: SynExpr) accessors xmlDoc attribs flags rangeStart = - let mWith, (getSet, getSetOpt, getterAccess, setterAccess) = accessors + let mWith, (getSet, getSetOpt) = accessors let memberRange = match getSetOpt with @@ -1135,8 +1135,6 @@ let mkAutoPropDefn mVal access ident typ mEquals (expr: SynExpr) accessors xmlDo memberFlagsForSet, xmlDoc, access, - getterAccess, - setterAccess, expr, memberRange, trivia diff --git a/src/Compiler/SyntaxTree/ParseHelpers.fsi b/src/Compiler/SyntaxTree/ParseHelpers.fsi index 52f4257d4c2..a8d61f3cb7e 100644 --- a/src/Compiler/SyntaxTree/ParseHelpers.fsi +++ b/src/Compiler/SyntaxTree/ParseHelpers.fsi @@ -272,7 +272,7 @@ val mkAutoPropDefn: typ: SynType option -> mEquals: range option -> expr: SynExpr -> - accessors: range option * (SynMemberKind * GetSetKeywords option * SynAccess option * SynAccess option) -> + accessors: range option * (SynMemberKind * GetSetKeywords option) -> xmlDoc: PreXmlDoc -> attribs: SynAttributes -> flags: (SynMemberKind -> SynMemberFlags) * SynLeadingKeyword -> diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fs b/src/Compiler/SyntaxTree/SyntaxTree.fs index a4ba8c601f4..8b034740be4 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fs +++ b/src/Compiler/SyntaxTree/SyntaxTree.fs @@ -1463,8 +1463,6 @@ type SynMemberDefn = memberFlagsForSet: SynMemberFlags * xmlDoc: PreXmlDoc * accessibility: SynAccess option * - getterAccessibility: SynAccess option * - setterAccessibility: SynAccess option * synExpr: SynExpr * range: range * trivia: SynMemberDefnAutoPropertyTrivia diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fsi b/src/Compiler/SyntaxTree/SyntaxTree.fsi index 2f1d1d5776c..3d9ef06dcad 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTree.fsi @@ -1656,8 +1656,6 @@ type SynMemberDefn = memberFlagsForSet: SynMemberFlags * xmlDoc: PreXmlDoc * accessibility: SynAccess option * - getterAccessibility: SynAccess option * - setterAccessibility: SynAccess option * synExpr: SynExpr * range: range * trivia: SynMemberDefnAutoPropertyTrivia diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index b8871f5a270..4080fc7ec8b 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -949,14 +949,7 @@ classMemberSpfn: | opt_attributes opt_access memberSpecFlags opt_inline opt_access nameop opt_explicitValTyparDecls COLON topTypeWithTypeConstraints classMemberSpfnGetSet optLiteralValueSpfn { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(), rhs parseState 2)) let isInline, doc, vis2, id, explicitValTyparDecls, (ty, arity), (mEquals, optLiteralValue) = (Option.isSome $4), grabXmlDoc(parseState, $1, 1), $5, $6, $7, $9, $11 - let mWith, (getSet, getSetRangeOpt, getterAccess, setterAccess) = $10 - match getterAccess with - | Some(x: SynAccess) -> warning(Error(FSComp.SR.parsAccessModifiersBeforeGettersAndSettersNotAllowedInSigFile(), x.Range)) - | _ -> () - match setterAccess with - | Some(x: SynAccess) -> warning(Error(FSComp.SR.parsAccessModifiersBeforeGettersAndSettersNotAllowedInSigFile(), x.Range)) - | _ -> () - + let mWith, (getSet, getSetRangeOpt) = $10 let getSetAdjuster arity = match arity, getSet with SynValInfo([], _), SynMemberKind.Member -> SynMemberKind.PropertyGet | _ -> getSet let mWhole = let m = rhs parseState 3 @@ -1028,7 +1021,7 @@ classMemberSpfn: /* The optional "with get, set" on a member in a signature */ classMemberSpfnGetSet: | /* EMPTY */ - { None, (SynMemberKind.Member, None, None, None) } + { None, (SynMemberKind.Member, None) } | WITH classMemberSpfnGetSetElements { let mWith = rhs parseState 1 @@ -1046,39 +1039,39 @@ classMemberSpfnGetSet: /* The "get, set" on a property member in a signature */ classMemberSpfnGetSetElements: - | opt_access nameop - { (let (SynIdent(id:Ident, _)) = $2 + | nameop + { (let (SynIdent(id:Ident, _)) = $1 if id.idText = "get" then - SynMemberKind.PropertyGet, Some(GetSetKeywords.Get id.idRange), $1, None + SynMemberKind.PropertyGet, Some(GetSetKeywords.Get id.idRange) else if id.idText = "set" then - SynMemberKind.PropertySet, Some(GetSetKeywords.Set id.idRange), None, $1 + SynMemberKind.PropertySet, Some(GetSetKeywords.Set id.idRange) else raiseParseErrorAt (rhs parseState 1) (FSComp.SR.parsGetOrSetRequired())) } - | opt_access nameop COMMA opt_access nameop - { let (SynIdent(id, _)) = $2 - let (SynIdent(id2, _)) = $5 + | nameop COMMA nameop + { let (SynIdent(id, _)) = $1 + let (SynIdent(id2, _)) = $3 if not ((id.idText = "get" && id2.idText = "set") || (id.idText = "set" && id2.idText = "get")) then raiseParseErrorAt (rhs2 parseState 1 3) (FSComp.SR.parsGetOrSetRequired()) if id.idText = "get" then - SynMemberKind.PropertyGetSet, Some(GetSetKeywords.GetSet(id.idRange, id2.idRange)), $1, $4 + SynMemberKind.PropertyGetSet, Some(GetSetKeywords.GetSet(id.idRange, id2.idRange)) else - SynMemberKind.PropertyGetSet, Some(GetSetKeywords.GetSet(id2.idRange, id.idRange)), $4, $1 } + SynMemberKind.PropertyGetSet, Some(GetSetKeywords.GetSet(id2.idRange, id.idRange)) } - | opt_access nameop COMMA recover - { (let (SynIdent(id:Ident, _)) = $2 + | nameop COMMA recover + { (let (SynIdent(id:Ident, _)) = $1 if id.idText = "get" then - SynMemberKind.PropertyGet, Some(GetSetKeywords.Get id.idRange), $1, None + SynMemberKind.PropertyGet, Some(GetSetKeywords.Get id.idRange) else if id.idText = "set" then - SynMemberKind.PropertySet, Some(GetSetKeywords.Set id.idRange), None, $1 + SynMemberKind.PropertySet, Some(GetSetKeywords.Set id.idRange) else - raiseParseErrorAt (rhs parseState 2) (FSComp.SR.parsGetOrSetRequired())) } + raiseParseErrorAt (rhs parseState 1) (FSComp.SR.parsGetOrSetRequired())) } | OBLOCKBEGIN oblockend ODECLEND { reportParseErrorAt (rhs parseState 1) (FSComp.SR.parsIdentifierExpected()) - SynMemberKind.Member, None, None, None } + SynMemberKind.Member, None } memberSpecFlags: | memberFlags { $1 } @@ -2041,7 +2034,7 @@ classDefnMember: | opt_attributes opt_access abstractMemberFlags opt_inline nameop opt_explicitValTyparDecls COLON topTypeWithTypeConstraints classMemberSpfnGetSet opt_ODECLEND { let ty, arity = $8 let isInline, doc, id, explicitValTyparDecls = (Option.isSome $4), grabXmlDoc(parseState, $1, 1), $5, $6 - let mWith, (getSet, getSetRangeOpt, getterAccess, setterAccess) = $9 + let mWith, (getSet, getSetRangeOpt) = $9 let getSetAdjuster arity = match arity, getSet with SynValInfo([], _), SynMemberKind.Member -> SynMemberKind.PropertyGet | _ -> getSet let mWhole = let m = rhs parseState 1 @@ -2049,8 +2042,7 @@ classDefnMember: | None -> unionRanges m ty.Range | Some gs -> unionRanges m gs.Range |> unionRangeWithXmlDoc doc - if Option.isSome $2 || Option.isSome getterAccess || Option.isSome setterAccess - then errorR(Error(FSComp.SR.parsAccessibilityModsIllegalForAbstract(), mWhole)) + if Option.isSome $2 then errorR(Error(FSComp.SR.parsAccessibilityModsIllegalForAbstract(), mWhole)) let mkFlags, leadingKeyword = $3 let trivia = { LeadingKeyword = leadingKeyword; InlineKeyword = $4; WithKeyword = mWith; EqualsRange = None } let valSpfn = SynValSig($1, id, explicitValTyparDecls, ty, arity, isInline, false, doc, None, None, mWhole, trivia) @@ -2189,7 +2181,7 @@ autoPropsDefnDecl: errorR (Error(FSComp.SR.parsMutableOnAutoPropertyShouldBeGetSet (), rhs parseState 2)) fun attribs flags rangeStart -> let xmlDoc = grabXmlDocAtRangeStart (parseState, attribs, rangeStart) - [ mkAutoPropDefn mVal $3 $4 $5 None expr (None, (SynMemberKind.Member, None, None, None)) xmlDoc attribs flags rangeStart ] } + [ mkAutoPropDefn mVal $3 $4 $5 None expr (None, (SynMemberKind.Member, None)) xmlDoc attribs flags rangeStart ] } | VAL opt_mutable opt_access ident opt_typ OBLOCKSEP { let mVal = rhs parseState 1 @@ -2202,7 +2194,7 @@ autoPropsDefnDecl: errorR (Error(FSComp.SR.parsMutableOnAutoPropertyShouldBeGetSet (), rhs parseState 2)) fun attribs flags rangeStart -> let xmlDoc = grabXmlDocAtRangeStart (parseState, attribs, rangeStart) - [ mkAutoPropDefn mVal $3 $4 $5 None expr (None, (SynMemberKind.Member, None, None, None)) xmlDoc attribs flags rangeStart ] } + [ mkAutoPropDefn mVal $3 $4 $5 None expr (None, (SynMemberKind.Member, None)) xmlDoc attribs flags rangeStart ] } | VAL opt_mutable opt_access recover { let mVal = rhs parseState 1 @@ -2212,7 +2204,7 @@ autoPropsDefnDecl: errorR (Error(FSComp.SR.parsMutableOnAutoPropertyShouldBeGetSet (), rhs parseState 2)) fun attribs flags rangeStart -> let xmlDoc = grabXmlDocAtRangeStart(parseState, attribs, rangeStart) - [ mkAutoPropDefn mVal $3 id None None expr (None, (SynMemberKind.Member, None, None, None)) xmlDoc attribs flags rangeStart ] } + [ mkAutoPropDefn mVal $3 id None None expr (None, (SynMemberKind.Member, None)) xmlDoc attribs flags rangeStart ] } /* An optional type on an auto-property definition */ opt_typ: diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 509c8bd4ad7..66205091123 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -227,11 +227,6 @@ další převody orientované na typ - - Allow access modifiers to auto properties getters and setters - Allow access modifiers to auto properties getters and setters - - applicative computation expressions aplikativní výpočetní výrazy @@ -912,11 +907,6 @@ Funkce správy balíčků vyžaduje jazykovou verzi 5.0 nebo vyšší. - - The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. - The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. - - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. Syntaxi průniku omezení lze použít pouze s flexibilními typy, například „#IDisposable a #ISomeInterface“. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 2635ea818f1..f72b6948a76 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -227,11 +227,6 @@ zusätzliche typgesteuerte Konvertierungen - - Allow access modifiers to auto properties getters and setters - Allow access modifiers to auto properties getters and setters - - applicative computation expressions applikative Berechnungsausdrücke @@ -912,11 +907,6 @@ Für das „Paketverwaltungsfeature“ ist Sprachversion 5.0 oder höher erforderlich - - The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. - The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. - - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. Die Einschränkungsüberschneidungssyntax kann nur mit flexiblen Typen verwendet werden, z. B. "#IDisposable & #ISomeInterface". diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 3c81bed6124..12f4457f73e 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -227,11 +227,6 @@ conversiones adicionales dirigidas a tipos - - Allow access modifiers to auto properties getters and setters - Allow access modifiers to auto properties getters and setters - - applicative computation expressions expresiones de cálculo aplicativas @@ -912,11 +907,6 @@ La característica de "administración de paquetes" requiere la versión de lenguaje 5.0 o superior - - The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. - The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. - - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. La sintaxis de intersección de restricciones solo se puede usar con tipos flexibles, por ejemplo, "#IDisposable &#ISomeInterface". diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 5162b04d3d8..9477b8b7680 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -227,11 +227,6 @@ conversions supplémentaires dirigées vers le type - - Allow access modifiers to auto properties getters and setters - Allow access modifiers to auto properties getters and setters - - applicative computation expressions expressions de calcul applicatives @@ -912,11 +907,6 @@ La fonction « gestion des paquets » nécessite une version de langue 5.0 ou supérieure. - - The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. - The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. - - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. La syntaxe d'intersection de contraintes ne peut être utilisée qu'avec des types flexibles, par ex. '#IDisposable et #ISomeInterface'. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 4050b14cf7f..b17ab37848d 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -227,11 +227,6 @@ conversioni aggiuntive dirette ai tipi - - Allow access modifiers to auto properties getters and setters - Allow access modifiers to auto properties getters and setters - - applicative computation expressions espressioni di calcolo applicativo @@ -912,11 +907,6 @@ La funzionalità 'gestione pacchetti' richiede la versione del linguaggio 5.0 o superiore - - The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. - The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. - - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. La sintassi dell'intersezione dei vincoli può essere usata solo con tipi flessibili, ad esempio '#IDisposable & #ISomeInterface'. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 2f30491d680..fa6fb18bda6 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -227,11 +227,6 @@ その他の型指定された変換 - - Allow access modifiers to auto properties getters and setters - Allow access modifiers to auto properties getters and setters - - applicative computation expressions 適用できる計算式 @@ -912,11 +907,6 @@ 'package management' (パッケージ管理) 機能には、言語バージョン 5.0 以降が必要です - - The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. - The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. - - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. 制約交差構文は、"#IDisposable & #ISomeInterface" など、柔軟な型でのみ使用できます。 diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 9340410bcba..1cf38ecd52e 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -227,11 +227,6 @@ 추가 형식-디렉션 변환 - - Allow access modifiers to auto properties getters and setters - Allow access modifiers to auto properties getters and setters - - applicative computation expressions 적용 가능한 계산 식 @@ -912,11 +907,6 @@ '패키지 관리' 기능을 사용하려면 언어 버전 5.0 이상이 필요합니다. - - The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. - The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. - - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. 제약 조건 교차 구문은 유연한 형식(예: '#IDisposable &#ISomeInterface')에서만 사용할 수 있습니다. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 5452bcebf00..a36f1d7cb51 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -227,11 +227,6 @@ dodatkowe konwersje ukierunkowane na typ - - Allow access modifiers to auto properties getters and setters - Allow access modifiers to auto properties getters and setters - - applicative computation expressions praktyczne wyrażenia obliczeniowe @@ -912,11 +907,6 @@ Funkcja „Zarządzanie pakietami” wymaga języka w wersji 5.0 lub nowszej - - The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. - The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. - - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. Składnia przecięcia ograniczenia może być używana tylko z typami elastycznymi, np. „#IDisposable &#ISomeInterface”. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index f90d3d8fa12..129e7cb792e 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -227,11 +227,6 @@ conversões direcionadas por tipos adicionais - - Allow access modifiers to auto properties getters and setters - Allow access modifiers to auto properties getters and setters - - applicative computation expressions expressões de computação aplicáveis @@ -912,11 +907,6 @@ O recurso 'gerenciamento de pacotes' requer a versão 5.0 ou superior do idioma - - The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. - The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. - - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. A sintaxe de interseção de restrição só pode ser usada com tipos flexíveis, por exemplo, "#IDisposable & #ISomeInterface". diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index f4a2e807c60..d0acf9ef585 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -227,11 +227,6 @@ дополнительные преобразования на основе типа - - Allow access modifiers to auto properties getters and setters - Allow access modifiers to auto properties getters and setters - - applicative computation expressions применимые вычислительные выражения @@ -912,11 +907,6 @@ Для функции управления пакетами требуется версия языка 5.0 или более поздняя - - The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. - The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. - - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. Синтаксис пересечения ограничений можно использовать только с гибкими типами, например. "#IDisposable & #ISomeInterface". diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 940de471b10..555f737153e 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -227,11 +227,6 @@ ek tür ile yönlendirilen dönüştürmeler - - Allow access modifiers to auto properties getters and setters - Allow access modifiers to auto properties getters and setters - - applicative computation expressions uygulama hesaplama ifadeleri @@ -912,11 +907,6 @@ ‘Paket yönetimi’ özelliği, dil sürümü 5.0 veya üstünü gerektirir - - The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. - The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. - - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. Kısıtlama kesişimi söz dizimi yalnızca esnek türlerle kullanılabilir. Ör. '#IDisposable & #ISomeInterface'. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 30e6d6073c0..72e2ea8f447 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -227,11 +227,6 @@ 附加类型定向转换 - - Allow access modifiers to auto properties getters and setters - Allow access modifiers to auto properties getters and setters - - applicative computation expressions 适用的计算表达式 @@ -912,11 +907,6 @@ “包管理”功能需要语言版本 5.0 或更高版本 - - The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. - The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. - - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. 约束交集语法只能与灵活类型一起使用,例如 "#IDisposable & #ISomeInterface"。 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 8d79311a0dc..817e803623b 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -227,11 +227,6 @@ 其他類型導向轉換 - - Allow access modifiers to auto properties getters and setters - Allow access modifiers to auto properties getters and setters - - applicative computation expressions 適用的計算運算式 @@ -912,11 +907,6 @@ 「套件管理」功能需要語言版本 5.0 或更新版本 - - The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. - The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file. - - Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'. 條件約束交集語法只能搭配彈性類型使用,例如「#IDisposable 與 #ISomeInterface'」。 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/MemberDefinitions/MethodsAndProperties/AutoPropsWithModifierBeforeGetSet.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/MemberDefinitions/MethodsAndProperties/AutoPropsWithModifierBeforeGetSet.fs deleted file mode 100644 index 8e1703df5a2..00000000000 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/MemberDefinitions/MethodsAndProperties/AutoPropsWithModifierBeforeGetSet.fs +++ /dev/null @@ -1,177 +0,0 @@ -// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. - -module Conformance.BasicGrammarElements.AutoPropsWithModifierBeforeGetSet - -open Xunit -open FSharp.Test -open FSharp.Test.Compiler - -let verifyCompile compilation = - compilation - |> asExe - |> withOptions ["--nowarn:988"] - |> compile - -let verifyCompileAndRun compilation = - compilation - |> asExe - |> withOptions ["--nowarn:988"] - |> compileAndRun - -[] -let ``Instance Properties Test`` () = - Fs """type InstancePropertiesTest() = - member val B1: int = 0 with get - // should fail - member val B2: int = 0 with set - member val B3: int = 0 with get, set - member val B4: int = 0 with internal get - // should fail - member val B5: int = 0 with internal set - member val B6: int = 0 with internal get, internal set - member val B7: int = 0 with internal get, set - member val B8: int = 0 with get, internal set - // should fail - member val internal B11: int = 0 with internal get, set - // should fail - member val internal B12: int = 0 with internal get - // should fail - member val internal B13: int = 0 with internal set - member val internal B14: int = 0 with get, set - member val internal B15: int = 0 with get - // should fail - member val internal B16: int = 0 with set""" - |> withLangVersionPreview - |> typecheck - |> shouldFail - |> withDiagnostics [ - (Error 3135, Line 4, Col 33, Line 4, Col 36, "To indicate that this property can be set, use 'member val PropertyName = expr with get,set'.") - (Error 3135, Line 8, Col 42, Line 8, Col 45, "To indicate that this property can be set, use 'member val PropertyName = expr with get,set'.") - (Error 0558, Line 13, Col 43, Line 13, Col 51, "When the visibility for a property is specified, setting the visibility of the set or get method is not allowed.") - (Error 0558, Line 15, Col 43, Line 15, Col 51, "When the visibility for a property is specified, setting the visibility of the set or get method is not allowed.") - (Error 3135, Line 17, Col 52, Line 17, Col 55, "To indicate that this property can be set, use 'member val PropertyName = expr with get,set'.") - (Error 0558, Line 17, Col 43, Line 17, Col 51, "When the visibility for a property is specified, setting the visibility of the set or get method is not allowed.") - (Error 3135, Line 21, Col 43, Line 21, Col 46, "To indicate that this property can be set, use 'member val PropertyName = expr with get,set'.") - ] - -[] -let ``Static Properties Test`` () = - Fs """type StaticPropertiesTest() = - static member val B1: int = 0 with get - // should fail - static member val B2: int = 0 with set - static member val B3: int = 0 with get, set - static member val B4: int = 0 with internal get - // should fail - static member val B5: int = 0 with internal set - static member val B6: int = 0 with internal get, internal set - static member val B7: int = 0 with internal get, set - static member val B8: int = 0 with get, internal set - // should fail - static member val internal B11: int = 0 with internal get, set - // should fail - static member val internal B12: int = 0 with internal get - // should fail - static member val internal B13: int = 0 with internal set - static member val internal B14: int = 0 with get, set - static member val internal B15: int = 0 with get - // should fail - static member val internal B16: int = 0 with set""" - |> withLangVersionPreview - |> typecheck - |> shouldFail - |> withDiagnostics [ - (Error 3135, Line 4, Col 40, Line 4, Col 43, "To indicate that this property can be set, use 'member val PropertyName = expr with get,set'.") - (Error 3135, Line 8, Col 49, Line 8, Col 52, "To indicate that this property can be set, use 'member val PropertyName = expr with get,set'.") - (Error 0558, Line 13, Col 50, Line 13, Col 58, "When the visibility for a property is specified, setting the visibility of the set or get method is not allowed.") - (Error 0558, Line 15, Col 50, Line 15, Col 58, "When the visibility for a property is specified, setting the visibility of the set or get method is not allowed.") - (Error 3135, Line 17, Col 59, Line 17, Col 62, "To indicate that this property can be set, use 'member val PropertyName = expr with get,set'.") - (Error 0558, Line 17, Col 50, Line 17, Col 58, "When the visibility for a property is specified, setting the visibility of the set or get method is not allowed.") - (Error 3135, Line 21, Col 50, Line 21, Col 53, "To indicate that this property can be set, use 'member val PropertyName = expr with get,set'.") - ] - -[] -let ``Abstract Properties Test: access modifiers are not allowed`` () = - Fs """type ``Abstract Properties Test`` = - abstract member B1: int with get, set - abstract member B2: int with get - abstract member B3: int with set - // should fail - abstract member B4: int with internal get, set - // should fail - abstract member B5: int with get, internal set - // should fail - abstract member B6: int with internal get, internal set - // should fail - abstract member B7: int with internal get - // should fail - abstract member B8: int with internal set""" - |> withLangVersionPreview - |> typecheck - |> shouldFail - |> withDiagnostics [ - (Error 0561, Line 6, Col 5, Line 6, Col 51, "Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.") - (Error 0561, Line 8, Col 5, Line 8, Col 51, "Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.") - (Error 0561, Line 10, Col 5, Line 10, Col 60, "Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.") - (Error 0561, Line 12, Col 5, Line 12, Col 46, "Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.") - (Error 0561, Line 14, Col 5, Line 14, Col 46, "Accessibility modifiers are not allowed on this member. Abstract slots always have the same visibility as the enclosing type.") - ] - -[] -let ``Signature File Test: no access modifiers before getter and setter`` () = - Fsi """module Program - -type A = - new: unit -> A - member internal B: int - member internal C: int with get, set - // will warning - member D: int with internal get, private set - abstract E: int with get, set - // will warning - abstract F: int with get, private set""" - |> withLangVersionPreview - |> verifyCompile - |> shouldFail - |> withDiagnostics [ - (Warning 3866, Line 8, Col 24, Line 8, Col 32, "The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file.") - (Warning 3866, Line 8, Col 38, Line 8, Col 45, "The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file.") - (Warning 3866, Line 11, Col 31, Line 11, Col 38, "The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file.") - (Error 240, Line 1, Col 1, Line 11, Col 42, "The signature file 'Program' 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 ``Signature And Implement File Test`` () = - let encodeFs = - FsSource """module Program - -type A() = - member val B: int = 0 with internal get, internal set - member val C: int = 0 with internal get, internal set - member val D: int = 0 with internal get, private set""" - Fsi """module Program - -type A = - new: unit -> A - member internal B: int - member internal C: int with get, set - // will warning - member D: int with internal get, private set""" - |> withAdditionalSourceFile encodeFs - |> withLangVersionPreview - |> compile - |> shouldFail - |> withDiagnostics [ - (Warning 3866, Line 8, Col 24, Line 8, Col 32, "The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file.") - (Warning 3866, Line 8, Col 38, Line 8, Col 45, "The modifier will be ignored because access modifiers before getters and setters are not allowed in signature file.") - (Error 0034, Line 6, Col 16, Line 6, Col 17, "Module 'Program' contains - member private A.D: int with set -but its signature specifies - member A.D: int with set -The accessibility specified in the signature is more than that specified in the implementation") - (Error 0034, Line 6, Col 16, Line 6, Col 17, "Module 'Program' contains - member internal A.D: int -but its signature specifies - member A.D: int -The accessibility specified in the signature is more than that specified in the implementation") - ] diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 0bb8fd4a34f..4f04946a466 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -56,7 +56,6 @@ - diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl index 51d08041668..3c4b22f76c1 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl @@ -7739,10 +7739,6 @@ FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: Microsoft.FSharp.Collections. FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynAttributeList] get_attributes() FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynAccess] accessibility 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.SynAccess] get_getterAccessibility() -FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynAccess] get_setterAccessibility() -FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynAccess] getterAccessibility -FSharp.Compiler.Syntax.SynMemberDefn+AutoProperty: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynAccess] setterAccessibility 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+GetSetMember: FSharp.Compiler.SyntaxTrivia.SynMemberGetSetTrivia get_trivia() @@ -7852,7 +7848,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.SyntaxTrivia.SynMemberDefnAbstractSlotTrivia) -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], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.SynAccess], 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 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.SynPat, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Syntax.Ident], FSharp.Compiler.Xml.PreXmlDoc, FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynMemberDefnImplicitCtorTrivia) 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) diff --git a/tests/service/data/SyntaxTree/LeadingKeyword/DefaultValKeyword.fs.bsl b/tests/service/data/SyntaxTree/LeadingKeyword/DefaultValKeyword.fs.bsl index aae0b57cb0c..0451b561b92 100644 --- a/tests/service/data/SyntaxTree/LeadingKeyword/DefaultValKeyword.fs.bsl +++ b/tests/service/data/SyntaxTree/LeadingKeyword/DefaultValKeyword.fs.bsl @@ -28,8 +28,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((3,4), FSharp.Compiler.Xml.XmlDocCollector), - None, None, None, Const (Int32 1, (3,26--3,27)), - (3,4--3,27), + None, Const (Int32 1, (3,26--3,27)), (3,4--3,27), { LeadingKeyword = DefaultVal ((3,4--3,11), (3,12--3,15)) WithKeyword = None diff --git a/tests/service/data/SyntaxTree/LeadingKeyword/MemberValKeyword.fs.bsl b/tests/service/data/SyntaxTree/LeadingKeyword/MemberValKeyword.fs.bsl index a5a5c94bbf8..7178d569385 100644 --- a/tests/service/data/SyntaxTree/LeadingKeyword/MemberValKeyword.fs.bsl +++ b/tests/service/data/SyntaxTree/LeadingKeyword/MemberValKeyword.fs.bsl @@ -28,8 +28,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((3,4), FSharp.Compiler.Xml.XmlDocCollector), - None, None, None, Const (Int32 1, (3,25--3,26)), - (3,4--3,26), + None, Const (Int32 1, (3,25--3,26)), (3,4--3,26), { LeadingKeyword = MemberVal ((3,4--3,10), (3,11--3,14)) WithKeyword = None diff --git a/tests/service/data/SyntaxTree/LeadingKeyword/OverrideValKeyword.fs.bsl b/tests/service/data/SyntaxTree/LeadingKeyword/OverrideValKeyword.fs.bsl index de95a8f3bbb..4d3005f29e3 100644 --- a/tests/service/data/SyntaxTree/LeadingKeyword/OverrideValKeyword.fs.bsl +++ b/tests/service/data/SyntaxTree/LeadingKeyword/OverrideValKeyword.fs.bsl @@ -28,8 +28,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((3,4), FSharp.Compiler.Xml.XmlDocCollector), - None, None, None, Const (Int32 1, (3,27--3,28)), - (3,4--3,28), + None, Const (Int32 1, (3,27--3,28)), (3,4--3,28), { LeadingKeyword = OverrideVal ((3,4--3,12), (3,13--3,16)) WithKeyword = None diff --git a/tests/service/data/SyntaxTree/LeadingKeyword/StaticMemberValKeyword.fs.bsl b/tests/service/data/SyntaxTree/LeadingKeyword/StaticMemberValKeyword.fs.bsl index 2ac6f5d2c39..809096c0c78 100644 --- a/tests/service/data/SyntaxTree/LeadingKeyword/StaticMemberValKeyword.fs.bsl +++ b/tests/service/data/SyntaxTree/LeadingKeyword/StaticMemberValKeyword.fs.bsl @@ -28,8 +28,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((3,4), FSharp.Compiler.Xml.XmlDocCollector), - None, None, None, Const (Int32 1, (3,32--3,33)), - (3,4--3,33), + None, Const (Int32 1, (3,32--3,33)), (3,4--3,33), { LeadingKeyword = StaticMemberVal ((3,4--3,10), (3,11--3,17), (3,18--3,21)) diff --git a/tests/service/data/SyntaxTree/Member/Auto property 01.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 01.fs.bsl index 4576c205a95..5155ca1b3e3 100644 --- a/tests/service/data/SyntaxTree/Member/Auto property 01.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Auto property 01.fs.bsl @@ -27,8 +27,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, None, None, Const (Int32 1, (4,20--4,21)), - (4,4--4,21), + None, Const (Int32 1, (4,20--4,21)), (4,4--4,21), { LeadingKeyword = MemberVal ((4,4--4,10), (4,11--4,14)) WithKeyword = None diff --git a/tests/service/data/SyntaxTree/Member/Auto property 02.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 02.fs.bsl index b8736fd23e2..af2cbcfa598 100644 --- a/tests/service/data/SyntaxTree/Member/Auto property 02.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Auto property 02.fs.bsl @@ -27,7 +27,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, None, None, + None, ArbitraryAfterError ("typedSequentialExprBlock1", (4,19--4,19)), (4,4--4,19), diff --git a/tests/service/data/SyntaxTree/Member/Auto property 03.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 03.fs.bsl index c489efc4380..4dc2510f320 100644 --- a/tests/service/data/SyntaxTree/Member/Auto property 03.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Auto property 03.fs.bsl @@ -27,7 +27,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, None, None, + None, ArbitraryAfterError ("typedSequentialExprBlock1", (4,19--4,19)), (4,4--4,19), @@ -51,8 +51,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((5,4), FSharp.Compiler.Xml.XmlDocCollector), - None, None, None, Const (Int32 2, (5,20--5,21)), - (5,4--5,21), + None, Const (Int32 2, (5,20--5,21)), (5,4--5,21), { LeadingKeyword = MemberVal ((5,4--5,10), (5,11--5,14)) WithKeyword = None diff --git a/tests/service/data/SyntaxTree/Member/Auto property 04.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 04.fs.bsl index f9c511bfc5e..9497c483352 100644 --- a/tests/service/data/SyntaxTree/Member/Auto property 04.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Auto property 04.fs.bsl @@ -27,8 +27,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, None, None, - ArbitraryAfterError ("autoProp2", (4,17--4,17)), + None, ArbitraryAfterError ("autoProp2", (4,17--4,17)), (4,4--4,17), { LeadingKeyword = MemberVal ((4,4--4,10), (4,11--4,14)) @@ -50,8 +49,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((5,4), FSharp.Compiler.Xml.XmlDocCollector), - None, None, None, Const (Int32 2, (5,20--5,21)), - (5,4--5,21), + None, Const (Int32 2, (5,20--5,21)), (5,4--5,21), { LeadingKeyword = MemberVal ((5,4--5,10), (5,11--5,14)) WithKeyword = None diff --git a/tests/service/data/SyntaxTree/Member/Auto property 05.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 05.fs.bsl index 541adf1f681..84a9f629f6e 100644 --- a/tests/service/data/SyntaxTree/Member/Auto property 05.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Auto property 05.fs.bsl @@ -27,8 +27,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, None, None, - ArbitraryAfterError ("autoProp3", (4,14--4,14)), + None, ArbitraryAfterError ("autoProp3", (4,14--4,14)), (4,4--4,14), { LeadingKeyword = MemberVal ((4,4--4,10), (4,11--4,14)) @@ -50,8 +49,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((5,4), FSharp.Compiler.Xml.XmlDocCollector), - None, None, None, Const (Int32 2, (5,20--5,21)), - (5,4--5,21), + None, Const (Int32 2, (5,20--5,21)), (5,4--5,21), { LeadingKeyword = MemberVal ((5,4--5,10), (5,11--5,14)) WithKeyword = None diff --git a/tests/service/data/SyntaxTree/Member/Auto property 06.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 06.fs.bsl index 0a7d12909ea..50d5378bf80 100644 --- a/tests/service/data/SyntaxTree/Member/Auto property 06.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Auto property 06.fs.bsl @@ -27,8 +27,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, None, None, Const (Int32 1, (4,20--4,21)), - (4,4--4,21), + None, Const (Int32 1, (4,20--4,21)), (4,4--4,21), { LeadingKeyword = MemberVal ((4,4--4,10), (4,11--4,14)) WithKeyword = None diff --git a/tests/service/data/SyntaxTree/Member/Auto property 07.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 07.fs.bsl index 84e7a69d193..492124d31f0 100644 --- a/tests/service/data/SyntaxTree/Member/Auto property 07.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Auto property 07.fs.bsl @@ -32,8 +32,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, None, None, Const (Int32 7, (4,24--4,25)), - (4,4--4,38), + None, Const (Int32 7, (4,24--4,25)), (4,4--4,38), { LeadingKeyword = MemberVal ((4,4--4,10), (4,11--4,14)) WithKeyword = Some (4,26--4,30) diff --git a/tests/service/data/SyntaxTree/Member/Auto property 08.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 08.fs.bsl index 982030b64d2..82805ec6df7 100644 --- a/tests/service/data/SyntaxTree/Member/Auto property 08.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Auto property 08.fs.bsl @@ -27,8 +27,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, None, None, Const (Int32 1, (4,19--4,20)), - (4,4--4,29), + None, Const (Int32 1, (4,19--4,20)), (4,4--4,29), { LeadingKeyword = MemberVal ((4,4--4,10), (4,11--4,14)) WithKeyword = Some (4,21--4,25) @@ -46,4 +45,4 @@ ImplFile (6,0)-(6,1) parse error Unexpected syntax or possible incorrect indentation: this token is offside of context started at position (4:22). Try indenting this further. To continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7. -(6,0)-(6,1) parse error Incomplete structured construct at or before this point. Expected identifier, '(', '(*)' or other token. +(6,0)-(6,1) parse error Incomplete structured construct at or before this point in member definition. Expected identifier, '(', '(*)' or other token. diff --git a/tests/service/data/SyntaxTree/Member/Auto property 09.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 09.fs.bsl index f4d9b9aa777..00760cf2537 100644 --- a/tests/service/data/SyntaxTree/Member/Auto property 09.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Auto property 09.fs.bsl @@ -27,8 +27,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, None, None, Const (Int32 1, (4,20--4,21)), - (4,4--4,30), + None, Const (Int32 1, (4,20--4,21)), (4,4--4,30), { LeadingKeyword = MemberVal ((4,4--4,10), (4,11--4,14)) WithKeyword = Some (4,22--4,26) @@ -69,4 +68,4 @@ ImplFile (5,4)-(5,10) parse error Unexpected syntax or possible incorrect indentation: this token is offside of context started at position (4:23). Try indenting this further. To continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7. -(5,4)-(5,10) parse error Incomplete structured construct at or before this point. Expected identifier, '(', '(*)' or other token. +(5,4)-(5,10) parse error Incomplete structured construct at or before this point in member definition. Expected identifier, '(', '(*)' or other token. diff --git a/tests/service/data/SyntaxTree/Member/Auto property 10.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 10.fs.bsl index aeaf553b54c..1a61306fb2d 100644 --- a/tests/service/data/SyntaxTree/Member/Auto property 10.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Auto property 10.fs.bsl @@ -27,8 +27,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, None, None, Const (Int32 1, (4,19--4,20)), - (4,4--4,29), + None, Const (Int32 1, (4,19--4,20)), (4,4--4,29), { LeadingKeyword = MemberVal ((4,4--4,10), (4,11--4,14)) WithKeyword = Some (4,21--4,25) @@ -45,4 +44,4 @@ ImplFile (5,0)-(5,0) parse error Unexpected syntax or possible incorrect indentation: this token is offside of context started at position (4:22). Try indenting this further. To continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7. -(5,0)-(5,0) parse error Incomplete structured construct at or before this point. Expected identifier, '(', '(*)' or other token. +(5,0)-(5,0) parse error Incomplete structured construct at or before this point in member definition. Expected identifier, '(', '(*)' or other token. diff --git a/tests/service/data/SyntaxTree/Member/Auto property 11.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 11.fs.bsl index b0235cf362a..14121127b62 100644 --- a/tests/service/data/SyntaxTree/Member/Auto property 11.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Auto property 11.fs.bsl @@ -27,8 +27,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, None, None, Const (Int32 1, (4,19--4,20)), - (4,4--4,29), + None, Const (Int32 1, (4,19--4,20)), (4,4--4,29), { LeadingKeyword = MemberVal ((4,4--4,10), (4,11--4,14)) WithKeyword = Some (4,21--4,25) diff --git a/tests/service/data/SyntaxTree/Member/Auto property 12.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 12.fs.bsl index 79d41c4f5a0..d466718e4af 100644 --- a/tests/service/data/SyntaxTree/Member/Auto property 12.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Auto property 12.fs.bsl @@ -27,8 +27,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, None, None, Const (Int32 1, (4,19--4,20)), - (4,4--4,20), + None, Const (Int32 1, (4,19--4,20)), (4,4--4,20), { LeadingKeyword = MemberVal ((4,4--4,10), (4,11--4,14)) WithKeyword = Some (4,21--4,25) diff --git a/tests/service/data/SyntaxTree/Member/Auto property 13.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 13.fs.bsl index a4515894463..d0c7a6c9dbc 100644 --- a/tests/service/data/SyntaxTree/Member/Auto property 13.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/Auto property 13.fs.bsl @@ -27,8 +27,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, None, None, Const (Int32 1, (4,19--4,20)), - (4,4--4,20), + None, Const (Int32 1, (4,19--4,20)), (4,4--4,20), { LeadingKeyword = MemberVal ((4,4--4,10), (4,11--4,14)) WithKeyword = Some (4,21--4,25) diff --git a/tests/service/data/SyntaxTree/Member/Auto property 14.fs b/tests/service/data/SyntaxTree/Member/Auto property 14.fs deleted file mode 100644 index c69c16bcfbf..00000000000 --- a/tests/service/data/SyntaxTree/Member/Auto property 14.fs +++ /dev/null @@ -1,4 +0,0 @@ -module A - -type X() = - member val Y: int = 7 with public get, private set diff --git a/tests/service/data/SyntaxTree/Member/Auto property 14.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 14.fs.bsl deleted file mode 100644 index 2235a327002..00000000000 --- a/tests/service/data/SyntaxTree/Member/Auto property 14.fs.bsl +++ /dev/null @@ -1,56 +0,0 @@ -ImplFile - (ParsedImplFileInput - ("/root/Member/Auto property 14.fs", false, QualifiedNameOfFile A, [], [], - [SynModuleOrNamespace - ([A], false, NamedModule, - [Types - ([SynTypeDefn - (SynComponentInfo - ([], None, [], [X], - PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (3,5--3,6)), - ObjectModel - (Unspecified, - [ImplicitCtor - (None, [], Const (Unit, (3,6--3,8)), None, - PreXmlDoc ((3,6), FSharp.Compiler.Xml.XmlDocCollector), - (3,5--3,6), { AsKeyword = None }); - AutoProperty - ([], false, Y, - Some (LongIdent (SynLongIdent ([int], [], [None]))), - PropertyGetSet, - { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = Member }, - { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = PropertySet }, - PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, Some (Public (4,31--4,37)), - Some (Private (4,43--4,50)), - Const (Int32 7, (4,24--4,25)), (4,4--4,54), - { LeadingKeyword = - MemberVal ((4,4--4,10), (4,11--4,14)) - WithKeyword = Some (4,26--4,30) - EqualsRange = Some (4,22--4,23) - GetSetKeywords = - Some (GetSet ((4,38--4,41), (4,51--4,54))) })], - (4,4--4,54)), [], - Some - (ImplicitCtor - (None, [], Const (Unit, (3,6--3,8)), None, - PreXmlDoc ((3,6), FSharp.Compiler.Xml.XmlDocCollector), - (3,5--3,6), { AsKeyword = None })), (3,5--4,54), - { LeadingKeyword = Type (3,0--3,4) - EqualsRange = Some (3,9--3,10) - WithKeyword = None })], (3,0--4,54))], - PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, - (1,0--4,54), { LeadingKeyword = Module (1,0--1,6) })], (true, true), - { ConditionalDirectives = [] - CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Member/Auto property 15.fs b/tests/service/data/SyntaxTree/Member/Auto property 15.fs deleted file mode 100644 index aedf83865d3..00000000000 --- a/tests/service/data/SyntaxTree/Member/Auto property 15.fs +++ /dev/null @@ -1,4 +0,0 @@ -module A - -type X() = - member val internal Y: int = 7 with public get, private set diff --git a/tests/service/data/SyntaxTree/Member/Auto property 15.fs.bsl b/tests/service/data/SyntaxTree/Member/Auto property 15.fs.bsl deleted file mode 100644 index 457b112dc31..00000000000 --- a/tests/service/data/SyntaxTree/Member/Auto property 15.fs.bsl +++ /dev/null @@ -1,56 +0,0 @@ -ImplFile - (ParsedImplFileInput - ("/root/Member/Auto property 15.fs", false, QualifiedNameOfFile A, [], [], - [SynModuleOrNamespace - ([A], false, NamedModule, - [Types - ([SynTypeDefn - (SynComponentInfo - ([], None, [], [X], - PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector), - false, None, (3,5--3,6)), - ObjectModel - (Unspecified, - [ImplicitCtor - (None, [], Const (Unit, (3,6--3,8)), None, - PreXmlDoc ((3,6), FSharp.Compiler.Xml.XmlDocCollector), - (3,5--3,6), { AsKeyword = None }); - AutoProperty - ([], false, Y, - Some (LongIdent (SynLongIdent ([int], [], [None]))), - PropertyGetSet, - { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = Member }, - { IsInstance = true - IsDispatchSlot = false - IsOverrideOrExplicitImpl = false - IsFinal = false - GetterOrSetterIsCompilerGenerated = false - MemberKind = PropertySet }, - PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - Some (Internal (4,15--4,23)), - Some (Public (4,40--4,46)), Some (Private (4,52--4,59)), - Const (Int32 7, (4,33--4,34)), (4,4--4,63), - { LeadingKeyword = - MemberVal ((4,4--4,10), (4,11--4,14)) - WithKeyword = Some (4,35--4,39) - EqualsRange = Some (4,31--4,32) - GetSetKeywords = - Some (GetSet ((4,47--4,50), (4,60--4,63))) })], - (4,4--4,63)), [], - Some - (ImplicitCtor - (None, [], Const (Unit, (3,6--3,8)), None, - PreXmlDoc ((3,6), FSharp.Compiler.Xml.XmlDocCollector), - (3,5--3,6), { AsKeyword = None })), (3,5--4,63), - { LeadingKeyword = Type (3,0--3,4) - EqualsRange = Some (3,9--3,10) - WithKeyword = None })], (3,0--4,63))], - PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), [], None, - (1,0--4,63), { LeadingKeyword = Module (1,0--1,6) })], (true, true), - { ConditionalDirectives = [] - CodeComments = [] }, set [])) diff --git a/tests/service/data/SyntaxTree/Member/SynTypeDefnWithAutoPropertyContainsTheRangeOfTheEqualsSign.fs.bsl b/tests/service/data/SyntaxTree/Member/SynTypeDefnWithAutoPropertyContainsTheRangeOfTheEqualsSign.fs.bsl index 9ebebcbddf1..7cfa4c283eb 100644 --- a/tests/service/data/SyntaxTree/Member/SynTypeDefnWithAutoPropertyContainsTheRangeOfTheEqualsSign.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/SynTypeDefnWithAutoPropertyContainsTheRangeOfTheEqualsSign.fs.bsl @@ -51,7 +51,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((5,4), FSharp.Compiler.Xml.XmlDocCollector), - None, None, None, Ident name, (4,4--5,40), + None, Ident name, (4,4--5,40), { LeadingKeyword = MemberVal ((5,4--5,10), (5,11--5,14)) WithKeyword = Some (5,27--5,31) diff --git a/tests/service/data/SyntaxTree/Member/SynTypeDefnWithAutoPropertyContainsTheRangeOfTheWithKeyword.fs.bsl b/tests/service/data/SyntaxTree/Member/SynTypeDefnWithAutoPropertyContainsTheRangeOfTheWithKeyword.fs.bsl index c5a3db03d4d..0bef3c32697 100644 --- a/tests/service/data/SyntaxTree/Member/SynTypeDefnWithAutoPropertyContainsTheRangeOfTheWithKeyword.fs.bsl +++ b/tests/service/data/SyntaxTree/Member/SynTypeDefnWithAutoPropertyContainsTheRangeOfTheWithKeyword.fs.bsl @@ -34,7 +34,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((3,4), FSharp.Compiler.Xml.XmlDocCollector), - None, None, None, Ident autoProp, (3,4--3,52), + None, Ident autoProp, (3,4--3,52), { LeadingKeyword = MemberVal ((3,4--3,10), (3,11--3,14)) WithKeyword = Some (3,39--3,43) @@ -56,7 +56,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, None, None, Ident autoProp, (4,4--4,39), + None, Ident autoProp, (4,4--4,39), { LeadingKeyword = MemberVal ((4,4--4,10), (4,11--4,14)) WithKeyword = None diff --git a/tests/service/data/SyntaxTree/MemberFlag/SynMemberDefnAutoPropertyHasCorrectKeyword.fs.bsl b/tests/service/data/SyntaxTree/MemberFlag/SynMemberDefnAutoPropertyHasCorrectKeyword.fs.bsl index 67858fd3916..f3b34e63689 100644 --- a/tests/service/data/SyntaxTree/MemberFlag/SynMemberDefnAutoPropertyHasCorrectKeyword.fs.bsl +++ b/tests/service/data/SyntaxTree/MemberFlag/SynMemberDefnAutoPropertyHasCorrectKeyword.fs.bsl @@ -28,8 +28,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((3,4), FSharp.Compiler.Xml.XmlDocCollector), - None, None, None, Const (Int32 1, (3,32--3,33)), - (3,4--3,33), + None, Const (Int32 1, (3,32--3,33)), (3,4--3,33), { LeadingKeyword = StaticMemberVal ((3,4--3,10), (3,11--3,17), (3,18--3,21)) @@ -52,8 +51,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((4,4), FSharp.Compiler.Xml.XmlDocCollector), - None, None, None, Const (Int32 1, (4,25--4,26)), - (4,4--4,26), + None, Const (Int32 1, (4,25--4,26)), (4,4--4,26), { LeadingKeyword = MemberVal ((4,4--4,10), (4,11--4,14)) WithKeyword = None @@ -75,8 +73,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((5,4), FSharp.Compiler.Xml.XmlDocCollector), - None, None, None, Const (Int32 2, (5,27--5,28)), - (5,4--5,28), + None, Const (Int32 2, (5,27--5,28)), (5,4--5,28), { LeadingKeyword = OverrideVal ((5,4--5,12), (5,13--5,16)) WithKeyword = None @@ -98,8 +95,7 @@ ImplFile GetterOrSetterIsCompilerGenerated = false MemberKind = PropertySet }, PreXmlDoc ((6,4), FSharp.Compiler.Xml.XmlDocCollector), - None, None, None, Const (Int32 1, (6,26--6,27)), - (6,4--6,27), + None, Const (Int32 1, (6,26--6,27)), (6,4--6,27), { LeadingKeyword = DefaultVal ((6,4--6,11), (6,12--6,15)) WithKeyword = None From f2fcad0f25cc8e5163c26d0f3ac8aa3e8e1f3aa0 Mon Sep 17 00:00:00 2001 From: Alex Berezhnykh Date: Mon, 11 Mar 2024 13:16:35 +0300 Subject: [PATCH 05/14] Refactor GetCSharpStyleIndexedExtensionMembersForTyconRef: unify logic (#16839) --- src/Compiler/Checking/NameResolution.fs | 86 +++++++++---------------- 1 file changed, 32 insertions(+), 54 deletions(-) diff --git a/src/Compiler/Checking/NameResolution.fs b/src/Compiler/Checking/NameResolution.fs index 68b333b52d9..76a89601b9c 100644 --- a/src/Compiler/Checking/NameResolution.fs +++ b/src/Compiler/Checking/NameResolution.fs @@ -573,62 +573,40 @@ let GetTyconRefForExtensionMembers minfo (deref: Entity) amap m g = /// Get the info for all the .NET-style extension members listed as static members in the type. let private GetCSharpStyleIndexedExtensionMembersForTyconRef (amap: Import.ImportMap) m (tcrefOfStaticClass: TyconRef) = let g = amap.g - let pri = NextExtensionMethodPriority() - - if g.langVersion.SupportsFeature(LanguageFeature.CSharpExtensionAttributeNotRequired) then - let csharpStyleExtensionMembers = - if IsTyconRefUsedForCSharpStyleExtensionMembers g m tcrefOfStaticClass || (tcrefOfStaticClass.IsLocalRef && not tcrefOfStaticClass.IsTypeAbbrev) then - protectAssemblyExploration [] (fun () -> - let ty = generalizedTyconRef g tcrefOfStaticClass - GetImmediateIntrinsicMethInfosOfType (None, AccessorDomain.AccessibleFromSomeFSharpCode) g amap m ty - |> List.filter (IsMethInfoPlainCSharpStyleExtensionMember g m true)) - else - [] - if not csharpStyleExtensionMembers.IsEmpty then - [ for minfo in csharpStyleExtensionMembers do - let ilExtMem = ILExtMem (tcrefOfStaticClass, minfo, pri) + let isApplicable = + IsTyconRefUsedForCSharpStyleExtensionMembers g m tcrefOfStaticClass || - // The results are indexed by the TyconRef of the first 'this' argument, if any. - // So we need to go and crack the type of the 'this' argument. - // - // This is convoluted because we only need the ILTypeRef of the first argument, and we don't - // want to read any other metadata as it can trigger missing-assembly errors. It turns out ImportILTypeRef - // is less eager in reading metadata than GetParamTypes. - // - // We don't use the index for the IL extension method for tuple of F# function types (e.g. if extension - // methods for tuple occur in C# code) - let thisTyconRef = GetTyconRefForExtensionMembers minfo tcrefOfStaticClass.Deref amap m g - match thisTyconRef with - | None -> () - | Some (Some tcref) -> yield Choice1Of2(tcref, ilExtMem) - | Some None -> yield Choice2Of2 ilExtMem ] - else - [] - else - if IsTyconRefUsedForCSharpStyleExtensionMembers g m tcrefOfStaticClass then - let ty = generalizedTyconRef g tcrefOfStaticClass - let minfos = GetImmediateIntrinsicMethInfosOfType (None, AccessorDomain.AccessibleFromSomeFSharpCode) g amap m ty - - [ for minfo in minfos do - if IsMethInfoPlainCSharpStyleExtensionMember g m true minfo then - let ilExtMem = ILExtMem (tcrefOfStaticClass, minfo, pri) - // The results are indexed by the TyconRef of the first 'this' argument, if any. - // So we need to go and crack the type of the 'this' argument. - // - // This is convoluted because we only need the ILTypeRef of the first argument, and we don't - // want to read any other metadata as it can trigger missing-assembly errors. It turns out ImportILTypeRef - // is less eager in reading metadata than GetParamTypes. - // - // We don't use the index for the IL extension method for tuple of F# function types (e.g. if extension - // methods for tuple occur in C# code) - let thisTyconRef = GetTyconRefForExtensionMembers minfo tcrefOfStaticClass.Deref amap m g - match thisTyconRef with - | None -> () - | Some (Some tcref) -> yield Choice1Of2(tcref, ilExtMem) - | Some None -> yield Choice2Of2 ilExtMem ] - else - [] + g.langVersion.SupportsFeature(LanguageFeature.CSharpExtensionAttributeNotRequired) && + tcrefOfStaticClass.IsLocalRef && + not tcrefOfStaticClass.IsTypeAbbrev + + if not isApplicable then [] else + + let ty = generalizedTyconRef g tcrefOfStaticClass + let pri = NextExtensionMethodPriority() + + let methods = + protectAssemblyExploration [] + (fun () -> GetImmediateIntrinsicMethInfosOfType (None, AccessorDomain.AccessibleFromSomeFSharpCode) g amap m ty) + + [ for minfo in methods do + if IsMethInfoPlainCSharpStyleExtensionMember g m true minfo then + let ilExtMem = ILExtMem (tcrefOfStaticClass, minfo, pri) + // The results are indexed by the TyconRef of the first 'this' argument, if any. + // So we need to go and crack the type of the 'this' argument. + // + // This is convoluted because we only need the ILTypeRef of the first argument, and we don't + // want to read any other metadata as it can trigger missing-assembly errors. It turns out ImportILTypeRef + // is less eager in reading metadata than GetParamTypes. + // + // We don't use the index for the IL extension method for tuple of F# function types (e.g. if extension + // methods for tuple occur in C# code) + let thisTyconRef = GetTyconRefForExtensionMembers minfo tcrefOfStaticClass.Deref amap m g + match thisTyconRef with + | None -> () + | Some (Some tcref) -> yield Choice1Of2(tcref, ilExtMem) + | Some None -> yield Choice2Of2 ilExtMem ] /// Query the declared properties of a type (including inherited properties) let IntrinsicPropInfosOfTypeInScope (infoReader: InfoReader) optFilter ad findFlag m ty = From 31a435446fe0e6ec0bfc0c2652a1ea3664f3b06f Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Mon, 11 Mar 2024 12:57:55 +0100 Subject: [PATCH 06/14] Disable transparent compiler tests (#16850) --- .../FSharpChecker/TransparentCompiler.fs | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs b/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs index 5dc3dedb548..7e78cda1704 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs +++ b/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs @@ -28,7 +28,7 @@ open OpenTelemetry.Trace #nowarn "57" -[] +[] let ``Use Transparent Compiler`` () = let size = 20 @@ -58,7 +58,7 @@ let ``Use Transparent Compiler`` () = checkFile last expectSignatureChanged } -[] +[] let ``Parallel processing`` () = let project = SyntheticProject.Create( @@ -76,7 +76,7 @@ let ``Parallel processing`` () = checkFile "E" expectSignatureChanged } -[] +[] let ``Parallel processing with signatures`` () = let project = SyntheticProject.Create( @@ -111,7 +111,7 @@ let makeTestProject () = let testWorkflow () = ProjectWorkflowBuilder(makeTestProject(), useTransparentCompiler = true) -[] +[] let ``Edit file, check it, then check dependent file`` () = testWorkflow() { updateFile "First" breakDependentFiles @@ -119,21 +119,21 @@ let ``Edit file, check it, then check dependent file`` () = checkFile "Second" expectErrors } -[] +[] let ``Edit file, don't check it, check dependent file`` () = testWorkflow() { updateFile "First" breakDependentFiles checkFile "Second" expectErrors } -[] +[] let ``Check transitive dependency`` () = testWorkflow() { updateFile "First" breakDependentFiles checkFile "Last" expectSignatureChanged } -[] +[] let ``Change multiple files at once`` () = testWorkflow() { updateFile "First" (setPublicVersion 2) @@ -142,7 +142,7 @@ let ``Change multiple files at once`` () = checkFile "Last" (expectSignatureContains "val f: x: 'a -> (ModuleFirst.TFirstV_2<'a> * ModuleSecond.TSecondV_2<'a>) * (ModuleFirst.TFirstV_2<'a> * ModuleThird.TThirdV_2<'a>) * TLastV_1<'a>") } -[] +[] let ``Files depend on signature file if present`` () = let project = makeTestProject() |> updateFile "First" addSignatureFile @@ -152,7 +152,7 @@ let ``Files depend on signature file if present`` () = checkFile "Second" expectNoChanges } -[] +[] let ``Project with signatures`` () = let project = SyntheticProject.Create( @@ -167,7 +167,7 @@ let ``Project with signatures`` () = checkFile "Second" expectOk } -[] +[] let ``Signature update`` () = let project = SyntheticProject.Create( @@ -183,7 +183,7 @@ let ``Signature update`` () = checkFile "Second" expectSignatureChanged } -[] +[] let ``Adding a file`` () = testWorkflow() { addFileAbove "Second" (sourceFile "New" []) @@ -191,14 +191,14 @@ let ``Adding a file`` () = checkFile "Last" (expectSignatureContains "val f: x: 'a -> (ModuleFirst.TFirstV_1<'a> * ModuleNew.TNewV_1<'a> * ModuleSecond.TSecondV_1<'a>) * (ModuleFirst.TFirstV_1<'a> * ModuleThird.TThirdV_1<'a>) * TLastV_1<'a>") } -[] +[] let ``Removing a file`` () = testWorkflow() { removeFile "Second" checkFile "Last" expectErrors } -[] +[] let ``Changes in a referenced project`` () = let library = SyntheticProject.Create("library", sourceFile "Library" []) @@ -217,7 +217,7 @@ let ``Changes in a referenced project`` () = } -[] +[] let ``File is not checked twice`` () = let cacheEvents = ConcurrentQueue() @@ -241,7 +241,7 @@ let ``File is not checked twice`` () = Assert.Equal([Weakened; Requested; Started; Finished], intermediateTypeChecks["FileFirst.fs"]) Assert.Equal([Weakened; Requested; Started; Finished], intermediateTypeChecks["FileThird.fs"]) -[] +[] let ``If a file is checked as a dependency it's not re-checked later`` () = let cacheEvents = ConcurrentQueue() @@ -265,7 +265,7 @@ let ``If a file is checked as a dependency it's not re-checked later`` () = Assert.Equal([Weakened; Requested; Started; Finished; Requested], intermediateTypeChecks["FileThird.fs"]) -// [] TODO: differentiate complete and minimal checking requests +// [] TODO: differentiate complete and minimal checking requests let ``We don't check files that are not depended on`` () = let project = SyntheticProject.Create( sourceFile "First" [], @@ -295,7 +295,7 @@ let ``We don't check files that are not depended on`` () = Assert.Equal([Started; Finished], intermediateTypeChecks["FileThird.fs"]) Assert.False (intermediateTypeChecks.ContainsKey "FileSecond.fs") -// [] TODO: differentiate complete and minimal checking requests +// [] TODO: differentiate complete and minimal checking requests let ``Files that are not depended on don't invalidate cache`` () = let project = SyntheticProject.Create( sourceFile "First" [], @@ -336,7 +336,7 @@ let ``Files that are not depended on don't invalidate cache`` () = Assert.Equal([], intermediateTypeChecks |> Map.toList) -// [] TODO: differentiate complete and minimal checking requests +// [] TODO: differentiate complete and minimal checking requests let ``Files that are not depended on don't invalidate cache part 2`` () = let project = SyntheticProject.Create( sourceFile "A" [], @@ -376,7 +376,7 @@ let ``Files that are not depended on don't invalidate cache part 2`` () = Assert.Equal(["FileE.fs", [Started; Finished]], graphConstructions) Assert.Equal(["FileE.fs", [Started; Finished]], intermediateTypeChecks) -[] +[] let ``Changing impl files doesn't invalidate cache when they have signatures`` () = let project = SyntheticProject.Create( { sourceFile "A" [] with SignatureFile = AutoGenerated }, @@ -405,7 +405,7 @@ let ``Changing impl files doesn't invalidate cache when they have signatures`` ( Assert.Equal([], intermediateTypeChecks) -[] +[] let ``Changing impl file doesn't invalidate an in-memory referenced project`` () = let library = SyntheticProject.Create("library", { sourceFile "A" [] with SignatureFile = AutoGenerated }) @@ -789,7 +789,7 @@ module Stuff = let fileName, snapshot, checker = singleFileChecker source checker.ParseFile(fileName, snapshot) |> Async.RunSynchronously - //[] + //[] let ``Hash stays the same when whitespace changes`` () = //let parseResult = getParseResult source @@ -845,7 +845,7 @@ let ``TypeCheck last file in project with transparent compiler`` useTransparentC checkFile lastFile expectOk } -[] +[] let ``LoadClosure for script is computed once`` () = let project = SyntheticProject.CreateForScript( sourceFile "First" []) @@ -870,7 +870,7 @@ let ``LoadClosure for script is computed once`` () = Assert.Empty(closureComputations) -[] +[] let ``LoadClosure for script is recomputed after changes`` () = let project = SyntheticProject.CreateForScript( sourceFile "First" []) @@ -899,7 +899,7 @@ let ``LoadClosure for script is recomputed after changes`` () = Assert.Equal([Weakened; Requested; Started; Finished; Weakened; Requested; Started; Finished], closureComputations["FileFirst.fs"]) -[] +[] let ``TryGetRecentCheckResultsForFile returns None before first call to ParseAndCheckFileInProject`` () = let project = SyntheticProject.Create( sourceFile "First" []) @@ -909,7 +909,7 @@ let ``TryGetRecentCheckResultsForFile returns None before first call to ParseAnd tryGetRecentCheckResults "First" expectNone } |> ignore -[] +[] let ``TryGetRecentCheckResultsForFile returns result after first call to ParseAndCheckFileInProject`` () = let project = SyntheticProject.Create( sourceFile "First" [] ) @@ -918,7 +918,7 @@ let ``TryGetRecentCheckResultsForFile returns result after first call to ParseAn tryGetRecentCheckResults "First" expectSome } |> ignore -[] +[] let ``TryGetRecentCheckResultsForFile returns no result after edit`` () = let project = SyntheticProject.Create( sourceFile "First" []) @@ -931,7 +931,7 @@ let ``TryGetRecentCheckResultsForFile returns no result after edit`` () = tryGetRecentCheckResults "First" expectSome } |> ignore -[] +[] let ``TryGetRecentCheckResultsForFile returns result after edit of other file`` () = let project = SyntheticProject.Create( sourceFile "First" [], @@ -945,7 +945,7 @@ let ``TryGetRecentCheckResultsForFile returns result after edit of other file`` tryGetRecentCheckResults "Second" expectSome // file didn't change so we still want to get the recent result } |> ignore -[] +[] let ``Background compiler and Transparent compiler return the same options`` () = async { let backgroundChecker = FSharpChecker.Create(useTransparentCompiler = false) From dac19d31fd98fa8ddff67f639df00474d57c4d6f Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 13:49:35 +0000 Subject: [PATCH 07/14] [main] Update dependencies from dotnet/arcade (#16828) * Update dependencies from https://github.com/dotnet/arcade build 20240305.2 Microsoft.DotNet.Arcade.Sdk From Version 8.0.0-beta.24151.4 -> To Version 8.0.0-beta.24155.2 * Update dependencies from https://github.com/dotnet/arcade build 20240306.1 Microsoft.DotNet.Arcade.Sdk From Version 8.0.0-beta.24151.4 -> To Version 8.0.0-beta.24156.1 * Update dependencies from https://github.com/dotnet/arcade build 20240308.1 Microsoft.DotNet.Arcade.Sdk From Version 8.0.0-beta.24151.4 -> To Version 8.0.0-beta.24158.1 * Update dependencies from https://github.com/dotnet/arcade build 20240308.4 Microsoft.DotNet.Arcade.Sdk From Version 8.0.0-beta.24151.4 -> To Version 8.0.0-beta.24158.4 --------- Co-authored-by: dotnet-maestro[bot] Co-authored-by: Vlad Zarytovskii --- eng/Version.Details.xml | 4 ++-- eng/common/SetupNugetSources.ps1 | 26 +++++++++++------------ eng/common/templates-official/job/job.yml | 4 ++++ eng/common/templates/job/job.yml | 4 ++++ global.json | 2 +- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 41c7f6365b1..b1514f0854a 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -30,9 +30,9 @@ - + https://github.com/dotnet/arcade - cbb61c3a9a42e7c3cce17ee453ff5ecdc7f69282 + 052a4b9e7a9bdb9744c86c05665f1b46e4d59b15 diff --git a/eng/common/SetupNugetSources.ps1 b/eng/common/SetupNugetSources.ps1 index 6c65e81925f..efa2fd72bfa 100644 --- a/eng/common/SetupNugetSources.ps1 +++ b/eng/common/SetupNugetSources.ps1 @@ -35,7 +35,7 @@ Set-StrictMode -Version 2.0 . $PSScriptRoot\tools.ps1 # Add source entry to PackageSources -function AddPackageSource($sources, $SourceName, $SourceEndPoint, $creds, $Username, $Password) { +function AddPackageSource($sources, $SourceName, $SourceEndPoint, $creds, $Username, $pwd) { $packageSource = $sources.SelectSingleNode("add[@key='$SourceName']") if ($packageSource -eq $null) @@ -48,12 +48,11 @@ function AddPackageSource($sources, $SourceName, $SourceEndPoint, $creds, $Usern else { Write-Host "Package source $SourceName already present." } - - AddCredential -Creds $creds -Source $SourceName -Username $Username -Password $Password + AddCredential -Creds $creds -Source $SourceName -Username $Username -pwd $pwd } # Add a credential node for the specified source -function AddCredential($creds, $source, $username, $password) { +function AddCredential($creds, $source, $username, $pwd) { # Looks for credential configuration for the given SourceName. Create it if none is found. $sourceElement = $creds.SelectSingleNode($Source) if ($sourceElement -eq $null) @@ -82,17 +81,18 @@ function AddCredential($creds, $source, $username, $password) { $passwordElement.SetAttribute("key", "ClearTextPassword") $sourceElement.AppendChild($passwordElement) | Out-Null } - $passwordElement.SetAttribute("value", $Password) + + $passwordElement.SetAttribute("value", $pwd) } -function InsertMaestroPrivateFeedCredentials($Sources, $Creds, $Username, $Password) { +function InsertMaestroPrivateFeedCredentials($Sources, $Creds, $Username, $pwd) { $maestroPrivateSources = $Sources.SelectNodes("add[contains(@key,'darc-int')]") Write-Host "Inserting credentials for $($maestroPrivateSources.Count) Maestro's private feeds." ForEach ($PackageSource in $maestroPrivateSources) { Write-Host "`tInserting credential for Maestro's feed:" $PackageSource.Key - AddCredential -Creds $creds -Source $PackageSource.Key -Username $Username -Password $Password + AddCredential -Creds $creds -Source $PackageSource.Key -Username $Username -pwd $pwd } } @@ -144,13 +144,13 @@ if ($disabledSources -ne $null) { $userName = "dn-bot" # Insert credential nodes for Maestro's private feeds -InsertMaestroPrivateFeedCredentials -Sources $sources -Creds $creds -Username $userName -Password $Password +InsertMaestroPrivateFeedCredentials -Sources $sources -Creds $creds -Username $userName -pwd $Password # 3.1 uses a different feed url format so it's handled differently here $dotnet31Source = $sources.SelectSingleNode("add[@key='dotnet3.1']") if ($dotnet31Source -ne $null) { - AddPackageSource -Sources $sources -SourceName "dotnet3.1-internal" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3.1-internal/nuget/v2" -Creds $creds -Username $userName -Password $Password - AddPackageSource -Sources $sources -SourceName "dotnet3.1-internal-transport" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3.1-internal-transport/nuget/v2" -Creds $creds -Username $userName -Password $Password + AddPackageSource -Sources $sources -SourceName "dotnet3.1-internal" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3.1-internal/nuget/v2" -Creds $creds -Username $userName -pwd $Password + AddPackageSource -Sources $sources -SourceName "dotnet3.1-internal-transport" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3.1-internal-transport/nuget/v2" -Creds $creds -Username $userName -pwd $Password } $dotnetVersions = @('5','6','7','8') @@ -159,9 +159,9 @@ foreach ($dotnetVersion in $dotnetVersions) { $feedPrefix = "dotnet" + $dotnetVersion; $dotnetSource = $sources.SelectSingleNode("add[@key='$feedPrefix']") if ($dotnetSource -ne $null) { - AddPackageSource -Sources $sources -SourceName "$feedPrefix-internal" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/internal/_packaging/$feedPrefix-internal/nuget/v2" -Creds $creds -Username $userName -Password $Password - AddPackageSource -Sources $sources -SourceName "$feedPrefix-internal-transport" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/internal/_packaging/$feedPrefix-internal-transport/nuget/v2" -Creds $creds -Username $userName -Password $Password + AddPackageSource -Sources $sources -SourceName "$feedPrefix-internal" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/internal/_packaging/$feedPrefix-internal/nuget/v2" -Creds $creds -Username $userName -pwd $Password + AddPackageSource -Sources $sources -SourceName "$feedPrefix-internal-transport" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/internal/_packaging/$feedPrefix-internal-transport/nuget/v2" -Creds $creds -Username $userName -pwd $Password } } -$doc.Save($filename) +$doc.Save($filename) \ No newline at end of file diff --git a/eng/common/templates-official/job/job.yml b/eng/common/templates-official/job/job.yml index 9e7bebe9af8..647e3f92e5f 100644 --- a/eng/common/templates-official/job/job.yml +++ b/eng/common/templates-official/job/job.yml @@ -15,6 +15,7 @@ parameters: timeoutInMinutes: '' variables: [] workspace: '' + templateContext: '' # Job base template specific parameters # See schema documentation - https://github.com/dotnet/arcade/blob/master/Documentation/AzureDevOps/TemplateSchema.md @@ -68,6 +69,9 @@ jobs: ${{ if ne(parameters.timeoutInMinutes, '') }}: timeoutInMinutes: ${{ parameters.timeoutInMinutes }} + ${{ if ne(parameters.templateContext, '') }}: + templateContext: ${{ parameters.templateContext }} + variables: - ${{ if ne(parameters.enableTelemetry, 'false') }}: - name: DOTNET_CLI_TELEMETRY_PROFILE diff --git a/eng/common/templates/job/job.yml b/eng/common/templates/job/job.yml index e24ca2f46f9..8ec5c4f2d9f 100644 --- a/eng/common/templates/job/job.yml +++ b/eng/common/templates/job/job.yml @@ -15,6 +15,7 @@ parameters: timeoutInMinutes: '' variables: [] workspace: '' + templateContext: '' # Job base template specific parameters # See schema documentation - https://github.com/dotnet/arcade/blob/master/Documentation/AzureDevOps/TemplateSchema.md @@ -68,6 +69,9 @@ jobs: ${{ if ne(parameters.timeoutInMinutes, '') }}: timeoutInMinutes: ${{ parameters.timeoutInMinutes }} + ${{ if ne(parameters.templateContext, '') }}: + templateContext: ${{ parameters.templateContext }} + variables: - ${{ if ne(parameters.enableTelemetry, 'false') }}: - name: DOTNET_CLI_TELEMETRY_PROFILE diff --git a/global.json b/global.json index 599589eadff..189a8c9b73e 100644 --- a/global.json +++ b/global.json @@ -17,7 +17,7 @@ "perl": "5.38.0.1" }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.24151.4", + "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.24158.4", "Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23255.2" } } From 04ddfad51cdb5b8076b01333a300201c7e3564f8 Mon Sep 17 00:00:00 2001 From: Rustam Date: Mon, 11 Mar 2024 20:57:07 +0300 Subject: [PATCH 08/14] Add missing files to Docs (#16848) --- FSharp.sln | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/FSharp.sln b/FSharp.sln index 8846c08339a..a8a5374a585 100644 --- a/FSharp.sln +++ b/FSharp.sln @@ -62,6 +62,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docs", "Docs", "{4E4F41D9-8 docs\optimizations.md = docs\optimizations.md docs\optimizations-equality.md = docs\optimizations-equality.md docs\overview.md = docs\overview.md + docs\builder-caches.md = docs\builder-caches.md + docs\changing-the-ast.md = docs\changing-the-ast.md + docs\names.md = docs\names.md + docs\perf-discussions-archive.md = docs\perf-discussions-archive.md + docs\project-builds.md = docs\project-builds.md + docs\representations.md = docs\representations.md + docs\running-documentation-locally.md = docs\running-documentation-locally.md + docs\tooling-features.md = docs\tooling-features.md EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "fcs", "fcs", "{B86EBFF1-E03E-4FAE-89BF-60A4CAE2BC78}" @@ -79,6 +87,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "fcs", "fcs", "{B86EBFF1-E03 docs\fcs\tokenizer.fsx = docs\fcs\tokenizer.fsx docs\fcs\typedtree.fsx = docs\fcs\typedtree.fsx docs\fcs\untypedtree.fsx = docs\fcs\untypedtree.fsx + docs\fcs\untypedtree-apis.fsx = docs\fcs\untypedtree-apis.fsx EndProjectSection EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "fsc", "src\fsc\fscProject\fsc.fsproj", "{10D15DBB-EFF0-428C-BA83-41600A93EEC4}" @@ -105,6 +114,56 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Benchmarks.Common", "tests\benchmarks\FSharp.Benchmarks.Common\FSharp.Benchmarks.Common.fsproj", "{7D482560-DF6F-46A5-B50C-20ECF7C38759}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "content", "content", "{10F0D468-FD52-4658-811E-7ED6A8318449}" + ProjectSection(SolutionItems) = preProject + docs\content\fsdocs-theme.css = docs\content\fsdocs-theme.css + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "img", "img", "{99773BD6-F1D7-48E2-AD72-AC48DA6BB293}" + ProjectSection(SolutionItems) = preProject + docs\img\favicon.ico = docs\img\favicon.ico + docs\img\logo.png = docs\img\logo.png + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "release-notes", "release-notes", "{C28ABF2D-6B43-4B0F-A12B-38570C5D9A81}" + ProjectSection(SolutionItems) = preProject + docs\release-notes\About.md = docs\release-notes\About.md + docs\release-notes\FSharp.Compiler.Service.fsx = docs\release-notes\FSharp.Compiler.Service.fsx + docs\release-notes\FSharp.Core.fsx = docs\release-notes\FSharp.Core.fsx + docs\release-notes\Language.fsx = docs\release-notes\Language.fsx + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".aux", ".aux", "{F1DADFB8-F320-40B6-B430-0ED5C37D3BAC}" + ProjectSection(SolutionItems) = preProject + docs\release-notes\.aux\Common.fsx = docs\release-notes\.aux\Common.fsx + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".FSharp.Compiler.Service", ".FSharp.Compiler.Service", "{01C43145-5289-47BF-A19B-B9F0FB66254D}" + ProjectSection(SolutionItems) = preProject + docs\release-notes\.FSharp.Compiler.Service\8.0.100.md = docs\release-notes\.FSharp.Compiler.Service\8.0.100.md + docs\release-notes\.FSharp.Compiler.Service\8.0.200.md = docs\release-notes\.FSharp.Compiler.Service\8.0.200.md + docs\release-notes\.FSharp.Compiler.Service\8.0.202.md = docs\release-notes\.FSharp.Compiler.Service\8.0.202.md + docs\release-notes\.FSharp.Compiler.Service\8.0.300.md = docs\release-notes\.FSharp.Compiler.Service\8.0.300.md + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".FSharp.Core", ".FSharp.Core", "{23798638-A1E9-4DAE-9C9C-F5D87499ADD6}" + ProjectSection(SolutionItems) = preProject + docs\release-notes\.FSharp.Core\8.0.200.md = docs\release-notes\.FSharp.Core\8.0.200.md + docs\release-notes\.FSharp.Core\8.0.300.md = docs\release-notes\.FSharp.Core\8.0.300.md + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".Language", ".Language", "{1478B841-73BD-4E68-8F23-413ABB0B991F}" + ProjectSection(SolutionItems) = preProject + docs\release-notes\.Language\8.0.md = docs\release-notes\.Language\8.0.md + docs\release-notes\.Language\preview.md = docs\release-notes\.Language\preview.md + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".VisualStudio", ".VisualStudio", "{AF70EC5A-8E7C-4FDA-857D-AF08082CFC64}" + ProjectSection(SolutionItems) = preProject + docs\release-notes\.VisualStudio\17.9.md = docs\release-notes\.VisualStudio\17.9.md + docs\release-notes\.VisualStudio\17.10.md = docs\release-notes\.VisualStudio\17.10.md + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -433,6 +492,14 @@ Global {BEC6E796-7E53-4888-AAFC-B8FD55C425DF} = {CE70D631-C5DC-417E-9CDA-B16097BEF1AC} {9C7523BA-7AB2-4604-A5FD-653E82C2BAD1} = {CE70D631-C5DC-417E-9CDA-B16097BEF1AC} {7D482560-DF6F-46A5-B50C-20ECF7C38759} = {CE70D631-C5DC-417E-9CDA-B16097BEF1AC} + {10F0D468-FD52-4658-811E-7ED6A8318449} = {4E4F41D9-86A7-4F5D-B735-1A0744AB68AC} + {99773BD6-F1D7-48E2-AD72-AC48DA6BB293} = {4E4F41D9-86A7-4F5D-B735-1A0744AB68AC} + {C28ABF2D-6B43-4B0F-A12B-38570C5D9A81} = {4E4F41D9-86A7-4F5D-B735-1A0744AB68AC} + {F1DADFB8-F320-40B6-B430-0ED5C37D3BAC} = {C28ABF2D-6B43-4B0F-A12B-38570C5D9A81} + {01C43145-5289-47BF-A19B-B9F0FB66254D} = {C28ABF2D-6B43-4B0F-A12B-38570C5D9A81} + {23798638-A1E9-4DAE-9C9C-F5D87499ADD6} = {C28ABF2D-6B43-4B0F-A12B-38570C5D9A81} + {1478B841-73BD-4E68-8F23-413ABB0B991F} = {C28ABF2D-6B43-4B0F-A12B-38570C5D9A81} + {AF70EC5A-8E7C-4FDA-857D-AF08082CFC64} = {C28ABF2D-6B43-4B0F-A12B-38570C5D9A81} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BD5177C7-1380-40E7-94D2-7768E1A8B1B8} From 4fde5da13a191d68c10ad7d92b445c0221de672c Mon Sep 17 00:00:00 2001 From: Florian Verdonck Date: Mon, 11 Mar 2024 19:51:02 +0100 Subject: [PATCH 09/14] Type abbreviation mismatch extended data (#16811) --- .../.FSharp.Compiler.Service/8.0.300.md | 1 + src/Compiler/Checking/SignatureConformance.fs | 11 ++++-- .../Checking/SignatureConformance.fsi | 8 +++++ src/Compiler/Driver/CompilerDiagnostics.fs | 21 +++++++++-- src/Compiler/FSComp.txt | 1 - src/Compiler/FSStrings.resx | 3 ++ src/Compiler/Symbols/FSharpDiagnostic.fs | 10 ++++++ src/Compiler/Symbols/FSharpDiagnostic.fsi | 8 +++++ 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 --- src/Compiler/xlf/FSStrings.cs.xlf | 5 +++ src/Compiler/xlf/FSStrings.de.xlf | 5 +++ src/Compiler/xlf/FSStrings.es.xlf | 5 +++ src/Compiler/xlf/FSStrings.fr.xlf | 5 +++ src/Compiler/xlf/FSStrings.it.xlf | 5 +++ src/Compiler/xlf/FSStrings.ja.xlf | 5 +++ src/Compiler/xlf/FSStrings.ko.xlf | 5 +++ src/Compiler/xlf/FSStrings.pl.xlf | 5 +++ src/Compiler/xlf/FSStrings.pt-BR.xlf | 5 +++ src/Compiler/xlf/FSStrings.ru.xlf | 5 +++ src/Compiler/xlf/FSStrings.tr.xlf | 5 +++ src/Compiler/xlf/FSStrings.zh-Hans.xlf | 5 +++ src/Compiler/xlf/FSStrings.zh-Hant.xlf | 5 +++ .../ExtendedDiagnosticDataTests.fs | 36 +++++++++++++++++++ ...ervice.SurfaceArea.netstandard20.debug.bsl | 5 +++ ...vice.SurfaceArea.netstandard20.release.bsl | 5 +++ tests/fsharp/typeProviders/negTests/neg2h.bsl | 5 ++- 38 files changed, 173 insertions(+), 71 deletions(-) diff --git a/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md b/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md index 148f3734185..f14715ddf7c 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md +++ b/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md @@ -26,6 +26,7 @@ * Add switch to generate types and members with IL visibility that accurately represents their F# visibility. ([PR #15484](https://github.com/dotnet/fsharp/pull/15484) * Allow returning bool instead of unit option for partial active patterns. ([Language suggestion #1041](https://github.com/fsharp/fslang-suggestions/issues/1041), [PR #16473](https://github.com/dotnet/fsharp/pull/16473)) * Symbols: Add GenericArguments to FSharpEntity ([PR #16470](https://github.com/dotnet/fsharp/pull/16470)) +* Add extended data for `DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer` (FS0318). ([PR #16811](https://github.com/dotnet/fsharp/pull/16811))) ### Changed diff --git a/src/Compiler/Checking/SignatureConformance.fs b/src/Compiler/Checking/SignatureConformance.fs index a058182c1a9..08a3be709b4 100644 --- a/src/Compiler/Checking/SignatureConformance.fs +++ b/src/Compiler/Checking/SignatureConformance.fs @@ -39,6 +39,14 @@ exception InterfaceNotRevealed of DisplayEnv * TType * range exception ArgumentsInSigAndImplMismatch of sigArg: Ident * implArg: Ident +exception DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer of + denv: DisplayEnv * + implTycon:Tycon * + sigTycon:Tycon * + implTypeAbbrev:TType * + sigTypeAbbrev:TType * + range: range + // Use a type to capture the constant, common parameters type Checker(g, amap, denv, remapInfo: SignatureRepackageInfo, checkingSig) = @@ -589,8 +597,7 @@ type Checker(g, amap, denv, remapInfo: SignatureRepackageInfo, checkingSig) = match implTycon.TypeAbbrev, sigTycon.TypeAbbrev with | Some ty1, Some ty2 -> if not (typeAEquiv g aenv ty1 ty2) then - let s1, s2, _ = NicePrint.minimalStringsOfTwoTypes denv ty1 ty2 - errorR (Error (FSComp.SR.DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer(implTycon.TypeOrMeasureKind.ToString(), implTycon.DisplayName, s1, s2), m)) + errorR (DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer(denv, implTycon, sigTycon, ty1, ty2, m)) false else true diff --git a/src/Compiler/Checking/SignatureConformance.fsi b/src/Compiler/Checking/SignatureConformance.fsi index c0939f92b35..1b137968945 100644 --- a/src/Compiler/Checking/SignatureConformance.fsi +++ b/src/Compiler/Checking/SignatureConformance.fsi @@ -40,6 +40,14 @@ exception InterfaceNotRevealed of DisplayEnv * TType * range exception ArgumentsInSigAndImplMismatch of sigArg: Ident * implArg: Ident +exception DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer of + denv: DisplayEnv * + implTycon: Tycon * + sigTycon: Tycon * + implTypeAbbrev: TType * + sigTypeAbbrev: TType * + range: range + type Checker = new: diff --git a/src/Compiler/Driver/CompilerDiagnostics.fs b/src/Compiler/Driver/CompilerDiagnostics.fs index 3327aa0a635..596ea9f085d 100644 --- a/src/Compiler/Driver/CompilerDiagnostics.fs +++ b/src/Compiler/Driver/CompilerDiagnostics.fs @@ -79,6 +79,7 @@ type Exception with member exn.DiagnosticRange = match exn with + | DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer(range = m) -> Some m | ArgumentsInSigAndImplMismatch(_, implArg) -> Some implArg.idRange | ErrorFromAddingConstraint(_, exn2, _) -> exn2.DiagnosticRange #if !NO_TYPEPROVIDERS @@ -320,7 +321,7 @@ type Exception with | BadEventTransformation _ -> 91 | HashLoadedScriptConsideredSource _ -> 92 | UnresolvedConversionOperator _ -> 93 - | ArgumentsInSigAndImplMismatch _ -> 3218 + // avoid 94-100 for safety | ObsoleteError _ -> 101 #if !NO_TYPEPROVIDERS @@ -328,6 +329,9 @@ type Exception with | TypeProviders.ProvidedTypeResolution _ -> 103 #endif | PatternMatchCompilation.EnumMatchIncomplete _ -> 104 + | Failure _ -> 192 + | DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer _ -> 318 + | ArgumentsInSigAndImplMismatch _ -> 3218 // Strip TargetInvocationException wrappers | :? TargetInvocationException as e -> e.InnerException.DiagnosticNumber @@ -335,7 +339,6 @@ type Exception with | DiagnosticWithText(n, _, _) -> n | DiagnosticWithSuggestions(n, _, _, _, _) -> n | DiagnosticEnabledWithLanguageFeature(n, _, _, _) -> n - | Failure _ -> 192 | IllegalFileNameChar(fileName, invalidChar) -> fst (FSComp.SR.buildUnexpectedFileNameCharacter (fileName, string invalidChar)) #if !NO_TYPEPROVIDERS | :? TypeProviderError as e -> e.Number @@ -606,6 +609,9 @@ module OldStyleMessages = let TargetInvocationExceptionWrapperE () = Message("TargetInvocationExceptionWrapper", "%s") let ArgumentsInSigAndImplMismatchE () = Message("ArgumentsInSigAndImplMismatch", "%s%s") + let DefinitionsInSigAndImplNotCompatibleAbbreviationsDifferE () = + Message("DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer", "%s%s%s%s") + #if DEBUG let mutable showParserStackOnParseError = false #endif @@ -1857,6 +1863,17 @@ type Exception with | ArgumentsInSigAndImplMismatch(sigArg, implArg) -> os.AppendString(ArgumentsInSigAndImplMismatchE().Format sigArg.idText implArg.idText) + | DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer(denv, implTycon, _sigTycon, implTypeAbbrev, sigTypeAbbrev, _m) -> + let s1, s2, _ = NicePrint.minimalStringsOfTwoTypes denv implTypeAbbrev sigTypeAbbrev + + os.AppendString( + DefinitionsInSigAndImplNotCompatibleAbbreviationsDifferE().Format + (implTycon.TypeOrMeasureKind.ToString()) + implTycon.DisplayName + s1 + s2 + ) + // Strip TargetInvocationException wrappers | :? TargetInvocationException as exn -> exn.InnerException.Output(os, suggestNames) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 5846712049b..838ead87857 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -155,7 +155,6 @@ ValueNotContainedMutabilityInstanceButStatic,"Module '%s' contains\n %s \n 315,DefinitionsInSigAndImplNotCompatibleAbstractMemberMissingInImpl,"The %s definitions for type '%s' in the signature and implementation are not compatible because the abstract member '%s' was required by the signature but was not specified by the implementation" 316,DefinitionsInSigAndImplNotCompatibleAbstractMemberMissingInSig,"The %s definitions for type '%s' in the signature and implementation are not compatible because the abstract member '%s' was present in the implementation but not in the signature" 317,DefinitionsInSigAndImplNotCompatibleSignatureDeclaresDiffer,"The %s definitions for type '%s' in the signature and implementation are not compatible because the signature declares a %s while the implementation declares a %s" -318,DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer,"The %s definitions for type '%s' in the signature and implementation are not compatible because the abbreviations differ: %s versus %s" 319,DefinitionsInSigAndImplNotCompatibleAbbreviationHiddenBySig,"The %s definitions for type '%s' in the signature and implementation are not compatible because an abbreviation is being hidden by a signature. The abbreviation must be visible to other CLI languages. Consider making the abbreviation visible in the signature." 320,DefinitionsInSigAndImplNotCompatibleSigHasAbbreviation,"The %s definitions for type '%s' in the signature and implementation are not compatible because the signature has an abbreviation while the implementation does not" ModuleContainsConstructorButNamesDiffer,"The module contains the constructor\n %s \nbut its signature specifies\n %s \nThe names differ" diff --git a/src/Compiler/FSStrings.resx b/src/Compiler/FSStrings.resx index e24b4737742..d5e19724c80 100644 --- a/src/Compiler/FSStrings.resx +++ b/src/Compiler/FSStrings.resx @@ -1113,6 +1113,9 @@ The argument names in the signature '{0}' and implementation '{1}' do not match. The argument name from the signature file will be used. This may cause problems when debugging or profiling. + + The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3} + keyword 'while!' diff --git a/src/Compiler/Symbols/FSharpDiagnostic.fs b/src/Compiler/Symbols/FSharpDiagnostic.fs index 2c27e7e2ff3..46566d61bbf 100644 --- a/src/Compiler/Symbols/FSharpDiagnostic.fs +++ b/src/Compiler/Symbols/FSharpDiagnostic.fs @@ -106,6 +106,13 @@ module ExtendedData = member x.ImplementationName = implArg.idText member x.SignatureRange = sigArg.idRange member x.ImplementationRange = implArg.idRange + + [] + type DefinitionsInSigAndImplNotCompatibleAbbreviationsDifferExtendedData + internal(signatureType: Tycon, implementationType: Tycon) = + interface IFSharpDiagnosticExtendedData + member x.SignatureRange: range = signatureType.Range + member x.ImplementationRange: range = implementationType.Range open ExtendedData @@ -191,6 +198,9 @@ type FSharpDiagnostic(m: range, severity: FSharpDiagnosticSeverity, message: str | ArgumentsInSigAndImplMismatch(sigArg, implArg) -> Some(ArgumentsInSigAndImplMismatchExtendedData(sigArg, implArg)) + | DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer(implTycon = implTycon; sigTycon = sigTycon) -> + Some(DefinitionsInSigAndImplNotCompatibleAbbreviationsDifferExtendedData(sigTycon, implTycon)) + | _ -> None let msg = diff --git a/src/Compiler/Symbols/FSharpDiagnostic.fsi b/src/Compiler/Symbols/FSharpDiagnostic.fsi index 252a15a33c1..6c941bdd84d 100644 --- a/src/Compiler/Symbols/FSharpDiagnostic.fsi +++ b/src/Compiler/Symbols/FSharpDiagnostic.fsi @@ -101,6 +101,14 @@ module public ExtendedData = /// Argument identifier range within implementation file member ImplementationRange: range + [] + type DefinitionsInSigAndImplNotCompatibleAbbreviationsDifferExtendedData = + interface IFSharpDiagnosticExtendedData + /// Range of the signature type identifier. + member SignatureRange: range + /// Range of the implementation type identifier. + member ImplementationRange: range + open ExtendedData /// Represents a diagnostic produced by the F# compiler diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 66205091123..8d023b7157f 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -2277,11 +2277,6 @@ Definice {0} pro typ {1} v signatuře a implementaci nejsou kompatibilní, protože signatura deklaruje {2}, ale implementace deklaruje {3}. - - The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ: {2} versus {3} - Definice {0} pro typ {1} v signatuře a implementaci nejsou kompatibilní, protože se liší zkratky: {2} oproti {3} - - The {0} definitions for type '{1}' in the signature and implementation are not compatible because an abbreviation is being hidden by a signature. The abbreviation must be visible to other CLI languages. Consider making the abbreviation visible in the signature. Definice {0} pro typ {1} v signatuře a implementaci nejsou kompatibilní, protože signatura skrývá zkratku. Zkratka musí být viditelná pro ostatní jazyky CLI. Zvažte zviditelnění zkratky v signatuře. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index f72b6948a76..a64e570f7b9 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -2277,11 +2277,6 @@ Die {0} Definitionen für den Typ "{1}" in der Signatur und Implementierung sind nicht kompatibel, weil in der Signatur "{2}", in der Implementierung hingegen "{3}" deklariert wird. - - The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ: {2} versus {3} - Die {0} Definitionen für den Typ "{1}" in der Signatur und in der Implementierung sind aufgrund unterschiedlicher Abkürzungen nicht kompatibel: {2} und {3}. - - The {0} definitions for type '{1}' in the signature and implementation are not compatible because an abbreviation is being hidden by a signature. The abbreviation must be visible to other CLI languages. Consider making the abbreviation visible in the signature. Die {0} Definitionen für den Typ "{1}" in der Signatur und in der Implementierung sind nicht kompatibel, weil eine Abkürzung von einer Signatur verdeckt wird. Die Abkürzung muss für andere CLI-Sprachen sichtbar sein. Sorgen Sie dafür, dass die Abkürzung in der Signatur sichtbar ist. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 12f4457f73e..77d35305506 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -2277,11 +2277,6 @@ Las definiciones de {0} para el tipo "{1}" en la signatura y la implementación no son compatibles porque la signatura declara un {2} mientras la implementación declara un {3} - - The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ: {2} versus {3} - Las definiciones de {0} para el tipo "{1}" de la signatura y la implementación no son compatibles porque las abreviaciones difieren: {2} frente a {3} - - The {0} definitions for type '{1}' in the signature and implementation are not compatible because an abbreviation is being hidden by a signature. The abbreviation must be visible to other CLI languages. Consider making the abbreviation visible in the signature. Las definiciones de {0} para el tipo "{1}" de la signatura y la implementación no son compatibles porque una signatura oculta una abreviación. La abreviación debe estar visible para otros lenguajes CLI. Considere hacer que la abreviación esté visible en la signatura. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 9477b8b7680..03ce9378c00 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -2277,11 +2277,6 @@ Les {0} définitions pour le type '{1}' dans la signature et l'implémentation ne sont pas compatibles, car la signature déclare {2} alors que l'implémentation déclare {3} - - The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ: {2} versus {3} - Les {0} définitions pour le type '{1}' dans la signature et l'implémentation ne sont pas compatibles, car les abréviations sont différentes : {2} par opposition à {3} - - The {0} definitions for type '{1}' in the signature and implementation are not compatible because an abbreviation is being hidden by a signature. The abbreviation must be visible to other CLI languages. Consider making the abbreviation visible in the signature. Les {0} définitions pour le type '{1}' dans la signature et l'implémentation ne sont pas compatibles, car une abréviation est masquée par une signature. L'abréviation doit être visible par les autres langages CLI. Rendez l'abréviation visible dans la signature. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index b17ab37848d..2344a13f7a1 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -2277,11 +2277,6 @@ Le definizioni di {0} per il tipo '{1}' nella firma e nell'implementazione non sono compatibili perché la firma dichiara {2} mentre l'implementazione dichiara {3} - - The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ: {2} versus {3} - Le definizioni di {0} per il tipo '{1}' nella firma e nell'implementazione non sono compatibili perché le abbreviazioni sono diverse: {2} invece di {3} - - The {0} definitions for type '{1}' in the signature and implementation are not compatible because an abbreviation is being hidden by a signature. The abbreviation must be visible to other CLI languages. Consider making the abbreviation visible in the signature. Le definizioni di {0} per il tipo '{1}' nella firma e nell'implementazione non sono compatibili perché un'abbreviazione è nascosta da una firma. L'abbreviazione deve essere visibile ad altri linguaggi CLI. Provare a rendere visibile l'abbreviazione nella firma. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index fa6fb18bda6..53c737bbfcf 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -2277,11 +2277,6 @@ シグネチャは {2} を宣言していますが、実装では {3} を宣言しているため、シグネチャおよび実装内の型 '{1}' の {0} 定義は互換性がありません - - The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ: {2} versus {3} - シグネチャおよび実装内の型 '{1}' の {0} 定義は、省略形が異なるため ({2} と {3})、互換性がありません - - The {0} definitions for type '{1}' in the signature and implementation are not compatible because an abbreviation is being hidden by a signature. The abbreviation must be visible to other CLI languages. Consider making the abbreviation visible in the signature. 省略形がシグネチャによって隠ぺいされているため、シグネチャおよび実装の型 '{1}' の {0} 定義に互換性がありません。省略形は他の CLI 言語から参照できるようにする必要があります。シグネチャ内の省略形を参照できるようにしてください。 diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 1cf38ecd52e..5ff6910f893 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -2277,11 +2277,6 @@ 시그니처가 {2}을(를) 선언하지만 구현은 {3}을(를) 선언하므로 시그니처 및 구현의 '{1}' 형식에 대한 {0} 정의가 호환되지 않습니다. - - The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ: {2} versus {3} - 약어가 {2}과(와) {3}(으)로 서로 다르므로 시그니처 및 구현의 '{1}' 형식에 대한 {0} 정의가 호환되지 않습니다. - - The {0} definitions for type '{1}' in the signature and implementation are not compatible because an abbreviation is being hidden by a signature. The abbreviation must be visible to other CLI languages. Consider making the abbreviation visible in the signature. 시그니처에 의해 약어가 숨겨져 있으므로 시그니처 및 구현의 '{1}' 형식에 대한 {0} 정의가 호환되지 않습니다. 약어는 다른 CLI 언어에 표시되어야 합니다. 시그니처에서 약어를 표시하세요. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index a36f1d7cb51..266d64c82cd 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -2277,11 +2277,6 @@ Definicje {0} dla typu „{1}” w sygnaturze i implementacji są niezgodne, ponieważ sygnatura deklaruje element {2}, natomiast implementacja deklaruje element {3} - - The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ: {2} versus {3} - Definicje {0} dla typu „{1}” w sygnaturze i implementacji są niezgodne, ponieważ skróty są różne: {2} i {3} - - The {0} definitions for type '{1}' in the signature and implementation are not compatible because an abbreviation is being hidden by a signature. The abbreviation must be visible to other CLI languages. Consider making the abbreviation visible in the signature. Definicje {0} dla typu „{1}” w sygnaturze i implementacji są niezgodne, ponieważ skrót jest ukrywany przez sygnaturę. Skrót musi być widoczny dla innych języków infrastruktury CLI. Rozważ zapewnienie widoczności skrótu w sygnaturze. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 129e7cb792e..345fd834ac0 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -2277,11 +2277,6 @@ As definições {0} para o tipo '{1}' na assinatura e implementação não são compatíveis, pois a assinatura declara um {2} enquanto a implementação declara um {3} - - The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ: {2} versus {3} - As definições {0} para o tipo '{1}' na assinatura e implementação não são compatíveis, pois as abreviações são diferentes: {2} versus {3} - - The {0} definitions for type '{1}' in the signature and implementation are not compatible because an abbreviation is being hidden by a signature. The abbreviation must be visible to other CLI languages. Consider making the abbreviation visible in the signature. As definições {0} para o tipo '{1}' na assinatura e implementação não são compatíveis, pois uma abreviação está sendo ocultada por uma assinatura. A abreviação deve estar visível a outras linguagens CLIs. Considere deixar a abreviação visível na assinatura. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index d0acf9ef585..8daa89725d2 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -2277,11 +2277,6 @@ Определения {0} для типа "{1}" в сигнатуре и реализации несовместимы, так как сигнатура объявляет {2}, а реализация — {3}. - - The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ: {2} versus {3} - Определения {0} для типа "{1}" в сигнатуре и реализации несовместимы, так как сокращения различаются: {2} в сравнении с {3}. - - The {0} definitions for type '{1}' in the signature and implementation are not compatible because an abbreviation is being hidden by a signature. The abbreviation must be visible to other CLI languages. Consider making the abbreviation visible in the signature. Определения {0} для типа "{1}" в сигнатуре и реализации несовместимы, так как сокращение скрывается сигнатурой. Сокращение должно быть видимым для других языков CLI. Попробуйте сделать сокращение видимым в сигнатуре. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 555f737153e..b062ac01ce4 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -2277,11 +2277,6 @@ İmzada {2} bildirilirken uygulamada {3} bildirildiğinden, imza ve uygulamadaki '{1}' türü için {0} tanımları uyumlu değil - - The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ: {2} versus {3} - Kısaltmalar farklı olduğundan ({2} ve {3}), imza ve uygulamadaki '{1}' türü için {0} tanımları uyumlu değil - - The {0} definitions for type '{1}' in the signature and implementation are not compatible because an abbreviation is being hidden by a signature. The abbreviation must be visible to other CLI languages. Consider making the abbreviation visible in the signature. Bir kısaltma imza ile gizlendiğinden, imza ve uygulamadaki '{1}' türü için {0} tanımları uyumlu değil. Kısaltmanın diğer CLI dilleri tarafından görünebilir olması gerekir. Kısaltmayı imzada görünür yapmayı düşünün. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 72e2ea8f447..b8a8910a995 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -2277,11 +2277,6 @@ 签名和实现中类型“{1}”的 {0} 定义不兼容,因为签名声明的是 {2},而实现声明的是 {3} - - The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ: {2} versus {3} - 签名和实现中类型“{1}”的 {0} 定义不兼容,因为缩写不同: {2} 与 {3} - - The {0} definitions for type '{1}' in the signature and implementation are not compatible because an abbreviation is being hidden by a signature. The abbreviation must be visible to other CLI languages. Consider making the abbreviation visible in the signature. 签名和实现中类型“{1}”的 {0} 定义不兼容,因为签名将隐藏缩写。缩写必须对其他 CLI 语言可见。请考虑使缩写在签名中可见。 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 817e803623b..bbf312f436b 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -2277,11 +2277,6 @@ 簽章與實作中類型 '{1}' 的 {0} 定義不相容,因為簽章宣告 {2},而實作則宣告 {3} - - The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ: {2} versus {3} - 簽章與實作中類型 '{1}' 的 {0} 定義不相容,因為縮寫不同: {2} 與 {3} - - The {0} definitions for type '{1}' in the signature and implementation are not compatible because an abbreviation is being hidden by a signature. The abbreviation must be visible to other CLI languages. Consider making the abbreviation visible in the signature. 簽章與實作中類型 '{1}' 的 {0} 定義不相容,因為簽章隱藏了某縮寫。其他 CLI 語言必須可看見該縮寫。請考慮使縮寫在簽章中可見。 diff --git a/src/Compiler/xlf/FSStrings.cs.xlf b/src/Compiler/xlf/FSStrings.cs.xlf index a3412bfc48c..6a3e83c532a 100644 --- a/src/Compiler/xlf/FSStrings.cs.xlf +++ b/src/Compiler/xlf/FSStrings.cs.xlf @@ -7,6 +7,11 @@ Názvy argumentů v signatuře {0} a implementaci {1} si neodpovídají. Použije se název argumentu ze souboru signatury. To může způsobit problémy při ladění nebo profilování. + + The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3} + The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3} + + Type mismatch. Expecting a tuple of length {0} of type\n {1} \nbut given a tuple of length {2} of type\n {3} {4}\n Neshoda typů Očekává se řazená kolekce členů o délce {0} typu\n {1} \nale odevzdala se řazená kolekce členů o délce {2} typu\n {3}{4}\n diff --git a/src/Compiler/xlf/FSStrings.de.xlf b/src/Compiler/xlf/FSStrings.de.xlf index d1028719674..8777c4ab388 100644 --- a/src/Compiler/xlf/FSStrings.de.xlf +++ b/src/Compiler/xlf/FSStrings.de.xlf @@ -7,6 +7,11 @@ Die Argumentnamen in Signatur "{0}" und Implementierung "{1}" stimmen nicht überein. Der Argumentname aus der Signaturdatei wird verwendet. Dadurch können Probleme beim Debuggen oder bei der Profilerstellung auftreten. + + The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3} + The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3} + + Type mismatch. Expecting a tuple of length {0} of type\n {1} \nbut given a tuple of length {2} of type\n {3} {4}\n Typenkonflikt. Es wurde ein Tupel der Länge {0} des Typs\n {1} \nerwartet, aber ein Tupel der Länge {2} des Typs\n {3}{4}\n angegeben. diff --git a/src/Compiler/xlf/FSStrings.es.xlf b/src/Compiler/xlf/FSStrings.es.xlf index 213872bb8d7..6484fb847fb 100644 --- a/src/Compiler/xlf/FSStrings.es.xlf +++ b/src/Compiler/xlf/FSStrings.es.xlf @@ -7,6 +7,11 @@ Los nombres de argumento en la firma "{0}" y la implementación "{1}" no coinciden. Se utilizará el nombre del argumento desde el archivo de firma. Esto puede causar problemas durante la depuración o la generación de perfiles. + + The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3} + The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3} + + Type mismatch. Expecting a tuple of length {0} of type\n {1} \nbut given a tuple of length {2} of type\n {3} {4}\n Error de coincidencia de tipos. Se espera una tupla de longitud {0} de tipo\n {1} \nperero se ha proporcionado una tupla de longitud {2} de tipo\n {3}{4}\n diff --git a/src/Compiler/xlf/FSStrings.fr.xlf b/src/Compiler/xlf/FSStrings.fr.xlf index 7539cba3a7b..3b15aaca563 100644 --- a/src/Compiler/xlf/FSStrings.fr.xlf +++ b/src/Compiler/xlf/FSStrings.fr.xlf @@ -7,6 +7,11 @@ Les noms d'arguments dans la signature '{0}' et l'implémentation '{1}' ne correspondent pas. Le nom d'argument du fichier de signature va être utilisé. Cela peut entraîner des problèmes durant le débogage ou le profilage. + + The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3} + The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3} + + Type mismatch. Expecting a tuple of length {0} of type\n {1} \nbut given a tuple of length {2} of type\n {3} {4}\n Incompatibilité de type. Tuple de longueur attendu {0} de type\n {1} \nmais tuple de longueur {2} de type\n {3}{4}\n diff --git a/src/Compiler/xlf/FSStrings.it.xlf b/src/Compiler/xlf/FSStrings.it.xlf index b4e6abe8be9..304025244e0 100644 --- a/src/Compiler/xlf/FSStrings.it.xlf +++ b/src/Compiler/xlf/FSStrings.it.xlf @@ -7,6 +7,11 @@ I nomi degli argomenti nella firma '{0}' e nell'implementazione '{1}' non corrispondono. Verrà usato il nome dell'argomento del file di firma. Questa situazione potrebbe causare problemi durante il debug o la profilatura. + + The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3} + The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3} + + Type mismatch. Expecting a tuple of length {0} of type\n {1} \nbut given a tuple of length {2} of type\n {3} {4}\n Tipo non corrispondente. È prevista una tupla di lunghezza {0} di tipo\n {1} \n, ma è stata specificata una tupla di lunghezza {2} di tipo\n {3}{4}\n diff --git a/src/Compiler/xlf/FSStrings.ja.xlf b/src/Compiler/xlf/FSStrings.ja.xlf index d465315dfa1..31ba40fcb3d 100644 --- a/src/Compiler/xlf/FSStrings.ja.xlf +++ b/src/Compiler/xlf/FSStrings.ja.xlf @@ -7,6 +7,11 @@ シグネチャ '{0}' と実装 '{1}' の引数の名前が一致しません。シグネチャ ファイルの引数の名前が使用されます。デバッグまたはプロファイルするときに問題が生じる原因となる可能性があります。 + + The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3} + The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3} + + Type mismatch. Expecting a tuple of length {0} of type\n {1} \nbut given a tuple of length {2} of type\n {3} {4}\n 型が一致しません。型の長さ {0} のタプルが必要です\n {1} \nただし、型の長さ {2} のタプルが指定された場合\n {3}{4}\n diff --git a/src/Compiler/xlf/FSStrings.ko.xlf b/src/Compiler/xlf/FSStrings.ko.xlf index 1e4bb958ae6..f0bbe7c8aae 100644 --- a/src/Compiler/xlf/FSStrings.ko.xlf +++ b/src/Compiler/xlf/FSStrings.ko.xlf @@ -7,6 +7,11 @@ 시그니처 '{0}'과(와) 구현 '{1}'의 인수 이름이 일치하지 않습니다. 시그니처 파일의 인수 이름이 사용됩니다. 이로 인해 디버깅 또는 프로파일링 시 문제가 발생할 수 있습니다. + + The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3} + The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3} + + Type mismatch. Expecting a tuple of length {0} of type\n {1} \nbut given a tuple of length {2} of type\n {3} {4}\n 유형 불일치. 형식이 \n {1}이고 길이가 {0}인 튜플이 필요합니다. \n그러나 형식이 \n {3}이고 길이가 {2}인 튜플이 제공되었습니다.{4}\n diff --git a/src/Compiler/xlf/FSStrings.pl.xlf b/src/Compiler/xlf/FSStrings.pl.xlf index c7087e22b98..3020002ce7c 100644 --- a/src/Compiler/xlf/FSStrings.pl.xlf +++ b/src/Compiler/xlf/FSStrings.pl.xlf @@ -7,6 +7,11 @@ Nazwy argumentów w podpisie „{0}” i implementacji „{1}” nie są zgodne. Używana będzie nazwa argumentu z pliku podpisu. Może to spowodować problemy podczas debugowania lub profilowania. + + The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3} + The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3} + + Type mismatch. Expecting a tuple of length {0} of type\n {1} \nbut given a tuple of length {2} of type\n {3} {4}\n Niezgodność. Oczekiwano krotki o długości {0} typu\n {1} \nale otrzymano krotkę o długości {2} typu\n {3}{4}\n diff --git a/src/Compiler/xlf/FSStrings.pt-BR.xlf b/src/Compiler/xlf/FSStrings.pt-BR.xlf index ba29b433934..b5647b8d0eb 100644 --- a/src/Compiler/xlf/FSStrings.pt-BR.xlf +++ b/src/Compiler/xlf/FSStrings.pt-BR.xlf @@ -7,6 +7,11 @@ Os nomes de argumento na assinatura '{0}' e na implementação '{1}' não coincidem. O nome do argumento do arquivo da assinatura será usado. Isso pode causar problemas durante a depuração ou a criação de perfil. + + The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3} + The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3} + + Type mismatch. Expecting a tuple of length {0} of type\n {1} \nbut given a tuple of length {2} of type\n {3} {4}\n Tipo incompatível. Esperando uma tupla de comprimento {0} do tipo\n {1} \nmas recebeu uma tupla de comprimento {2} do tipo\n {3}{4}\n diff --git a/src/Compiler/xlf/FSStrings.ru.xlf b/src/Compiler/xlf/FSStrings.ru.xlf index ecd597b4349..b47eb92bdc3 100644 --- a/src/Compiler/xlf/FSStrings.ru.xlf +++ b/src/Compiler/xlf/FSStrings.ru.xlf @@ -7,6 +7,11 @@ Имена аргументов в сигнатуре "{0}" и реализации "{1}" не совпадают. Будет использоваться имя аргумента из файла сигнатуры. Это может вызвать проблемы при отладке или профилировании. + + The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3} + The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3} + + Type mismatch. Expecting a tuple of length {0} of type\n {1} \nbut given a tuple of length {2} of type\n {3} {4}\n Несоответствие типов. Ожидается кортеж длиной {0} типа\n {1}, \nно предоставлен кортеж длиной {2} типа\n {3}{4}\n diff --git a/src/Compiler/xlf/FSStrings.tr.xlf b/src/Compiler/xlf/FSStrings.tr.xlf index e0b5f943f15..2fc08de7f13 100644 --- a/src/Compiler/xlf/FSStrings.tr.xlf +++ b/src/Compiler/xlf/FSStrings.tr.xlf @@ -7,6 +7,11 @@ {0}' imzası ve '{1}' uygulaması içindeki bağımsız değişken adları eşleşmiyor. İmza dosyasındaki bağımsız değişken adı kullanılacak. Bu, hata ayıklama veya profil oluşturma sırasında sorunlara neden olabilir. + + The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3} + The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3} + + Type mismatch. Expecting a tuple of length {0} of type\n {1} \nbut given a tuple of length {2} of type\n {3} {4}\n Tür uyuşmazlığı. {0} uzunluğunda türü\n {1} \nolan bir demet bekleniyordu ancak {2} uzunluğunda türü\n {3}{4}\nolan bir demet verildi diff --git a/src/Compiler/xlf/FSStrings.zh-Hans.xlf b/src/Compiler/xlf/FSStrings.zh-Hans.xlf index 9525488aa9b..f81bb2b61c7 100644 --- a/src/Compiler/xlf/FSStrings.zh-Hans.xlf +++ b/src/Compiler/xlf/FSStrings.zh-Hans.xlf @@ -7,6 +7,11 @@ 签名“{0}”和实现“{1}”中的参数名称不匹配。将使用签名文件中的参数名称。在进行调试或分析时这可能会导致问题。 + + The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3} + The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3} + + Type mismatch. Expecting a tuple of length {0} of type\n {1} \nbut given a tuple of length {2} of type\n {3} {4}\n 类型不匹配。应为长度为 {0} 的类型的元组\n {1} \n但提供了长度为 {2} 的类型的元组\n {3}{4}\n diff --git a/src/Compiler/xlf/FSStrings.zh-Hant.xlf b/src/Compiler/xlf/FSStrings.zh-Hant.xlf index c2181e3f317..d0de30dc7ff 100644 --- a/src/Compiler/xlf/FSStrings.zh-Hant.xlf +++ b/src/Compiler/xlf/FSStrings.zh-Hant.xlf @@ -7,6 +7,11 @@ 特徵標記 '{0}' 和實作 '{1}' 中的引數名稱不相符。將會使用特徵標記檔案中的引數名稱。這可能會在偵錯或分析時造成問題。 + + The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3} + The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3} + + Type mismatch. Expecting a tuple of length {0} of type\n {1} \nbut given a tuple of length {2} of type\n {3} {4}\n 類型不符。必須是類型為\n {1} \n 的元組長度 {0},但提供的是類型為\n {3}{4}\n 的元組長度 {2} diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ExtendedDiagnosticDataTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ExtendedDiagnosticDataTests.fs index eec3ce03dcd..65a1cceb43d 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ExtendedDiagnosticDataTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ExtendedDiagnosticDataTests.fs @@ -1,6 +1,7 @@ module ErrorMessages.ExtendedDiagnosticData #nowarn "57" +open FSharp.Compiler.Text open FSharp.Compiler.Diagnostics open FSharp.Compiler.Diagnostics.ExtendedData open FSharp.Test @@ -205,3 +206,38 @@ id (193, "This expression is a function value, i.e. is missing arguments. Its type is 'a -> 'a.") (fun (wrongType: ExpressionIsAFunctionExtendedData) -> Assert.Equal("type 'a -> 'a", wrongType.ActualType.ToString())) + +let private assertRange + (expectedStartLine: int, expectedStartColumn: int) + (expectedEndLine: int, expectedEndColumn: int) + (actualRange: range) + : unit = + Assert.Equal(Position.mkPos expectedStartLine expectedStartColumn, actualRange.Start) + Assert.Equal(Position.mkPos expectedEndLine expectedEndColumn, actualRange.End) + +[] +[] +[] +let ``DefinitionsInSigAndImplNotCompatibleAbbreviationsDifferExtendedData 01`` useTransparentCompiler = + let signature = + Fsi """ +namespace Project + +type Foo = {| bar: int |} + """ + + let implementation = + FsSource """ +namespace Project + +type Foo = {| bar: int; x: int |} + """ + + signature + |> withAdditionalSourceFile implementation + |> typecheckProject true useTransparentCompiler + |> checkDiagnostic + (318, "The type definitions for type 'Foo' in the signature and implementation are not compatible because the abbreviations differ:\n {| bar: int; x: int |}\nversus\n {| bar: int |}") + (fun (fieldsData: DefinitionsInSigAndImplNotCompatibleAbbreviationsDifferExtendedData) -> + assertRange (4,5) (4,8) fieldsData.SignatureRange + assertRange (4,6) (4,9) fieldsData.ImplementationRange) diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl index 3c4b22f76c1..cdbdb81bda0 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl @@ -2514,6 +2514,10 @@ FSharp.Compiler.Diagnostics.ExtendedData+ArgumentsInSigAndImplMismatchExtendedDa FSharp.Compiler.Diagnostics.ExtendedData+ArgumentsInSigAndImplMismatchExtendedData: System.String SignatureName FSharp.Compiler.Diagnostics.ExtendedData+ArgumentsInSigAndImplMismatchExtendedData: System.String get_ImplementationName() FSharp.Compiler.Diagnostics.ExtendedData+ArgumentsInSigAndImplMismatchExtendedData: System.String get_SignatureName() +FSharp.Compiler.Diagnostics.ExtendedData+DefinitionsInSigAndImplNotCompatibleAbbreviationsDifferExtendedData: FSharp.Compiler.Text.Range ImplementationRange +FSharp.Compiler.Diagnostics.ExtendedData+DefinitionsInSigAndImplNotCompatibleAbbreviationsDifferExtendedData: FSharp.Compiler.Text.Range SignatureRange +FSharp.Compiler.Diagnostics.ExtendedData+DefinitionsInSigAndImplNotCompatibleAbbreviationsDifferExtendedData: FSharp.Compiler.Text.Range get_ImplementationRange() +FSharp.Compiler.Diagnostics.ExtendedData+DefinitionsInSigAndImplNotCompatibleAbbreviationsDifferExtendedData: FSharp.Compiler.Text.Range get_SignatureRange() FSharp.Compiler.Diagnostics.ExtendedData+DiagnosticContextInfo+Tags: Int32 CollectionElement FSharp.Compiler.Diagnostics.ExtendedData+DiagnosticContextInfo+Tags: Int32 DowncastUsedInsteadOfUpcast FSharp.Compiler.Diagnostics.ExtendedData+DiagnosticContextInfo+Tags: Int32 ElseBranchResult @@ -2615,6 +2619,7 @@ FSharp.Compiler.Diagnostics.ExtendedData+ValueNotContainedDiagnosticExtendedData FSharp.Compiler.Diagnostics.ExtendedData+ValueNotContainedDiagnosticExtendedData: FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue get_ImplementationValue() FSharp.Compiler.Diagnostics.ExtendedData+ValueNotContainedDiagnosticExtendedData: FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue get_SignatureValue() FSharp.Compiler.Diagnostics.ExtendedData: FSharp.Compiler.Diagnostics.ExtendedData+ArgumentsInSigAndImplMismatchExtendedData +FSharp.Compiler.Diagnostics.ExtendedData: FSharp.Compiler.Diagnostics.ExtendedData+DefinitionsInSigAndImplNotCompatibleAbbreviationsDifferExtendedData FSharp.Compiler.Diagnostics.ExtendedData: FSharp.Compiler.Diagnostics.ExtendedData+DiagnosticContextInfo FSharp.Compiler.Diagnostics.ExtendedData: FSharp.Compiler.Diagnostics.ExtendedData+ExpressionIsAFunctionExtendedData FSharp.Compiler.Diagnostics.ExtendedData: FSharp.Compiler.Diagnostics.ExtendedData+FieldNotContainedDiagnosticExtendedData diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl index 3c4b22f76c1..cdbdb81bda0 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl @@ -2514,6 +2514,10 @@ FSharp.Compiler.Diagnostics.ExtendedData+ArgumentsInSigAndImplMismatchExtendedDa FSharp.Compiler.Diagnostics.ExtendedData+ArgumentsInSigAndImplMismatchExtendedData: System.String SignatureName FSharp.Compiler.Diagnostics.ExtendedData+ArgumentsInSigAndImplMismatchExtendedData: System.String get_ImplementationName() FSharp.Compiler.Diagnostics.ExtendedData+ArgumentsInSigAndImplMismatchExtendedData: System.String get_SignatureName() +FSharp.Compiler.Diagnostics.ExtendedData+DefinitionsInSigAndImplNotCompatibleAbbreviationsDifferExtendedData: FSharp.Compiler.Text.Range ImplementationRange +FSharp.Compiler.Diagnostics.ExtendedData+DefinitionsInSigAndImplNotCompatibleAbbreviationsDifferExtendedData: FSharp.Compiler.Text.Range SignatureRange +FSharp.Compiler.Diagnostics.ExtendedData+DefinitionsInSigAndImplNotCompatibleAbbreviationsDifferExtendedData: FSharp.Compiler.Text.Range get_ImplementationRange() +FSharp.Compiler.Diagnostics.ExtendedData+DefinitionsInSigAndImplNotCompatibleAbbreviationsDifferExtendedData: FSharp.Compiler.Text.Range get_SignatureRange() FSharp.Compiler.Diagnostics.ExtendedData+DiagnosticContextInfo+Tags: Int32 CollectionElement FSharp.Compiler.Diagnostics.ExtendedData+DiagnosticContextInfo+Tags: Int32 DowncastUsedInsteadOfUpcast FSharp.Compiler.Diagnostics.ExtendedData+DiagnosticContextInfo+Tags: Int32 ElseBranchResult @@ -2615,6 +2619,7 @@ FSharp.Compiler.Diagnostics.ExtendedData+ValueNotContainedDiagnosticExtendedData FSharp.Compiler.Diagnostics.ExtendedData+ValueNotContainedDiagnosticExtendedData: FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue get_ImplementationValue() FSharp.Compiler.Diagnostics.ExtendedData+ValueNotContainedDiagnosticExtendedData: FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue get_SignatureValue() FSharp.Compiler.Diagnostics.ExtendedData: FSharp.Compiler.Diagnostics.ExtendedData+ArgumentsInSigAndImplMismatchExtendedData +FSharp.Compiler.Diagnostics.ExtendedData: FSharp.Compiler.Diagnostics.ExtendedData+DefinitionsInSigAndImplNotCompatibleAbbreviationsDifferExtendedData FSharp.Compiler.Diagnostics.ExtendedData: FSharp.Compiler.Diagnostics.ExtendedData+DiagnosticContextInfo FSharp.Compiler.Diagnostics.ExtendedData: FSharp.Compiler.Diagnostics.ExtendedData+ExpressionIsAFunctionExtendedData FSharp.Compiler.Diagnostics.ExtendedData: FSharp.Compiler.Diagnostics.ExtendedData+FieldNotContainedDiagnosticExtendedData diff --git a/tests/fsharp/typeProviders/negTests/neg2h.bsl b/tests/fsharp/typeProviders/negTests/neg2h.bsl index cd6f4a2a1fc..c710ffaa959 100644 --- a/tests/fsharp/typeProviders/negTests/neg2h.bsl +++ b/tests/fsharp/typeProviders/negTests/neg2h.bsl @@ -1,2 +1,5 @@ -neg2h.fs(4,6,4,7): typecheck error FS0318: The type definitions for type 'A' in the signature and implementation are not compatible because the abbreviations differ: FSharp.HelloWorld.HelloWorldTypeWithStaticInt32Parameter<2> versus FSharp.HelloWorld.HelloWorldTypeWithStaticInt32Parameter<1> +neg2h.fs(4,6,4,7): typecheck error FS0318: The type definitions for type 'A' in the signature and implementation are not compatible because the abbreviations differ: + FSharp.HelloWorld.HelloWorldTypeWithStaticInt32Parameter<2> +versus + FSharp.HelloWorld.HelloWorldTypeWithStaticInt32Parameter<1> From 73e331ab166b1bfd1c4822260f166e40039df3fe Mon Sep 17 00:00:00 2001 From: Jakub Majocha <1760221+majocha@users.noreply.github.com> Date: Tue, 12 Mar 2024 10:32:08 +0100 Subject: [PATCH 10/14] deflake GetAllUsesOfAllSymbols test (#16858) --- .../FSharpChecker/CommonWorkflows.fs | 3 +-- tests/FSharp.Test.Utilities/ProjectGeneration.fs | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/FSharpChecker/CommonWorkflows.fs b/tests/FSharp.Compiler.ComponentTests/FSharpChecker/CommonWorkflows.fs index 735e7828b89..bcdc3517394 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharpChecker/CommonWorkflows.fs +++ b/tests/FSharp.Compiler.ComponentTests/FSharpChecker/CommonWorkflows.fs @@ -155,14 +155,13 @@ let GetAllUsesOfAllSymbols() = let result = async { let project = makeTestProject() - let checker = ProjectWorkflowBuilder(project, useGetSource=true, useChangeNotifications = true).Checker + let checker = ProjectWorkflowBuilder(project, useGetSource=true, useChangeNotifications = true, enablePartialTypeChecking = false).Checker do! saveProject project false checker let options = project.GetProjectOptions checker let! checkProjectResults = checker.ParseAndCheckProject(options) return checkProjectResults.GetAllUsesOfAllSymbols() } |> Async.RunSynchronously - traceProvider.ForceFlush() |> ignore traceProvider.Dispose() diff --git a/tests/FSharp.Test.Utilities/ProjectGeneration.fs b/tests/FSharp.Test.Utilities/ProjectGeneration.fs index 998f2bd201d..ad3660747fe 100644 --- a/tests/FSharp.Test.Utilities/ProjectGeneration.fs +++ b/tests/FSharp.Test.Utilities/ProjectGeneration.fs @@ -934,7 +934,8 @@ type ProjectWorkflowBuilder ?useTransparentCompiler, ?runTimeout, ?autoStart, - ?isExistingProject + ?isExistingProject, + ?enablePartialTypeChecking ) = let useTransparentCompiler = defaultArg useTransparentCompiler CompilerAssertHelpers.UseTransparentCompiler @@ -955,7 +956,7 @@ type ProjectWorkflowBuilder (FSharpChecker.Create( keepAllBackgroundSymbolUses = true, enableBackgroundItemKeyStoreAndSemanticClassification = true, - enablePartialTypeChecking = true, + enablePartialTypeChecking = defaultArg enablePartialTypeChecking true, captureIdentifiersWhenParsing = true, documentSource = (if useGetSource then DocumentSource.Custom getSource else DocumentSource.FileSystem), useSyntaxTreeCache = defaultArg useSyntaxTreeCache false, From be658c56fe5436b6b3dd8ac291ef118f8f9cc4eb Mon Sep 17 00:00:00 2001 From: Eugene Auduchinok Date: Tue, 12 Mar 2024 11:01:25 +0100 Subject: [PATCH 11/14] Completion: don't prevent getting items after record definition (#16813) * Completion: don't prevent getting items after record definition * Release notes * Fantomas * Add test --------- Co-authored-by: Vlad Zarytovskii --- docs/release-notes/.FSharp.Compiler.Service/8.0.300.md | 1 + src/Compiler/Service/ServiceParsedInputOps.fs | 8 ++++++-- tests/service/CompletionTests.fs | 9 +++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md b/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md index f14715ddf7c..29d414d88f4 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md +++ b/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md @@ -16,6 +16,7 @@ * Enforce AttributeTargets on let values and functions. ([PR #16692](https://github.com/dotnet/fsharp/pull/16692)) * Enforce AttributeTargets on union case declarations. ([PR #16764](https://github.com/dotnet/fsharp/pull/16764)) * Disallow using base to invoke an abstract base method. ([Issue #13926](https://github.com/dotnet/fsharp/issues/13926), [PR #16773](https://github.com/dotnet/fsharp/pull/16773)) +* Fix broken code completion after a record type declaration ([PR #16813]([Title](https://github.com/dotnet/fsharp/pull/16813))) ### Added diff --git a/src/Compiler/Service/ServiceParsedInputOps.fs b/src/Compiler/Service/ServiceParsedInputOps.fs index f1a8d3e9737..90062e81c68 100644 --- a/src/Compiler/Service/ServiceParsedInputOps.fs +++ b/src/Compiler/Service/ServiceParsedInputOps.fs @@ -1644,7 +1644,7 @@ module ParsedInput = | SynType.LongIdent _ when rangeContainsPos ty.Range pos -> Some CompletionContext.Type | _ -> defaultTraverse ty - member _.VisitRecordDefn(_, fields, _) = + member _.VisitRecordDefn(_, fields, range) = fields |> List.tryPick (fun (SynField(idOpt = idOpt; range = fieldRange)) -> match idOpt with @@ -1653,7 +1653,11 @@ module ParsedInput = | _ when rangeContainsPos fieldRange pos -> Some(CompletionContext.RecordField(RecordContext.Declaration false)) | _ -> None) // No completions in a record outside of all fields, except in attributes, which is established earlier in VisitAttributeApplication - |> Option.orElse (Some CompletionContext.Invalid) + |> Option.orElseWith (fun _ -> + if rangeContainsPos range pos then + Some CompletionContext.Invalid + else + None) member _.VisitUnionDefn(_, cases, _) = cases diff --git a/tests/service/CompletionTests.fs b/tests/service/CompletionTests.fs index 349647e0fa3..f973c434377 100644 --- a/tests/service/CompletionTests.fs +++ b/tests/service/CompletionTests.fs @@ -17,6 +17,15 @@ let assertHasItemWithNames names (completionInfo: DeclarationListInfo) = for name in names do Assert.That(Set.contains name itemNames, $"{name} not found in {itemNames}") +[] +let ``Expr - After record decl`` () = + let info = getCompletionInfo "{ Fi }" (4, 0) """ +type Record = { Field: int } + + +""" + assertHasItemWithNames ["ignore"] info + [] let ``Expr - record - field 01 - anon module`` () = let info = getCompletionInfo "{ Fi }" (4, 3) """ From 9669913821972b3d278b76f8b0006ba194827140 Mon Sep 17 00:00:00 2001 From: Eugene Auduchinok Date: Tue, 12 Mar 2024 14:16:39 +0100 Subject: [PATCH 12/14] Parser: fix pattern range for idents with trivia (#16824) * Parser: fix pattern range for idents with trivia * Release notes * Surface area --------- Co-authored-by: Petr Co-authored-by: Vlad Zarytovskii --- .../.FSharp.Compiler.Service/8.0.300.md | 3 +- src/Compiler/SyntaxTree/SyntaxTree.fs | 14 +++++++++- src/Compiler/SyntaxTree/SyntaxTree.fsi | 5 +++- src/Compiler/pars.fsy | 3 +- ...ervice.SurfaceArea.netstandard20.debug.bsl | 2 ++ ...vice.SurfaceArea.netstandard20.release.bsl | 2 ++ .../data/SyntaxTree/ModuleMember/Let 05.fs | 3 ++ .../SyntaxTree/ModuleMember/Let 05.fs.bsl | 28 +++++++++++++++++++ ...ePatternDefinitionWithoutParameters.fs.bsl | 4 +-- 9 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 tests/service/data/SyntaxTree/ModuleMember/Let 05.fs create mode 100644 tests/service/data/SyntaxTree/ModuleMember/Let 05.fs.bsl diff --git a/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md b/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md index 29d414d88f4..460e58b0fdc 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md +++ b/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md @@ -16,7 +16,8 @@ * Enforce AttributeTargets on let values and functions. ([PR #16692](https://github.com/dotnet/fsharp/pull/16692)) * Enforce AttributeTargets on union case declarations. ([PR #16764](https://github.com/dotnet/fsharp/pull/16764)) * Disallow using base to invoke an abstract base method. ([Issue #13926](https://github.com/dotnet/fsharp/issues/13926), [PR #16773](https://github.com/dotnet/fsharp/pull/16773)) -* Fix broken code completion after a record type declaration ([PR #16813]([Title](https://github.com/dotnet/fsharp/pull/16813))) +* Parser: fix pattern range for idents with trivia ([PR #16824](https://github.com/dotnet/fsharp/pull/16824)) +* Fix broken code completion after a record type declaration ([PR #16813](https://github.com/dotnet/fsharp/pull/16813)) ### Added diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fs b/src/Compiler/SyntaxTree/SyntaxTree.fs index 8b034740be4..a97976bee5c 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fs +++ b/src/Compiler/SyntaxTree/SyntaxTree.fs @@ -16,7 +16,19 @@ type Ident(text: string, range: range) = member _.idRange = range override _.ToString() = text -type SynIdent = SynIdent of ident: Ident * trivia: IdentTrivia option +type SynIdent = + | SynIdent of ident: Ident * trivia: IdentTrivia option + + member this.Range = + match this with + | SynIdent(ident, trivia) -> + match trivia with + | Some value -> + match value with + | IdentTrivia.OriginalNotationWithParen(leftParen, _, rightParen) + | IdentTrivia.HasParenthesis(leftParen, rightParen) -> unionRanges leftParen rightParen + | _ -> ident.idRange + | None -> ident.idRange type LongIdent = Ident list diff --git a/src/Compiler/SyntaxTree/SyntaxTree.fsi b/src/Compiler/SyntaxTree/SyntaxTree.fsi index 3d9ef06dcad..fa88b48004d 100644 --- a/src/Compiler/SyntaxTree/SyntaxTree.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTree.fsi @@ -16,7 +16,10 @@ type Ident = member idRange: range /// Represents an identifier with potentially additional trivia information. -type SynIdent = SynIdent of ident: Ident * trivia: IdentTrivia option +type SynIdent = + | SynIdent of ident: Ident * trivia: IdentTrivia option + + member Range: range /// Represents a long identifier e.g. 'A.B.C' type LongIdent = Ident list diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index 4080fc7ec8b..b33d55722a5 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -3627,8 +3627,7 @@ atomicPattern: mkSynPatMaybeVar lidwd vis (lhs parseState) else let synIdent = List.head lidwd.IdentsWithTrivia - let (SynIdent(id, _)) = synIdent - SynPat.Named(synIdent, false, vis, id.idRange) } + SynPat.Named(synIdent, false, vis, synIdent.Range) } | constant { SynPat.Const(fst $1, snd $1) } diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl index cdbdb81bda0..9dda7f12180 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl @@ -7534,6 +7534,8 @@ FSharp.Compiler.Syntax.SynField: System.String ToString() FSharp.Compiler.Syntax.SynIdent: FSharp.Compiler.Syntax.Ident get_ident() FSharp.Compiler.Syntax.SynIdent: FSharp.Compiler.Syntax.Ident ident FSharp.Compiler.Syntax.SynIdent: FSharp.Compiler.Syntax.SynIdent NewSynIdent(FSharp.Compiler.Syntax.Ident, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.SyntaxTrivia.IdentTrivia]) +FSharp.Compiler.Syntax.SynIdent: FSharp.Compiler.Text.Range Range +FSharp.Compiler.Syntax.SynIdent: FSharp.Compiler.Text.Range get_Range() FSharp.Compiler.Syntax.SynIdent: Int32 Tag FSharp.Compiler.Syntax.SynIdent: Int32 get_Tag() FSharp.Compiler.Syntax.SynIdent: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.SyntaxTrivia.IdentTrivia] get_trivia() diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl index cdbdb81bda0..9dda7f12180 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl @@ -7534,6 +7534,8 @@ FSharp.Compiler.Syntax.SynField: System.String ToString() FSharp.Compiler.Syntax.SynIdent: FSharp.Compiler.Syntax.Ident get_ident() FSharp.Compiler.Syntax.SynIdent: FSharp.Compiler.Syntax.Ident ident FSharp.Compiler.Syntax.SynIdent: FSharp.Compiler.Syntax.SynIdent NewSynIdent(FSharp.Compiler.Syntax.Ident, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.SyntaxTrivia.IdentTrivia]) +FSharp.Compiler.Syntax.SynIdent: FSharp.Compiler.Text.Range Range +FSharp.Compiler.Syntax.SynIdent: FSharp.Compiler.Text.Range get_Range() FSharp.Compiler.Syntax.SynIdent: Int32 Tag FSharp.Compiler.Syntax.SynIdent: Int32 get_Tag() FSharp.Compiler.Syntax.SynIdent: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.SyntaxTrivia.IdentTrivia] get_trivia() diff --git a/tests/service/data/SyntaxTree/ModuleMember/Let 05.fs b/tests/service/data/SyntaxTree/ModuleMember/Let 05.fs new file mode 100644 index 00000000000..3d306418d47 --- /dev/null +++ b/tests/service/data/SyntaxTree/ModuleMember/Let 05.fs @@ -0,0 +1,3 @@ +let (|AP|) + +() diff --git a/tests/service/data/SyntaxTree/ModuleMember/Let 05.fs.bsl b/tests/service/data/SyntaxTree/ModuleMember/Let 05.fs.bsl new file mode 100644 index 00000000000..684cfa3cfb0 --- /dev/null +++ b/tests/service/data/SyntaxTree/ModuleMember/Let 05.fs.bsl @@ -0,0 +1,28 @@ +ImplFile + (ParsedImplFileInput + ("/root/ModuleMember/Let 05.fs", false, QualifiedNameOfFile Let 05, [], [], + [SynModuleOrNamespace + ([Let 05], false, AnonModule, + [Let + (false, + [SynBinding + (None, Normal, false, false, [], + PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector), + SynValData + (None, SynValInfo ([], SynArgInfo ([], false, None)), None), + Named + (SynIdent + (|AP|, Some (HasParenthesis ((1,4--1,5), (1,9--1,10)))), + false, None, (1,4--1,10)), None, + ArbitraryAfterError ("localBinding2", (1,10--1,10)), + (1,4--1,10), Yes (1,0--1,10), + { LeadingKeyword = Let (1,0--1,3) + InlineKeyword = None + EqualsRange = None })], (1,0--1,10)); + Expr (Const (Unit, (3,0--3,2)), (3,0--3,2))], PreXmlDocEmpty, [], + None, (1,0--3,2), { LeadingKeyword = None })], (true, true), + { ConditionalDirectives = [] + CodeComments = [] }, set [])) + +(3,0)-(3,1) parse error Incomplete structured construct at or before this point in binding. Expected '=' or other token. +(1,0)-(2,0) parse warning The declarations in this file will be placed in an implicit module 'Let 05' based on the file name 'Let 05.fs'. However this is not a valid F# identifier, so the contents will not be accessible from other files. Consider renaming the file or adding a 'module' or 'namespace' declaration at the top of the file. diff --git a/tests/service/data/SyntaxTree/OperatorName/PartialActivePatternDefinitionWithoutParameters.fs.bsl b/tests/service/data/SyntaxTree/OperatorName/PartialActivePatternDefinitionWithoutParameters.fs.bsl index d3f6d9d59f8..be0b81e8577 100644 --- a/tests/service/data/SyntaxTree/OperatorName/PartialActivePatternDefinitionWithoutParameters.fs.bsl +++ b/tests/service/data/SyntaxTree/OperatorName/PartialActivePatternDefinitionWithoutParameters.fs.bsl @@ -16,12 +16,12 @@ ImplFile (SynIdent (|Boolean|_|, Some (HasParenthesis ((2,4--2,5), (2,16--2,17)))), false, - None, (2,5--2,16)), None, + None, (2,4--2,17)), None, LongIdent (false, SynLongIdent ([Boolean; parse], [(2,27--2,28)], [None; None]), None, - (2,20--2,33)), (2,5--2,16), Yes (2,0--2,33), + (2,20--2,33)), (2,4--2,17), Yes (2,0--2,33), { LeadingKeyword = Let (2,0--2,3) InlineKeyword = None EqualsRange = Some (2,18--2,19) })], (2,0--2,33))], From bcae92489b8f3e8a426df4b1d20af009dd9d0269 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Wed, 13 Mar 2024 15:03:04 +0100 Subject: [PATCH 13/14] Update dependencies from https://github.com/dotnet/arcade build 20240311.1 (#16865) Microsoft.DotNet.Arcade.Sdk From Version 8.0.0-beta.24158.4 -> To Version 8.0.0-beta.24161.1 Co-authored-by: dotnet-maestro[bot] Co-authored-by: Kevin Ransom (msft) --- eng/Version.Details.xml | 4 ++-- global.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index b1514f0854a..2663ee62f5b 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -30,9 +30,9 @@ - + https://github.com/dotnet/arcade - 052a4b9e7a9bdb9744c86c05665f1b46e4d59b15 + 5c3fdd3b5aaaa32b24383ec12a60b37ebff13079 diff --git a/global.json b/global.json index 189a8c9b73e..ca474949fc3 100644 --- a/global.json +++ b/global.json @@ -17,7 +17,7 @@ "perl": "5.38.0.1" }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.24158.4", + "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.24161.1", "Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23255.2" } } From 4f388c086de1407d503b1ff0199f374916b8e2c2 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Wed, 13 Mar 2024 17:23:09 +0000 Subject: [PATCH 14/14] Enforce AttributeTargets.Class and AttributeTargets.Struct (#16790) * Enforce AttributeTargets.Class and AttributeTargets.Struct * Enforce AttributeTargets.Class properly in the compiler * Enforce AttributeTargets.Class properly in the compiler * update tests * Fix test * release-notes * Extend AutoOpenAttribute and RequireQualifiedAccessAttribute to use AttributeTargets.Struct * Put back AutoOpen and RequireQualifiedAccess * Update tests * Release notes * release notes * Extend attributes targets * Update prim-types.fs * Update 8.0.300.md --------- Co-authored-by: Kevin Ransom (msft) Co-authored-by: Vlad Zarytovskii Co-authored-by: Petr --- .../.FSharp.Compiler.Service/8.0.300.md | 1 + docs/release-notes/.FSharp.Core/8.0.300.md | 1 + docs/release-notes/.Language/preview.md | 1 + src/Compiler/Checking/CheckDeclarations.fs | 10 ++- src/Compiler/FSComp.txt | 1 + src/Compiler/Facilities/LanguageFeatures.fs | 3 + src/Compiler/Facilities/LanguageFeatures.fsi | 1 + 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 ++ src/FSharp.Core/fslib-extra-pervasives.fs | 2 +- src/FSharp.Core/fslib-extra-pervasives.fsi | 2 +- src/FSharp.Core/prim-types.fs | 18 ++-- src/FSharp.Core/prim-types.fsi | 12 +-- .../AttributeUsage/AttributeTargetsIsClass.fs | 26 ++++++ .../AttributeTargetsIsStruct.fs | 23 +++++ .../AttributeUsage/AttributeUsage.fs | 83 +++++++++++++++++++ .../E_AttributeTargetIsClass.fs | 23 +++++ .../E_AttributeTargetIsMethod04.fs | 15 ++++ .../E_AttributeTargetIsStruct.fs | 27 ++++++ tests/service/ProjectAnalysisTests.fs | 22 ++--- tests/service/data/TestTP/ProvidedTypes.fs | 1 - .../ProvidedTypes.fs | 1 - 33 files changed, 307 insertions(+), 31 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeTargetsIsClass.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeTargetsIsStruct.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsClass.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsMethod04.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsStruct.fs diff --git a/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md b/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md index 460e58b0fdc..83b2c864908 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md +++ b/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md @@ -16,6 +16,7 @@ * Enforce AttributeTargets on let values and functions. ([PR #16692](https://github.com/dotnet/fsharp/pull/16692)) * Enforce AttributeTargets on union case declarations. ([PR #16764](https://github.com/dotnet/fsharp/pull/16764)) * Disallow using base to invoke an abstract base method. ([Issue #13926](https://github.com/dotnet/fsharp/issues/13926), [PR #16773](https://github.com/dotnet/fsharp/pull/16773)) +* Enforce AttributeTargets on structs and classes ([PR #16790](https://github.com/dotnet/fsharp/pull/16790)) * Parser: fix pattern range for idents with trivia ([PR #16824](https://github.com/dotnet/fsharp/pull/16824)) * Fix broken code completion after a record type declaration ([PR #16813](https://github.com/dotnet/fsharp/pull/16813)) diff --git a/docs/release-notes/.FSharp.Core/8.0.300.md b/docs/release-notes/.FSharp.Core/8.0.300.md index 7c3911ae98f..60b25705745 100644 --- a/docs/release-notes/.FSharp.Core/8.0.300.md +++ b/docs/release-notes/.FSharp.Core/8.0.300.md @@ -6,3 +6,4 @@ ### Fixed * Preserve original stack traces in resumable state machines generated code if available. ([PR #16568](https://github.com/dotnet/fsharp/pull/16568)) +* Enforce AttributeTargets on structs and classes. Also update `RequireQualifiedAccessAttribute` and `AutoOpenAttribute` to use `AttributeTargets.Struct` ([PR #16790](https://github.com/dotnet/fsharp/pull/16790)) \ No newline at end of file diff --git a/docs/release-notes/.Language/preview.md b/docs/release-notes/.Language/preview.md index eb7ddd08e54..4a6122e29dd 100644 --- a/docs/release-notes/.Language/preview.md +++ b/docs/release-notes/.Language/preview.md @@ -11,6 +11,7 @@ * Allow extension methods without type attribute work for types from imported assemblies. ([PR #16368](https://github.com/dotnet/fsharp/pull/16368)) * Enforce AttributeTargets on let values and functions. ([PR #16692](https://github.com/dotnet/fsharp/pull/16692)) * Enforce AttributeTargets on union case declarations. ([PR #16764](https://github.com/dotnet/fsharp/pull/16764)) +* Enforce AttributeTargets on structs and classes ([PR #16790](https://github.com/dotnet/fsharp/pull/16790)) ### Changed diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index 457a3489576..88c8c7b5a72 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -2926,10 +2926,16 @@ module EstablishTypeDefinitionCores = | _ -> let kind = match kind with - | SynTypeDefnKind.Class -> TFSharpClass + | SynTypeDefnKind.Class -> + if g.langVersion.SupportsFeature(LanguageFeature.EnforceAttributeTargetsOnStructAndClasses) then + TcAttributesWithPossibleTargets false cenv envinner AttributeTargets.Class synAttrs |> ignore + TFSharpClass | SynTypeDefnKind.Interface -> TFSharpInterface | SynTypeDefnKind.Delegate _ -> TFSharpDelegate (MakeSlotSig("Invoke", g.unit_ty, [], [], [], None)) - | SynTypeDefnKind.Struct -> TFSharpStruct + | SynTypeDefnKind.Struct -> + if g.langVersion.SupportsFeature(LanguageFeature.EnforceAttributeTargetsOnStructAndClasses) then + TcAttributesWithPossibleTargets false cenv envinner AttributeTargets.Struct synAttrs |> ignore + TFSharpStruct | _ -> error(InternalError("should have inferred tycon kind", m)) TFSharpTyconRepr (Construct.NewEmptyFSharpTyconData kind) diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 838ead87857..eda76095bb2 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1596,6 +1596,7 @@ featureBooleanReturningAndReturnTypeDirectedPartialActivePattern,"Boolean-return featureEnforceAttributeTargetsOnFunctions,"Enforce AttributeTargets on functions" featureEnforceAttributeTargetsUnionCaseDeclarations,"Enforce AttributeTargets on union case declarations" featureLowerInterpolatedStringToConcat,"Optimizes interpolated strings in certain cases, by lowering to concatenation" +featureEnforceAttributeTargetsOnStructAndClasses,"Enforce AttributeTargets on structs and classes" featureLowerIntegralRangesToFastLoops,"Optimizes certain uses of the integral range (..) and range-step (.. ..) operators to fast while-loops." 3354,tcNotAFunctionButIndexerNamedIndexingNotYetEnabled,"This value supports indexing, e.g. '%s.[index]'. The syntax '%s[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation." 3354,tcNotAFunctionButIndexerIndexingNotYetEnabled,"This expression supports indexing, e.g. 'expr.[index]'. The syntax 'expr[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation." diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index 3103d8b159e..ac48fc40b91 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -88,6 +88,7 @@ type LanguageFeature = | EnforceAttributeTargetsOnFunctions | EnforceAttributeTargetsUnionCaseDeclarations | LowerInterpolatedStringToConcat + | EnforceAttributeTargetsOnStructAndClasses | LowerIntegralRangesToFastLoops /// LanguageVersion management @@ -204,6 +205,7 @@ type LanguageVersion(versionText) = LanguageFeature.EnforceAttributeTargetsOnFunctions, previewVersion LanguageFeature.EnforceAttributeTargetsUnionCaseDeclarations, previewVersion LanguageFeature.LowerInterpolatedStringToConcat, previewVersion + LanguageFeature.EnforceAttributeTargetsOnStructAndClasses, previewVersion LanguageFeature.LowerIntegralRangesToFastLoops, previewVersion ] @@ -351,6 +353,7 @@ type LanguageVersion(versionText) = | LanguageFeature.EnforceAttributeTargetsOnFunctions -> FSComp.SR.featureEnforceAttributeTargetsOnFunctions () | LanguageFeature.EnforceAttributeTargetsUnionCaseDeclarations -> FSComp.SR.featureEnforceAttributeTargetsUnionCaseDeclarations () | LanguageFeature.LowerInterpolatedStringToConcat -> FSComp.SR.featureLowerInterpolatedStringToConcat () + | LanguageFeature.EnforceAttributeTargetsOnStructAndClasses -> FSComp.SR.featureEnforceAttributeTargetsOnStructAndClasses () | LanguageFeature.LowerIntegralRangesToFastLoops -> FSComp.SR.featureLowerIntegralRangesToFastLoops () /// Get a version string associated with the given feature. diff --git a/src/Compiler/Facilities/LanguageFeatures.fsi b/src/Compiler/Facilities/LanguageFeatures.fsi index 4f0fe835ffa..80a41c8ce54 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fsi +++ b/src/Compiler/Facilities/LanguageFeatures.fsi @@ -79,6 +79,7 @@ type LanguageFeature = | EnforceAttributeTargetsOnFunctions | EnforceAttributeTargetsUnionCaseDeclarations | LowerInterpolatedStringToConcat + | EnforceAttributeTargetsOnStructAndClasses | LowerIntegralRangesToFastLoops /// LanguageVersion management diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 8d023b7157f..29a83a20d98 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -297,6 +297,11 @@ Enforce AttributeTargets on functions + + Enforce AttributeTargets on structs and classes + Enforce AttributeTargets on structs and classes + + Enforce AttributeTargets on union case declarations Enforce AttributeTargets on union case declarations diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index a64e570f7b9..e28b1177ea9 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -297,6 +297,11 @@ Enforce AttributeTargets on functions + + Enforce AttributeTargets on structs and classes + Enforce AttributeTargets on structs and classes + + Enforce AttributeTargets on union case declarations Enforce AttributeTargets on union case declarations diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 77d35305506..d86bb178a0d 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -297,6 +297,11 @@ Enforce AttributeTargets on functions + + Enforce AttributeTargets on structs and classes + Enforce AttributeTargets on structs and classes + + Enforce AttributeTargets on union case declarations Enforce AttributeTargets on union case declarations diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 03ce9378c00..e9cefd5803b 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -297,6 +297,11 @@ Enforce AttributeTargets on functions + + Enforce AttributeTargets on structs and classes + Enforce AttributeTargets on structs and classes + + Enforce AttributeTargets on union case declarations Enforce AttributeTargets on union case declarations diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 2344a13f7a1..539502d9670 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -297,6 +297,11 @@ Enforce AttributeTargets on functions + + Enforce AttributeTargets on structs and classes + Enforce AttributeTargets on structs and classes + + Enforce AttributeTargets on union case declarations Enforce AttributeTargets on union case declarations diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 53c737bbfcf..a364c7953d6 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -297,6 +297,11 @@ Enforce AttributeTargets on functions + + Enforce AttributeTargets on structs and classes + Enforce AttributeTargets on structs and classes + + Enforce AttributeTargets on union case declarations Enforce AttributeTargets on union case declarations diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 5ff6910f893..96768306e24 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -297,6 +297,11 @@ Enforce AttributeTargets on functions + + Enforce AttributeTargets on structs and classes + Enforce AttributeTargets on structs and classes + + Enforce AttributeTargets on union case declarations Enforce AttributeTargets on union case declarations diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 266d64c82cd..22210fdee9c 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -297,6 +297,11 @@ Enforce AttributeTargets on functions + + Enforce AttributeTargets on structs and classes + Enforce AttributeTargets on structs and classes + + Enforce AttributeTargets on union case declarations Enforce AttributeTargets on union case declarations diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 345fd834ac0..8449413e457 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -297,6 +297,11 @@ Enforce AttributeTargets on functions + + Enforce AttributeTargets on structs and classes + Enforce AttributeTargets on structs and classes + + Enforce AttributeTargets on union case declarations Enforce AttributeTargets on union case declarations diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 8daa89725d2..41129014c1b 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -297,6 +297,11 @@ Enforce AttributeTargets on functions + + Enforce AttributeTargets on structs and classes + Enforce AttributeTargets on structs and classes + + Enforce AttributeTargets on union case declarations Enforce AttributeTargets on union case declarations diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index b062ac01ce4..659004ddc36 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -297,6 +297,11 @@ Enforce AttributeTargets on functions + + Enforce AttributeTargets on structs and classes + Enforce AttributeTargets on structs and classes + + Enforce AttributeTargets on union case declarations Enforce AttributeTargets on union case declarations diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index b8a8910a995..1b8716f794d 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -297,6 +297,11 @@ Enforce AttributeTargets on functions + + Enforce AttributeTargets on structs and classes + Enforce AttributeTargets on structs and classes + + Enforce AttributeTargets on union case declarations Enforce AttributeTargets on union case declarations diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index bbf312f436b..43da50f6960 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -297,6 +297,11 @@ Enforce AttributeTargets on functions + + Enforce AttributeTargets on structs and classes + Enforce AttributeTargets on structs and classes + + Enforce AttributeTargets on union case declarations Enforce AttributeTargets on union case declarations diff --git a/src/FSharp.Core/fslib-extra-pervasives.fs b/src/FSharp.Core/fslib-extra-pervasives.fs index b62d5b16eb8..b5cf5dee3af 100644 --- a/src/FSharp.Core/fslib-extra-pervasives.fs +++ b/src/FSharp.Core/fslib-extra-pervasives.fs @@ -363,7 +363,7 @@ type MeasureOne = class end -[] +[] type TypeProviderAttribute() = inherit System.Attribute() diff --git a/src/FSharp.Core/fslib-extra-pervasives.fsi b/src/FSharp.Core/fslib-extra-pervasives.fsi index ffd6f6f6a00..97120245f87 100644 --- a/src/FSharp.Core/fslib-extra-pervasives.fsi +++ b/src/FSharp.Core/fslib-extra-pervasives.fsi @@ -385,7 +385,7 @@ namespace Microsoft.FSharp.Core.CompilerServices type MeasureOne /// Place on a class that implements ITypeProvider to extend the compiler - [] + [] type TypeProviderAttribute = inherit System.Attribute diff --git a/src/FSharp.Core/prim-types.fs b/src/FSharp.Core/prim-types.fs index 346c1a64e0e..777a31b8e15 100644 --- a/src/FSharp.Core/prim-types.fs +++ b/src/FSharp.Core/prim-types.fs @@ -104,7 +104,7 @@ namespace Microsoft.FSharp.Core type CLIMutableAttribute() = inherit Attribute() - [] + [] [] type AutoSerializableAttribute(value:bool) = inherit Attribute() @@ -127,19 +127,19 @@ namespace Microsoft.FSharp.Core type ReferenceEqualityAttribute() = inherit Attribute() - [] + [] [] type StructuralComparisonAttribute() = inherit Attribute() - [] + [] [] type StructuralEqualityAttribute() = inherit Attribute() [] + AttributeTargets.Enum, AllowMultiple=false)>] [] type NoEqualityAttribute() = inherit Attribute() @@ -161,9 +161,9 @@ namespace Microsoft.FSharp.Core type NoComparisonAttribute() = inherit Attribute() - [] + [] [] type ReflectedDefinitionAttribute(includeValue: bool) = inherit Attribute() @@ -350,12 +350,12 @@ namespace Microsoft.FSharp.Core type RequiresExplicitTypeArgumentsAttribute() = inherit Attribute() - [] + [] [] type RequireQualifiedAccessAttribute() = inherit Attribute() - [] + [] [] type AutoOpenAttribute(path:string) = inherit Attribute() diff --git a/src/FSharp.Core/prim-types.fsi b/src/FSharp.Core/prim-types.fsi index dc4b9cc22dd..fc2b4d756a9 100644 --- a/src/FSharp.Core/prim-types.fsi +++ b/src/FSharp.Core/prim-types.fsi @@ -129,7 +129,7 @@ namespace Microsoft.FSharp.Core /// for use at runtime. /// /// Attributes - [] + [] [] type ReflectedDefinitionAttribute = inherit Attribute @@ -385,7 +385,7 @@ namespace Microsoft.FSharp.Core /// 'System.Object.GetHashCode()' for the type. /// /// Attributes - [] + [] [] type StructuralEqualityAttribute = inherit Attribute @@ -398,7 +398,7 @@ namespace Microsoft.FSharp.Core /// automatic generation of implementations for 'System.IComparable' for the type. /// /// Attributes - [] + [] [] type StructuralComparisonAttribute = inherit Attribute @@ -604,7 +604,7 @@ namespace Microsoft.FSharp.Core /// type Serializable by default. /// /// Attributes - [] + [] [] type AutoSerializableAttribute = inherit Attribute @@ -898,7 +898,7 @@ namespace Microsoft.FSharp.Core /// type require explicit qualified access. /// /// Attributes - [] + [] [] type RequireQualifiedAccessAttribute = inherit Attribute @@ -920,7 +920,7 @@ namespace Microsoft.FSharp.Core /// /// /// Attributes - [] + [] [] type AutoOpenAttribute = inherit Attribute diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeTargetsIsClass.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeTargetsIsClass.fs new file mode 100644 index 00000000000..8f587dcf099 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeTargetsIsClass.fs @@ -0,0 +1,26 @@ +open System + +[] +type CustomClassAttribute() = + inherit Attribute() + +[] +type Class(x: int) = class end + +[] +[] +type Class2 = class end + +[] +type Class3() = class end + +[] +type SemanticClassificationItem = + val Range: int + val Type: string + new((range, ty)) = { Range = range; Type = ty } + +[] +type ILTableName(idx: int) = + member __.Index = idx + static member FromIndex n = ILTableName n diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeTargetsIsStruct.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeTargetsIsStruct.fs new file mode 100644 index 00000000000..9b64c7cb33f --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeTargetsIsStruct.fs @@ -0,0 +1,23 @@ +open System + +[] +type CustomStructAttribute() = + inherit Attribute() + +[] +type Class(x: int) = struct end + +[] +[] +type Class2 = struct end + +[] +type SemanticClassificationItem = + val Range: int + val Type: string + new((range, ty)) = { Range = range; Type = ty } + +[] +type ILTableName(idx: int) = + member __.Index = idx + static member FromIndex n = ILTableName n diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs index 0bdc9306cb7..652755fd5cd 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs @@ -259,6 +259,18 @@ module CustomAttributes_AttributeUsage = (Error 842, Line 52, Col 6, Line 52, Col 16, "This attribute is not valid for use on this language element") ] + // SOURCE=E_AttributeTargetIsMethod04.fs # E_AttributeTargetIsMethod04.fs + [] + let ``E_AttributeTargetIsMethod04_fs`` compilation = + compilation + |> withOptions ["--nowarn:25"] + |> verifyCompile + |> shouldFail + |> withDiagnostics [ + (Error 842, Line 10, Col 3, Line 10, Col 15, "This attribute is not valid for use on this language element") + (Error 842, Line 13, Col 3, Line 13, Col 15, "This attribute is not valid for use on this language element") + ] + // SOURCE=E_ConditionalAttribute.fs SCFLAGS="--test:ErrorRanges" # E_ConditionalAttribute.fs [] let ``E_ConditionalAttribute_fs`` compilation = @@ -300,6 +312,77 @@ module CustomAttributes_AttributeUsage = |> withDiagnostics [ (Error 842, Line 12, Col 3, Line 12, Col 6, "This attribute is not valid for use on this language element") ] + + // SOURCE=AttributeTargetIsStruct.fs # AttributeTargetIsStruct.fs + [] + let ``AttributeTargetIsStruct_fs`` compilation = + compilation + |> verifyCompile + |> shouldSucceed + + // SOURCE=AttributeTargetIsStruct.fs # AttributeTargetIsStruct.fs + [] + let ``AttributeTargetIsStruct_fs preview`` compilation = + compilation + |> withLangVersionPreview + |> verifyCompile + |> shouldSucceed + + // SOURCE=AttributeTargetIsClass.fs # AttributeTargetIsClass.fs + [] + let ``AttributeTargetIsClass_fs`` compilation = + compilation + |> verifyCompile + |> shouldSucceed + + // SOURCE=AttributeTargetIsClass.fs # AttributeTargetIsClass.fs + [] + let ``AttributeTargetIsClass_fs preview`` compilation = + compilation + |> withLangVersionPreview + |> verifyCompile + |> shouldSucceed + + // SOURCE=E_AttributeTargetIsStruct.fs # E_AttributeTargetIsStruct.fs + [] + let ``E_AttributeTargetIsStruct_fs`` compilation = + compilation + |> verifyCompile + |> shouldSucceed + + // SOURCE=E_AttributeTargetIsStruct.fs # E_AttributeTargetIsStruct.fs + [] + let ``E_AttributeTargetIsStruct_fs preview`` compilation = + compilation + |> withLangVersionPreview + |> verifyCompile + |> shouldFail + |> withDiagnostics [ + (Error 842, Line 13, Col 3, Line 13, Col 14, "This attribute is not valid for use on this language element") + (Error 842, Line 19, Col 3, Line 19, Col 14, "This attribute is not valid for use on this language element") + (Error 842, Line 22, Col 11, Line 22, Col 22, "This attribute is not valid for use on this language element") + (Error 842, Line 25, Col 3, Line 25, Col 14, "This attribute is not valid for use on this language element") + ] + + // SOURCE=E_AttributeTargetIsClass.fs # E_AttributeTargetIsClass.fs + [] + let ``E_AttributeTargetIsClass_fs`` compilation = + compilation + |> verifyCompile + |> shouldSucceed + + // SOURCE=E_AttributeTargetIsClass.fs # E_AttributeTargetIsClass.fs + [] + let ``E_AttributeTargetIsClass_fs preview`` compilation = + compilation + |> withLangVersionPreview + |> verifyCompile + |> shouldFail + |> withDiagnostics [ + (Error 842, Line 13, Col 3, Line 13, Col 15, "This attribute is not valid for use on this language element") + (Error 842, Line 19, Col 3, Line 19, Col 15, "This attribute is not valid for use on this language element") + (Error 842, Line 22, Col 10, Line 22, Col 22, "This attribute is not valid for use on this language element") + ] // SOURCE=MarshalAsAttribute.fs # MarshalAsAttribute.fs [] diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsClass.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsClass.fs new file mode 100644 index 00000000000..845b7d1762f --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsClass.fs @@ -0,0 +1,23 @@ +// This tests that AttributeTargets.Struct is not allowed on a class, and that AttributeTargets.Class is not allowed on a struct. + +open System + +[] +type CustomStructAttribute() = + inherit Attribute() + +[] +type CustomClassAttribute() = + inherit Attribute() + +[] +type Class(x: int) = class end + +[] +type Class2(x: int) = class end + +[] +type Class3(x: int) = class end + +[] +type Class4 = class end \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsMethod04.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsMethod04.fs new file mode 100644 index 00000000000..bd78c8fd5d5 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsMethod04.fs @@ -0,0 +1,15 @@ +// This tests that AttributeTargets.Method is not allowed in class and struct types. + +open System +open System.Diagnostics + +[] +type CustomMethodAttribute() = + inherit Attribute() + +[] +type Class() = class end + +[] +type Struct(x: int) = struct end + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsStruct.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsStruct.fs new file mode 100644 index 00000000000..ace0b6a5c39 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsStruct.fs @@ -0,0 +1,27 @@ +// This tests that AttributeTargets.Class is not allowed on a struct, and that AttributeTargets.Struct is not allowed on a class. + +open System + +[] +type CustomStructAttribute() = + inherit Attribute() + +[] +type CustomClassAttribute() = + inherit Attribute() + +[] +type Struct(x: int) = struct end + +[] +type Struct1(x: int) = struct end + +[] +type Struct2(x: int) = struct end + +[] +type Struct4 = struct end + +[] +[] +type Struct5 = struct end \ No newline at end of file diff --git a/tests/service/ProjectAnalysisTests.fs b/tests/service/ProjectAnalysisTests.fs index b5324d5611b..5b8da7c30a3 100644 --- a/tests/service/ProjectAnalysisTests.fs +++ b/tests/service/ProjectAnalysisTests.fs @@ -2360,8 +2360,10 @@ let ``Test Project14 all symbols`` () = |> Array.map (fun su -> su.Symbol.ToString(), su.Symbol.DisplayName, Project14.cleanFileName su.FileName, tups su.Range, attribsOfSymbolUse su) allUsesOfAllSymbols |> shouldEqual - [|("StructAttribute", "StructAttribute", "file1", ((4, 2), (4, 8)), - ["attribute"]); + [| + ("StructAttribute", "StructAttribute", "file1", ((4, 2), (4, 8)), ["attribute"]); + ("member .ctor", "StructAttribute", "file1", ((4, 2), (4, 8)), []) + ("StructAttribute", "StructAttribute", "file1", ((4, 2), (4, 8)), ["attribute"]); ("member .ctor", "StructAttribute", "file1", ((4, 2), (4, 8)), []); ("int", "int", "file1", ((5, 9), (5, 12)), ["type"]); ("int", "int", "file1", ((5, 9), (5, 12)), ["type"]); @@ -2514,14 +2516,14 @@ let ``Test Project16 all symbols`` () = |> Array.map (fun su -> su.Symbol.ToString(), su.Symbol.DisplayName, Project16.cleanFileName su.FileName, tups su.Range, attribsOfSymbolUse su, attribsOfSymbol su.Symbol) allUsesOfAllSymbols |> shouldEqual - [|("ClassAttribute", "ClassAttribute", "sig1", ((8, 6), (8, 11)), - ["attribute"], ["class"]); - ("member .ctor", "ClassAttribute", "sig1", ((8, 6), (8, 11)), [], - ["member"]); - ("ClassAttribute", "ClassAttribute", "sig1", ((12, 6), (12, 11)), - ["attribute"], ["class"]); - ("member .ctor", "ClassAttribute", "sig1", ((12, 6), (12, 11)), [], - ["member"]); + [|("ClassAttribute", "ClassAttribute", "sig1", ((8, 6), (8, 11)), ["attribute"], ["class"]); + ("member .ctor", "ClassAttribute", "sig1", ((8, 6), (8, 11)), [], ["member"]); + ("ClassAttribute", "ClassAttribute", "sig1", ((8, 6), (8, 11)), ["attribute"], ["class"]); + ("member .ctor", "ClassAttribute", "sig1", ((8, 6), (8, 11)), [], ["member"]); + ("ClassAttribute", "ClassAttribute", "sig1", ((12, 6), (12, 11)), ["attribute"], ["class"]); + ("member .ctor", "ClassAttribute", "sig1", ((12, 6), (12, 11)), [], ["member"]); + ("ClassAttribute", "ClassAttribute", "sig1", ((12, 6), (12, 11)), ["attribute"], ["class"]); + ("member .ctor", "ClassAttribute", "sig1", ((12, 6), (12, 11)), [], ["member"]); ("int", "int", "sig1", ((16, 19), (16, 22)), ["type"], ["abbrev"]); ("int", "int", "sig1", ((16, 33), (16, 36)), ["type"], ["abbrev"]); ("int", "int", "sig1", ((17, 25), (17, 28)), ["type"], ["abbrev"]); diff --git a/tests/service/data/TestTP/ProvidedTypes.fs b/tests/service/data/TestTP/ProvidedTypes.fs index 828235a0b9d..9cd4c0dc0a2 100644 --- a/tests/service/data/TestTP/ProvidedTypes.fs +++ b/tests/service/data/TestTP/ProvidedTypes.fs @@ -3221,7 +3221,6 @@ module internal AssemblyReader = override __.ToString() = "" [] - [] type ILTableName(idx: int) = member __.Index = idx diff --git a/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/ProvidedTypes.fs b/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/ProvidedTypes.fs index ae593e9961a..e787194a7b6 100644 --- a/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/ProvidedTypes.fs +++ b/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/ProvidedTypes.fs @@ -2961,7 +2961,6 @@ namespace ProviderImplementation.ProvidedTypes.AssemblyReader override _.ToString() = "" [] - [] type ILTableName(idx: int) = member _.Index = idx