diff --git a/.config/service-branch-merge.json b/.config/service-branch-merge.json
index 49561874be8..9eaf6479d45 100644
--- a/.config/service-branch-merge.json
+++ b/.config/service-branch-merge.json
@@ -10,8 +10,8 @@
"ExtraSwitches": "-QuietComments"
},
"main": {
- "MergeToBranch": "release/dev17.14",
+ "MergeToBranch": "release/dev18.0",
"ExtraSwitches": "-QuietComments"
}
}
-}
\ No newline at end of file
+}
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index 8f6f1eee176..47927f1f370 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -1,7 +1,7 @@
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at:
{
"name": "F#",
- "image": "mcr.microsoft.com/dotnet/sdk:9.0.200",
+ "image": "mcr.microsoft.com/dotnet/sdk:9.0.202",
"features": {
"ghcr.io/devcontainers/features/common-utils:2.5.2": {},
"ghcr.io/devcontainers/features/git:1.3.2": {},
diff --git a/.fantomasignore b/.fantomasignore
index f5798fbdf00..c2677d44fa4 100644
--- a/.fantomasignore
+++ b/.fantomasignore
@@ -40,19 +40,6 @@ src/Compiler/Checking/SignatureConformance.fs
src/Compiler/Checking/TypeHierarchy.fs
src/Compiler/Checking/TypeRelations.fs
-# nullness-related problems
-src/Compiler/Utilities/lib.fsi
-src/Compiler/Utilities/Cancellable.fsi
-src/FSharp.Core/tasks.fsi
-src/FSharp.Core/tasks.fs
-src/FSharp.Core/resumable.fs
-src/Compiler/DependencyManager/DependencyProvider.fs
-src/FSharp.Core/fslib-extra-pervasives.fs
-src/FSharp.Core/fslib-extra-pervasives.fsi
-
-# Incorrectly formatted: https://github.com/dotnet/fsharp/pull/14645/commits/49443a67ea8a17670c8a7c80c8bdf91f82231e91 or https://github.com/fsprojects/fantomas/issues/2733
-# This CompilerImports.fs behavior is not fixed yet, following up in https://github.com/fsprojects/fantomas/issues/2733
-src/Compiler/Driver/CompilerImports.fs
# The following files were formatted, but the "format, --check" loop is not stable.
# Fantomas formats them, but still thinks they need formatting
src/Compiler/Optimize/DetupleArgs.fs
@@ -96,44 +83,6 @@ src/FSharp.Core/printf.fs
src/FSharp.Core/Query.fs
src/FSharp.Core/seqcore.fs
-
-# fsharp (to investigate)
-
-**/TypeProviders.fsi
-**/tainted.fsi
-
-# uses nullness features
-
-**/DependencyProvider.fsi
-src/FSharp.Core/array.fs
-src/FSharp.Core/option.fsi
-src/FSharp.Core/option.fs
-src/fsi/console.fs
-src/FSharp.Build/FSharpCommandLineBuilder.fs
-
-src/Compiler/Utilities/Activity.fs
-src/Compiler/Utilities/sformat.fs
-src/Compiler/Utilities/illib.fsi
-src/Compiler/Utilities/illib.fs
-
-
-src/Compiler/Utilities/NullnessShims.fs
-src/Compiler/Utilities/DependencyGraph.fs
-src/Compiler/Utilities/LruCache.fsi
-src/Compiler/Utilities/LruCache.fs
-src/Compiler/Utilities/HashMultiMap.fsi
-src/Compiler/Utilities/HashMultiMap.fs
-src/Compiler/Facilities/AsyncMemoize.fsi
-src/Compiler/Facilities/AsyncMemoize.fs
-src/Compiler/AbstractIL/il.fs
-src/Compiler/SyntaxTree/LexerStore.fs
-
-src/Compiler/Driver/GraphChecking/Graph.fsi
-src/Compiler/Driver/GraphChecking/Graph.fs
-
-src/Compiler/DependencyManager/NativeDllResolveHandler.fsi
-src/Compiler/DependencyManager/AssemblyResolveHandler.fsi
-
# Fantomas limitations on implementation files (to investigate)
src/Compiler/AbstractIL/ilwrite.fs
diff --git a/.github/policies/resourceManagement.yml b/.github/policies/resourceManagement.yml
new file mode 100644
index 00000000000..6a4eae33150
--- /dev/null
+++ b/.github/policies/resourceManagement.yml
@@ -0,0 +1,43 @@
+id:
+name: GitOps.PullRequestIssueManagement
+description: GitOps.PullRequestIssueManagement primitive
+owner:
+resource: repository
+disabled: false
+where:
+configuration:
+ resourceManagementConfiguration:
+ eventResponderTasks:
+ - if:
+ - payloadType: Issues
+ - labelAdded:
+ label: Breaking-change
+ then:
+ - addReply:
+ reply: >-
+ Refer to the [.NET SDK breaking change guidelines](https://github.com/dotnet/sdk/blob/main/documentation/project-docs/breaking-change-guidelines.md#required-process-for-all-net-sdk-breaking-changes)
+ description: Add breaking change doc instructions to issue
+ - if:
+ - payloadType: Pull_Request
+ - labelAdded:
+ label: Breaking-change
+ then:
+ - addLabel:
+ label: needs-breaking-change-doc-created
+ - addReply:
+ reply: >-
+ Added `needs-breaking-change-doc-created` label because this PR has the `breaking-change` label.
+
+
+ When you commit this breaking change:
+
+
+ 1. [ ] Create and link to this PR and the issue a matching issue in the dotnet/docs repo using the [breaking change documentation template](https://aka.ms/dotnet/docs/new-breaking-change-issue), then remove this `needs-breaking-change-doc-created` label.
+
+ 2. [ ] Ask a committer to mail the `.NET SDK Breaking Change Notification` email list.
+
+
+ You can refer to the [.NET SDK breaking change guidelines](https://github.com/dotnet/sdk/blob/main/documentation/project-docs/breaking-change-guidelines.md)
+ description: Add breaking change instructions to PR.
+onFailure:
+onSuccess:
diff --git a/Directory.Build.props b/Directory.Build.props
index c4f2bff9287..141c85ff4d2 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -10,11 +10,6 @@
$(DotNetBuildSourceOnly)
-
-
- $(NoWarn);FS0064;FS1182
-
-
$(ArtifactsDir)/bin/fslex/$(Configuration)/$(FSharpNetCoreProductDefaultTargetFramework)/$(RuntimeIdentifier)/fslex.dll
$(ArtifactsDir)/bin/fsyacc/$(Configuration)/$(FSharpNetCoreProductDefaultTargetFramework)/$(RuntimeIdentifier)/fsyacc.dll
- NO_CHECKNULLS;BUILDING_WITH_LKG;NO_NULLCHECKING_LIB_SUPPORT;$(DefineConstants)
+ BUILDING_WITH_LKG;$(DefineConstants)
diff --git a/FSharp.Profiles.props b/FSharp.Profiles.props
index 186875ad357..35a907b2e6f 100644
--- a/FSharp.Profiles.props
+++ b/FSharp.Profiles.props
@@ -1,41 +1,15 @@
-
-
-
- false
-
-
-
-
- false
-
- false
- NO_CHECKNULLS;BUILDING_WITH_LKG;NO_NULLCHECKING_LIB_SUPPORT;$(DefineConstants)
- false
+ BUILDING_WITH_LKG;$(DefineConstants)
preview
-
- false
-
-
-
- enable
-
-
-
-
- $(NoWarn);3271
- NO_CHECKNULLS;$(DefineConstants)
-
-
diff --git a/FSharp.sln b/FSharp.sln
index fdf3b68cdef..094d4302e5c 100644
--- a/FSharp.sln
+++ b/FSharp.sln
@@ -106,6 +106,7 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Compiler.Benchmarks"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D58BFE8B-7C85-4D3B-B5F3-9A7BB90FF1EE}"
ProjectSection(SolutionItems) = preProject
+ src\Compiler\default.win32manifest = src\Compiler\default.win32manifest
src\Compiler\FSComp.txt = src\Compiler\FSComp.txt
src\Compiler\FSCompCheck.fsx = src\Compiler\FSCompCheck.fsx
EndProjectSection
diff --git a/FSharpBuild.Directory.Build.props b/FSharpBuild.Directory.Build.props
index 148d9c95116..33772456e28 100644
--- a/FSharpBuild.Directory.Build.props
+++ b/FSharpBuild.Directory.Build.props
@@ -27,6 +27,7 @@
$(ArtifactsDir)\SymStore
$(ArtifactsDir)\Bootstrap
4.4.0
+ $(WarnOn);1182
1182;0025;$(WarningsAsErrors)
$(OtherFlags) --nowarn:3384
$(OtherFlags) --times --nowarn:75
diff --git a/buildtools/fslex/fslex.fsproj b/buildtools/fslex/fslex.fsproj
index b450de1668d..684fecb11da 100644
--- a/buildtools/fslex/fslex.fsproj
+++ b/buildtools/fslex/fslex.fsproj
@@ -5,7 +5,8 @@
$(FSharpNetCoreProductTargetFramework)
true
LatestMajor
- $(NoWarn);64;1182;1204
+ $(NoWarn);64;1204;1182
+ $(OtherFlags) --warnaserror-:1182
diff --git a/buildtools/fsyacc/fsyacc.fsproj b/buildtools/fsyacc/fsyacc.fsproj
index 5f97b762e03..38280006de3 100644
--- a/buildtools/fsyacc/fsyacc.fsproj
+++ b/buildtools/fsyacc/fsyacc.fsproj
@@ -5,7 +5,8 @@
$(FSharpNetCoreProductTargetFramework)
true
LatestMajor
- $(NoWarn);64;1182;1204
+ $(NoWarn);64;1204;1182
+ $(OtherFlags) --warnaserror-:1182
diff --git a/docs/release-notes/.FSharp.Compiler.Service/9.0.300.md b/docs/release-notes/.FSharp.Compiler.Service/9.0.300.md
index c4e4a6a1403..8893e4d237d 100644
--- a/docs/release-notes/.FSharp.Compiler.Service/9.0.300.md
+++ b/docs/release-notes/.FSharp.Compiler.Service/9.0.300.md
@@ -20,6 +20,8 @@
* Fix duplicate parse error reporting for GetBackgroundCheckResultsForFileInProject ([Issue #18379](https://github.com/dotnet/fsharp/issues/18379) [PR #18380](https://github.com/dotnet/fsharp/pull/18380))
* Fix MethodDefNotFound when compiling code invoking delegate with option parameter ([Issue #5171](https://github.com/dotnet/fsharp/issues/5171), [PR #18385](https://github.com/dotnet/fsharp/pull/18385))
* Fix #r nuget ..." downloads unneeded packages ([Issue #18231](https://github.com/dotnet/fsharp/issues/18231), [PR #18393](https://github.com/dotnet/fsharp/pull/18393))
+* Reenable β-reduction and subsequent reoptimization of immediately-invoked F#-defined generic delegates. ([PR #18401](https://github.com/dotnet/fsharp/pull/18401))
+* Fixed [#18433](https://github.com/dotnet/fsharp/issues/18433), a rare case of an internal error in xml comment processing. ([PR #18436](https://github.com/dotnet/fsharp/pull/18436))
### Added
* Added missing type constraints in FCS. ([PR #18241](https://github.com/dotnet/fsharp/pull/18241))
@@ -29,6 +31,7 @@
* Symbols: Add FSharpAssembly.IsFSharp ([PR #18290](https://github.com/dotnet/fsharp/pull/18290))
* Type parameter constraint `null` in generic code will now automatically imply `not struct` ([Issue #18320](https://github.com/dotnet/fsharp/issues/18320), [PR #18323](https://github.com/dotnet/fsharp/pull/18323))
* Add a switch to determine whether to generate a default implementation body for overridden method when completing. [PR #18341](https://github.com/dotnet/fsharp/pull/18341)
+* Use a more accurate range for CE Combine methods. [PR #18394](https://github.com/dotnet/fsharp/pull/18394)
### Changed
diff --git a/docs/reusing-typechecking-results.md b/docs/reusing-typechecking-results.md
index 247e26f21dd..9eedc036ab0 100644
--- a/docs/reusing-typechecking-results.md
+++ b/docs/reusing-typechecking-results.md
@@ -25,7 +25,7 @@ Here are some assumptions I am coming with after tinkering with the topic and in
### Premise 1: current compiler design
-The heart of the compiler, [fsc.fs](src\Compiler\Driver\fsc.fs), is split into 6 phases (`main1` - `main6`). The code is designed to pass minimum information between phases, using the `Args` structure, which is essentially a data bag. The first phase takes info from the program arguments.
+The heart of the compiler, [fsc.fs](../src/Compiler/Driver/fsc.fs), is split into 6 phases (`main1` - `main6`). The code is designed to pass minimum information between phases, using the `Args` structure, which is essentially a data bag. The first phase takes info from the program arguments.
```fsharp
main1 (...args...)
diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml
index a3b61734d48..da463444bca 100644
--- a/eng/Version.Details.xml
+++ b/eng/Version.Details.xml
@@ -1,9 +1,9 @@
-
+
https://github.com/dotnet/source-build-reference-packages
- 6968f7059f4418e985febe704a3b1320f9e5887d
+ 643689c88b1d5a0f1561383972c4189a0c673abe
@@ -42,14 +42,14 @@
-
+
https://github.com/dotnet/arcade
- 5ba9ca776c1d0bb72b2791591e54cf51fc52dfee
+ 97cbc7361ff28b2948c8182720c166a744049f55
-
+
https://github.com/dotnet/arcade
- 5ba9ca776c1d0bb72b2791591e54cf51fc52dfee
+ 97cbc7361ff28b2948c8182720c166a744049f55
diff --git a/eng/Versions.props b/eng/Versions.props
index f3f7d84dc80..ba0596f729e 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -71,21 +71,29 @@
$(VersionPrefix).0
+
+
+ 4.6.1
+ 4.6.3
+ 6.1.2
+
+
+
+ 4.6.0
+ 4.5.5
+ 6.1.0
+
8.0.0
- 4.6.0
$(SystemPackageVersionVersion)
$(SystemPackageVersionVersion)
$(SystemPackageVersionVersion)
$(SystemPackageVersionVersion)
- 4.5.5
- 4.6.0
4.7.0
$(SystemPackageVersionVersion)
- 6.1.0
$(SystemPackageVersionVersion)
1.6.0
diff --git a/global.json b/global.json
index eca327e814a..434c70939fc 100644
--- a/global.json
+++ b/global.json
@@ -17,7 +17,7 @@
"perl": "5.38.2.2"
},
"msbuild-sdks": {
- "Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.25164.2",
+ "Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.25204.5",
"Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23255.2"
}
}
diff --git a/src/Compiler/AbstractIL/il.fs b/src/Compiler/AbstractIL/il.fs
index 33a46ff0a23..d0770b414ed 100644
--- a/src/Compiler/AbstractIL/il.fs
+++ b/src/Compiler/AbstractIL/il.fs
@@ -170,11 +170,8 @@ let splitTypeNameRight nm =
// --------------------------------------------------------------------
/// This is used to store event, property and field maps.
-type LazyOrderedMultiMap<'Key, 'Data when 'Key: equality
-#if !NO_CHECKNULLS
- and 'Key:not null
-#endif
- >(keyf: 'Data -> 'Key, lazyItems: InterruptibleLazy<'Data list>) =
+type LazyOrderedMultiMap<'Key, 'Data when 'Key: equality and 'Key: not null>(keyf: 'Data -> 'Key, lazyItems: InterruptibleLazy<'Data list>)
+ =
let quickMap =
lazyItems
@@ -519,7 +516,11 @@ type ILAssemblyRef(data) =
let retargetable = aname.Flags = AssemblyNameFlags.Retargetable
- let name = match aname.Name with | null -> aname.FullName | name -> name
+ let name =
+ match aname.Name with
+ | null -> aname.FullName
+ | name -> name
+
ILAssemblyRef.Create(name, None, publicKey, retargetable, version, locale)
member aref.QualifiedName =
@@ -1862,7 +1863,7 @@ type ILGenericParameterDef =
Name: string
Constraints: ILTypes
Variance: ILGenericVariance
- HasReferenceTypeConstraint: bool
+ HasReferenceTypeConstraint: bool
HasNotNullableValueTypeConstraint: bool
HasDefaultConstructorConstraint: bool
HasAllowsRefStruct: bool
@@ -1910,7 +1911,11 @@ let inline conditionalAdd condition flagToAdd source =
let NoMetadataIdx = -1
type InterfaceImpl =
- { Idx: int; Type: ILType; mutable CustomAttrsStored: ILAttributesStored }
+ {
+ Idx: int
+ Type: ILType
+ mutable CustomAttrsStored: ILAttributesStored
+ }
member x.CustomAttrs =
match x.CustomAttrsStored with
@@ -1919,12 +1924,16 @@ type InterfaceImpl =
x.CustomAttrsStored <- ILAttributesStored.Given res
res
| ILAttributesStored.Given attrs -> attrs
-
- static member Create(ilType: ILType, customAttrsStored: ILAttributesStored) =
- { Idx = NoMetadataIdx; Type = ilType; CustomAttrsStored = customAttrsStored }
- static member Create(ilType: ILType) = InterfaceImpl.Create(ilType, emptyILCustomAttrsStored)
+ static member Create(ilType: ILType, customAttrsStored: ILAttributesStored) =
+ {
+ Idx = NoMetadataIdx
+ Type = ilType
+ CustomAttrsStored = customAttrsStored
+ }
+ static member Create(ilType: ILType) =
+ InterfaceImpl.Create(ilType, emptyILCustomAttrsStored)
[]
type ILMethodDef
@@ -2575,17 +2584,15 @@ type ILTypeDefAdditionalFlags =
| CanContainExtensionMethods = 1024
let internal typeKindFlags =
- ILTypeDefAdditionalFlags.Class |||
- ILTypeDefAdditionalFlags.ValueType |||
- ILTypeDefAdditionalFlags.Interface |||
- ILTypeDefAdditionalFlags.Enum |||
- ILTypeDefAdditionalFlags.Delegate
+ ILTypeDefAdditionalFlags.Class
+ ||| ILTypeDefAdditionalFlags.ValueType
+ ||| ILTypeDefAdditionalFlags.Interface
+ ||| ILTypeDefAdditionalFlags.Enum
+ ||| ILTypeDefAdditionalFlags.Delegate
-let inline internal resetTypeKind flags =
- flags &&& ~~~typeKindFlags
+let inline internal resetTypeKind flags = flags &&& ~~~typeKindFlags
-let (|HasFlag|_|) (flag: ILTypeDefAdditionalFlags) flags =
- flags &&& flag = flag
+let (|HasFlag|_|) (flag: ILTypeDefAdditionalFlags) flags = flags &&& flag = flag
let inline typeKindByNames extendsName typeName =
match extendsName with
@@ -2676,21 +2683,24 @@ type ILTypeDef
let hasFlag flag = additionalFlags &&& flag = flag
- new(name,
- attributes,
- layout,
- implements,
- genericParams,
- extends,
- methods,
- nestedTypes,
- fields,
- methodImpls,
- events,
- properties,
- additionalFlags,
- securityDecls,
- customAttrs) =
+ new
+ (
+ name,
+ attributes,
+ layout,
+ implements,
+ genericParams,
+ extends,
+ methods,
+ nestedTypes,
+ fields,
+ methodImpls,
+ events,
+ properties,
+ additionalFlags,
+ securityDecls,
+ customAttrs
+ ) =
ILTypeDef(
name,
attributes,
@@ -2710,23 +2720,27 @@ type ILTypeDef
NoMetadataIdx
)
- new(name,
- attributes,
- layout,
- implements,
- genericParams,
- extends,
- methods,
- nestedTypes,
- fields,
- methodImpls,
- events,
- properties,
- securityDecls,
- customAttrs) =
+ new
+ (
+ name,
+ attributes,
+ layout,
+ implements,
+ genericParams,
+ extends,
+ methods,
+ nestedTypes,
+ fields,
+ methodImpls,
+ events,
+ properties,
+ securityDecls,
+ customAttrs
+ ) =
let additionalFlags =
- ILTypeDefAdditionalFlags.CanContainExtensionMethods |||
- typeKindOfFlags name extends (int attributes)
+ ILTypeDefAdditionalFlags.CanContainExtensionMethods
+ ||| typeKindOfFlags name extends (int attributes)
+
ILTypeDef(
name,
attributes,
@@ -2955,10 +2969,10 @@ and [] ILPreTypeDef =
and [] ILPreTypeDefImpl(nameSpace: string list, name: string, metadataIndex: int32, storage: ILTypeDefStored) =
let stored =
lazy
- match storage with
- | ILTypeDefStored.Given td -> td
- | ILTypeDefStored.Computed f -> f ()
- | ILTypeDefStored.Reader f -> f metadataIndex
+ match storage with
+ | ILTypeDefStored.Given td -> td
+ | ILTypeDefStored.Computed f -> f ()
+ | ILTypeDefStored.Reader f -> f metadataIndex
interface ILPreTypeDef with
member _.Namespace = nameSpace
@@ -4248,25 +4262,31 @@ let mkILStorageCtorWithParamNames (preblock: ILInstr list, ty, extraParams, flds
| Some x -> I_seqpoint x
| None -> ()
yield! preblock
- for (n, (_pnm, nm, fieldTy,_attrs)) in List.indexed flds do
+ for (n, (_pnm, nm, fieldTy, _attrs)) in List.indexed flds do
mkLdarg0
mkLdarg (uint16 (n + 1))
mkNormalStfld (mkILFieldSpecInTy (ty, nm, fieldTy))
]
let body = mkMethodBody (false, [], 2, nonBranchingInstrsToCode code, tag, imports)
- let fieldParams =
+
+ let fieldParams =
[
- for (pnm,_,ty,attrs) in flds do
+ for (pnm, _, ty, attrs) in flds do
let ilParam = mkILParamNamed (pnm, ty)
+
let ilParam =
match attrs with
| [] -> ilParam
- | attrs -> {ilParam with CustomAttrsStored = storeILCustomAttrs (mkILCustomAttrs attrs ) }
+ | attrs ->
+ { ilParam with
+ CustomAttrsStored = storeILCustomAttrs (mkILCustomAttrs attrs)
+ }
+
yield ilParam
- ]
+ ]
- mkILCtor (access, fieldParams @ extraParams , body)
+ mkILCtor (access, fieldParams @ extraParams, body)
let mkILSimpleStorageCtorWithParamNames (baseTySpec, ty, extraParams, flds, access, tag, imports) =
let preblock =
diff --git a/src/Compiler/AbstractIL/ilreflect.fs b/src/Compiler/AbstractIL/ilreflect.fs
index 6151c28b8f0..ca309e95875 100644
--- a/src/Compiler/AbstractIL/ilreflect.fs
+++ b/src/Compiler/AbstractIL/ilreflect.fs
@@ -164,7 +164,7 @@ type TypeBuilder with
printfn "typeBuilder%d.CreateType()" (abs <| hash typB)
//Buggy annotation in ns20, will not be fixed.
-#if NETSTANDARD && !NO_CHECKNULLS
+#if NETSTANDARD
!!(typB.CreateTypeInfo()) :> Type
#else
typB.CreateTypeInfo() :> Type
diff --git a/src/Compiler/AbstractIL/ilwrite.fs b/src/Compiler/AbstractIL/ilwrite.fs
index 2cb9bb01a1b..1d5111daa50 100644
--- a/src/Compiler/AbstractIL/ilwrite.fs
+++ b/src/Compiler/AbstractIL/ilwrite.fs
@@ -362,11 +362,7 @@ let envForOverrideSpec (ospec: ILOverridesSpec) = { EnclosingTyparCount=ospec.De
//---------------------------------------------------------------------
[]
-type MetadataTable<'T
-#if !NO_CHECKNULLS
- when 'T:not null
-#endif
- > =
+type MetadataTable<'T when 'T:not null> =
{ name: string
dict: Dictionary<'T, int> // given a row, find its entry number
mutable rows: ResizeArray<'T> }
diff --git a/src/Compiler/Checking/CheckPatterns.fs b/src/Compiler/Checking/CheckPatterns.fs
index 9587c3b5e9f..9665bfd2463 100644
--- a/src/Compiler/Checking/CheckPatterns.fs
+++ b/src/Compiler/Checking/CheckPatterns.fs
@@ -269,7 +269,7 @@ and TcPat warnOnUpper (cenv: cenv) env valReprInfo vFlags (patEnv: TcPatLinearEn
| SynPat.As (pat1, pat2, m) ->
TcPatUnnamedAs warnOnUpper cenv env vFlags patEnv ty pat1 pat2 m
-
+
| SynPat.Named (SynIdent(id,_), isMemberThis, vis, m) ->
TcPatNamed warnOnUpper cenv env vFlags patEnv id ty isMemberThis vis valReprInfo m
@@ -522,7 +522,7 @@ and IsNameOf (cenv: cenv) (env: TcEnv) ad m (id: Ident) =
/// Check a long identifier in a pattern
and TcPatLongIdent warnOnUpper cenv env ad valReprInfo vFlags (patEnv: TcPatLinearEnv) ty (longDotId, tyargs, args, vis, m) =
let (SynLongIdent(longId, _, _)) = longDotId
-
+
if tyargs.IsSome then errorR(Error(FSComp.SR.tcInvalidTypeArgumentUsage(), m))
let warnOnUpperForId =
@@ -643,7 +643,7 @@ and TcPatLongIdentUnionCaseOrExnCase warnOnUpper cenv env ad vFlags patEnv ty (m
// Here we only care about the cases where the user has written the wildcard pattern explicitly
// | Case _ -> ...
// let myDiscardedArgFunc(Case _) = ..."""
- // This needs to be a waring because it was a valid pattern in version 7.0 and earlier and we don't want to break existing code.
+ // This needs to be a warning because it was a valid pattern in version 7.0 and earlier and we don't want to break existing code.
// The rest of the cases will still be reported as FS0725
warning(Error(FSComp.SR.matchNotAllowedForUnionCaseWithNoData(), m))
| _ -> ()
@@ -725,7 +725,7 @@ and TcPatLongIdentUnionCaseOrExnCase warnOnUpper cenv env ad vFlags patEnv ty (m
if numArgTys > 1 then
// Expects tuple without enough args
let printTy = NicePrint.minimalStringOfType env.DisplayEnv
- let missingArgs =
+ let missingArgs =
argNames.[numArgs..numArgTys - 1]
|> List.map (fun id -> (if id.rfield_name_generated then "" else id.DisplayName + ": ") + printTy id.FormalType)
|> String.concat (Environment.NewLine + "\t")
diff --git a/src/Compiler/Checking/Expressions/CheckComputationExpressions.fs b/src/Compiler/Checking/Expressions/CheckComputationExpressions.fs
index 52cb3c0d61a..10b4a891b32 100644
--- a/src/Compiler/Checking/Expressions/CheckComputationExpressions.fs
+++ b/src/Compiler/Checking/Expressions/CheckComputationExpressions.fs
@@ -914,7 +914,7 @@ let inline addVarsToVarSpace (varSpace: LazyWithContext
/// Try translate the syntax sugar
///
/// Computation expression context (carrying caches, environments, ranges, etc)
-/// Flag if it's inital check
+/// Flag if it's initial check
/// a flag indicating if custom operators are allowed. They are not allowed inside try/with, try/finally, if/then/else etc.
/// a lazy data structure indicating the variables bound so far in the overall computation
/// the computation expression being analyzed
@@ -1612,6 +1612,12 @@ let rec TryTranslateComputationExpression
// "cexpr; cexpr" is treated as builder.Combine(cexpr1, cexpr1)
let m1 = rangeForCombine innerComp1
+ let combineDelayRange =
+ match innerComp2 with
+ | SynExpr.YieldOrReturn(trivia = yieldOrReturn) -> yieldOrReturn.YieldOrReturnKeyword
+ | SynExpr.YieldOrReturnFrom(trivia = yieldOrReturnFrom) -> yieldOrReturnFrom.YieldOrReturnFromKeyword
+ | expr -> expr.Range
+
if
isNil (
TryFindIntrinsicOrExtensionMethInfo
@@ -1624,7 +1630,8 @@ let rec TryTranslateComputationExpression
ceenv.builderTy
)
then
- error (Error(FSComp.SR.tcRequireBuilderMethod ("Combine"), m))
+
+ error (Error(FSComp.SR.tcRequireBuilderMethod "Combine", combineDelayRange))
if
isNil (
@@ -1638,7 +1645,7 @@ let rec TryTranslateComputationExpression
ceenv.builderTy
)
then
- error (Error(FSComp.SR.tcRequireBuilderMethod ("Delay"), m))
+ error (Error(FSComp.SR.tcRequireBuilderMethod "Delay", combineDelayRange))
let combineCall =
mkSynCall
@@ -2786,7 +2793,7 @@ and convertSimpleReturnToExpr (ceenv: ComputationExpressionContext<'a>) comp var
| Some(thenExpr, None) ->
let elseExprOptOpt =
match elseCompOpt with
- // When we are missing an 'else' part alltogether in case of 'if cond then return exp', we fallback from BindReturn into regular Bind+Return
+ // When we are missing an 'else' part altogether in case of 'if cond then return exp', we fallback from BindReturn into regular Bind+Return
| None -> None
| Some elseComp ->
match convertSimpleReturnToExpr ceenv comp varSpace elseComp with
diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs
index f1e6960cc21..7f1d22f0dd2 100644
--- a/src/Compiler/Checking/Expressions/CheckExpressions.fs
+++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs
@@ -813,7 +813,7 @@ let TcConst (cenv: cenv) (overallTy: TType) m env synConst =
warning(Error(FSComp.SR.tcImplicitMeasureFollowingSlash(), m))
let factor1 = ms1 |> Option.defaultValue (SynMeasure.One Range.Zero)
Measure.Prod(tcMeasure factor1, Measure.Inv (tcMeasure ms2), ms.Range)
- | SynMeasure.Divide(measure1 = ms1; measure2 = ms2; range= m) ->
+ | SynMeasure.Divide(measure1 = ms1; measure2 = ms2) ->
let factor1 = ms1 |> Option.defaultValue (SynMeasure.One Range.Zero)
Measure.Prod(tcMeasure factor1, Measure.Inv (tcMeasure ms2), ms.Range)
| SynMeasure.Seq(mss, _) -> ProdMeasures (List.map tcMeasure mss)
@@ -10686,7 +10686,7 @@ and TcMatchClauses cenv inputTy (resultTy: OverallTy) env tpenv clauses =
resultList,tpEnv
and TcMatchClause cenv inputTy (resultTy: OverallTy) env isFirst tpenv synMatchClause =
- let (SynMatchClause(synPat, synWhenExprOpt, synResultExpr, patm, spTgt, trivia)) = synMatchClause
+ let (SynMatchClause(synPat, synWhenExprOpt, synResultExpr, patm, spTgt, _trivia)) = synMatchClause
let isTrueMatchClause =
if synMatchClause.IsTrueMatchClause then
diff --git a/src/Compiler/Checking/Expressions/CheckSequenceExpressions.fs b/src/Compiler/Checking/Expressions/CheckSequenceExpressions.fs
index 3c5f136d284..499ed2ca914 100644
--- a/src/Compiler/Checking/Expressions/CheckSequenceExpressions.fs
+++ b/src/Compiler/Checking/Expressions/CheckSequenceExpressions.fs
@@ -270,7 +270,7 @@ let TcSequenceExpression (cenv: TcFileState) env tpenv comp (overallTy: OverallT
let tclauses, tpenv =
(tpenv, clauses)
- ||> List.mapFold (fun tpenv (SynMatchClause(pat, cond, innerComp, _, sp, trivia) as clause) ->
+ ||> List.mapFold (fun tpenv (SynMatchClause(pat, cond, innerComp, _, sp, _trivia) as clause) ->
let isTrueMatchClause =
if clause.IsTrueMatchClause then
TcTrueMatchClause.Yes
@@ -319,7 +319,7 @@ let TcSequenceExpression (cenv: TcFileState) env tpenv comp (overallTy: OverallT
// Compile the pattern twice, once as a filter with all succeeding targets returning "1", and once as a proper catch block.
let clauses, tpenv =
(tpenv, withList)
- ||> List.mapFold (fun tpenv (SynMatchClause(pat, cond, innerComp, m, sp, trivia) as clause) ->
+ ||> List.mapFold (fun tpenv (SynMatchClause(pat, cond, innerComp, m, sp, _trivia) as clause) ->
let isTrueMatchClause =
if clause.IsTrueMatchClause then
TcTrueMatchClause.Yes
diff --git a/src/Compiler/Checking/PatternMatchCompilation.fs b/src/Compiler/Checking/PatternMatchCompilation.fs
index 00b25756801..3b42f561c1a 100644
--- a/src/Compiler/Checking/PatternMatchCompilation.fs
+++ b/src/Compiler/Checking/PatternMatchCompilation.fs
@@ -197,11 +197,11 @@ exception CannotRefute
[]
[]
-type CounterExampleType =
+type CounterExampleType =
/// Maps to EnumMatchIncomplete exn
- | EnumCoversKnown
+ | EnumCoversKnown
/// Maps to MatchIncomplete exn
- | WithoutEnum
+ | WithoutEnum
with member x.Combine(other) = match other with EnumCoversKnown -> other | _ -> x
let RefuteDiscrimSet g m path discrims : Expr * CounterExampleType =
@@ -366,7 +366,7 @@ let ShowCounterExample g denv m refuted =
| [] -> raise CannotRefute
| (r, eck) :: t ->
((r, eck), t) ||> List.fold (fun (rAcc, eckAcc) (r, eck) ->
- CombineRefutations g rAcc r, eckAcc.Combine(eck))
+ CombineRefutations g rAcc r, eckAcc.Combine(eck))
let text = LayoutRender.showL (NicePrint.dataExprL denv counterExample)
let failingWhenClause = refuted |> List.exists (function RefutedWhenClause -> true | _ -> false)
Some(text, failingWhenClause, enumCoversKnown)
@@ -400,7 +400,7 @@ let rec isMemOfActives p1 actives =
| [] -> false
| Active(p2, _, _) :: rest -> pathEq p1 p2 || isMemOfActives p1 rest
-// Find the information about the active investigation
+// Find the information about the active investigation
let rec lookupActive x l =
match l with
| [] -> raise (KeyNotFoundException())
@@ -423,13 +423,13 @@ type Implication =
/// Work out what a successful type test (against tgtTy1) implies about a null test for the same input value.
///
/// Example:
-/// match x with
+/// match x with
/// | :? string when false -> ... // note: "when false" used so type test succeeds but proceed to next type test
/// | null -> ...
/// For any inputs where ':? string' succeeds, 'null' will fail
///
/// Example:
-/// match x with
+/// match x with
/// | :? (int option) when false -> ... // note: "when false" used so type test succeeds but proceed to next type test
/// | null -> ...
/// Nothing can be learned. If ':? (int option)' succeeds, 'null' may still have to be run.
@@ -442,7 +442,7 @@ let computeWhatSuccessfulTypeTestImpliesAboutNullTest g tgtTy1 =
/// Work out what a failing type test (against tgtTy1) implies about a null test for the same input value.
///
/// Example:
-/// match x with
+/// match x with
/// | :? (int option) -> ...
/// | null -> ...
/// If ':? (int option)' fails then 'null' will fail
@@ -455,13 +455,13 @@ let computeWhatFailingTypeTestImpliesAboutNullTest g tgtTy1 =
/// Work out what one successful null test implies about a type test (against tgtTy2) for the same input value.
///
/// Example:
-/// match x with
+/// match x with
/// | null when false -> ... // note: "when false" used so null test succeeds but proceed to next type test
/// | :? string -> ...
/// For any inputs where 'null' succeeds, ':? string' will fail
///
/// Example:
-/// match x with
+/// match x with
/// | null when false -> ... // note: "when false" used so null test succeeds but proceed to next type test
/// | :? (int option) -> ...
/// For any inputs where 'null' succeeds, ':? (int option)' will succeed
@@ -487,12 +487,12 @@ let computeWhatSuccessfulTypeTestImpliesAboutTypeTest g amap m tgtTy1 tgtTy2 =
// supertypes (tgtTy2) always succeed.
//
// Example:
- // match x with
+ // match x with
// | :? string when false -> ... // note: "when false" used so type test succeeds but proceed to next type test
// | :? IComparable -> ...
//
// Example:
- // match x with
+ // match x with
// | :? string when false -> ... // note: "when false" used so type test succeeds but proceed to next type test
// | :? string -> ...
//
@@ -503,7 +503,7 @@ let computeWhatSuccessfulTypeTestImpliesAboutTypeTest g amap m tgtTy1 tgtTy2 =
// type tests of the same object against a unrelated target type (tgtTy2) fails.
//
// Example:
- // match x with
+ // match x with
// | :? int when false -> ... // note: "when false" used so type test succeeds but proceed to next type test
// | :? string -> ...
//
@@ -511,7 +511,7 @@ let computeWhatSuccessfulTypeTestImpliesAboutTypeTest g amap m tgtTy1 tgtTy2 =
//
//
// This only applies if tgtTy2 is not potentially related to the sealed type tgtTy1:
- // match x with
+ // match x with
// | :? int when false -> ... // note: "when false" used so type test succeeds but proceed to next type test
// | :? IComparable -> ...
//
@@ -520,7 +520,7 @@ let computeWhatSuccessfulTypeTestImpliesAboutTypeTest g amap m tgtTy1 tgtTy2 =
//
//
// This rule also doesn't apply to unsealed types:
- // match x with
+ // match x with
// | :? SomeUnsealedClass when false -> ... // note: "when false" used so type test succeeds but proceed to next type test
// | :? SomeInterface -> ...
// because the input may be some subtype of SomeUnsealedClass and that type could implement SomeInterface even if
@@ -528,7 +528,7 @@ let computeWhatSuccessfulTypeTestImpliesAboutTypeTest g amap m tgtTy1 tgtTy2 =
//
//
// This rule also doesn't apply to types with null as true value:
- // match x with
+ // match x with
// | :? (int option) when false -> ... // "when false" means type test succeeds but proceed to next type test
// | :? (string option) -> ...
//
@@ -542,7 +542,7 @@ let computeWhatSuccessfulTypeTestImpliesAboutTypeTest g amap m tgtTy1 tgtTy2 =
// a type test of the same input value against an unrelated non-interface type (tgtTy2) always fails
//
// Example:
- // match x with
+ // match x with
// | :? SomeUnsealedClass when false -> ... // "when false" used so type test succeeds but proceed to next type test
// | :? SomeUnrelatedClass -> ...
//
@@ -562,7 +562,7 @@ let computeWhatSuccessfulTypeTestImpliesAboutTypeTest g amap m tgtTy1 tgtTy2 =
// always fails.
//
// Example:
- // match x with
+ // match x with
// | :? IComparable when false -> ... // "when false" used so type test succeeds but proceed to next type test
// | :? SomeOtherSealedClass -> ...
//
@@ -586,12 +586,12 @@ let computeWhatFailingTypeTestImpliesAboutTypeTest g amap m tgtTy1 tgtTy2 =
// testing the same input value against an equivalent or subtype type (tgtTy2) always fails.
//
// Example:
- // match x with
+ // match x with
// | :? IComparable -> ...
// | :? string -> ...
//
// Example:
- // match x with
+ // match x with
// | :? string -> ...
// | :? string -> ...
if TypeDefinitelySubsumesTypeNoCoercion 0 g amap m tgtTy1 tgtTy2 then
@@ -696,7 +696,7 @@ let discrimWithinSimultaneousClass g amap m discrim prev =
| DecisionTreeTest.IsNull, _ ->
// Check that each previous test in the set, if successful, gives some information about this test
- prev |> List.forall (fun edge ->
+ prev |> List.forall (fun edge ->
match edge with
| DecisionTreeTest.IsNull -> true
| DecisionTreeTest.IsInst (_, tgtTy1) -> computeWhatSuccessfulTypeTestImpliesAboutNullTest g tgtTy1 <> Implication.Nothing
@@ -704,7 +704,7 @@ let discrimWithinSimultaneousClass g amap m discrim prev =
| DecisionTreeTest.IsInst (_, tgtTy2), _ ->
// Check that each previous test in the set, if successful, gives some information about this test
- prev |> List.forall (fun edge ->
+ prev |> List.forall (fun edge ->
match edge with
| DecisionTreeTest.IsNull -> true
| DecisionTreeTest.IsInst (_, tgtTy1) -> computeWhatSuccessfulTypeTestImpliesAboutTypeTest g amap m tgtTy1 tgtTy2 <> Implication.Nothing
@@ -885,8 +885,8 @@ let rec investigationPoints inpPat =
match inpPat with
| TPat_query((_, _, _, _, _, apinfo), subPat, _) ->
Array.prepend (not apinfo.IsTotal) (investigationPoints subPat)
- | TPat_isinst(_, _tgtTy, subPatOpt, _) ->
- match subPatOpt with
+ | TPat_isinst(_, _tgtTy, subPatOpt, _) ->
+ match subPatOpt with
| None -> singleFalseInvestigationPoint
| Some subPat -> Array.prepend false (investigationPoints subPat)
| TPat_as(subPat, _, _) -> investigationPoints subPat
@@ -904,7 +904,7 @@ let rec investigationPoints inpPat =
|> Seq.collect investigationPoints
|> Seq.toArray
|> Array.prepend false
- | TPat_null _
+ | TPat_null _
| TPat_const _ -> singleFalseInvestigationPoint
| TPat_wild _
| TPat_error _ -> [||]
@@ -930,7 +930,7 @@ let rec erasePartialPatterns inpPat =
and erasePartials inps =
List.map erasePartialPatterns inps
-
+
let ReportUnusedTargets (clauses: MatchClause list) dtree =
match dtree, clauses with
| TDSuccess _, [ _ ] -> ()
@@ -948,7 +948,7 @@ let ReportUnusedTargets (clauses: MatchClause list) dtree =
| [ head ] -> head.Id.idRange
| _ -> c.Pattern.Range
| _, Some guard -> guard.Range
-
+
withStartEnd c.Range.Start m.End m
|> RuleNeverMatched
|> warning)
@@ -994,10 +994,10 @@ let CompilePatternBasic
let mutable firstIncompleteMatchClauseWithThrowExpr = None
let warningsGenerated = new ResizeArray(2)
let getIncompleteMatchClause refuted =
- // Emit the incomplete match warning.
+ // Emit the incomplete match warning.
if warnOnIncomplete then
match actionOnFailure with
- | ThrowIncompleteMatchException
+ | ThrowIncompleteMatchException
| IgnoreWithWarning ->
let ignoreWithWarning = (actionOnFailure = IgnoreWithWarning)
let counterExample = ShowCounterExample g denv mMatch refuted
@@ -1070,7 +1070,7 @@ let CompilePatternBasic
| ThrowIncompleteMatchException ->
mkThrow mMatch resultTy
- (mkExnExpr(g.MatchFailureException_tcr,
+ (mkExnExpr(g.MatchFailureException_tcr,
[ mkString g mMatch mMatch.FileName
mkInt g mMatch mMatch.StartLine
mkInt g mMatch mMatch.StartColumn], mMatch))
@@ -1259,7 +1259,7 @@ let CompilePatternBasic
| ActivePatternReturnKind.Boolean -> false
let vOpt, addrExp, _readonly, _writeonly = mkExprAddrOfExprAux g mustTakeAddress false NeverMutates appExpr None mMatch
match vOpt with
- | None ->
+ | None ->
let v, vExpr = mkCompGenLocal m ("activePatternResult" + string (newUnique())) resTy
if origInputVal.IsMemberOrModuleBinding then
AdjustValToHaveValReprInfo v origInputVal.TryDeclaringEntity ValReprInfo.emptyValData
@@ -1316,7 +1316,7 @@ let CompilePatternBasic
if not total && aparity > 1 then
error(Error(FSComp.SR.patcPartialActivePatternsGenerateOneResult(), m))
- if not total then
+ if not total then
match retKind with
| ActivePatternReturnKind.Boolean -> DecisionTreeTest.Const(Const.Bool true)
| ActivePatternReturnKind.RefTypeWrapper -> DecisionTreeTest.UnionCase(mkAnySomeCase g false, resTys)
@@ -1497,7 +1497,7 @@ let CompilePatternBasic
match discrim with
| DecisionTreeTest.IsInst (_srcTy, tgtTy2) ->
match computeWhatSuccessfulTypeTestImpliesAboutTypeTest g amap m tgtTy2 tgtTy1 with
- | Implication.Succeeds ->
+ | Implication.Succeeds ->
match pbindOpt with
| Some pbind ->
let subAccess tpinst exprIn =
@@ -1534,7 +1534,7 @@ let CompilePatternBasic
match discrim with
| DecisionTreeTest.IsNull ->
[Frontier (i, newActives, valMap)]
- | DecisionTreeTest.IsInst (_, tgtTy) ->
+ | DecisionTreeTest.IsInst (_, tgtTy) ->
match computeWhatSuccessfulTypeTestImpliesAboutNullTest g tgtTy with
| Implication.Succeeds -> [Frontier (i, newActives, valMap)]
| Implication.Fails -> []
@@ -1637,7 +1637,7 @@ let CompilePatternBasic
// - Partial active patterns
// - Disjunctive patterns
// - Pattern clauses with 'when'
-// - isinst patterns
+// - isinst patterns
//
// Partial active patterns that are not the "last" thing in a clause,
// combined with subsequent clauses, can cause significant code expansion
@@ -1666,13 +1666,13 @@ let CompilePatternBasic
// a partial pattern. This can lead to sub-standard code generation
// but has long been the technique we use to avoid blow-up of pattern matching.
//
-// Disjunctive patterns combined with 'when' clauses can also cause signficant code
+// Disjunctive patterns combined with 'when' clauses can also cause significant code
// expansion. In particular this leads to multiple copies of 'when' expressions (even for one clause)
// and each failure path of those 'when' will then continue on the expand any remaining
// pattern logic in subsequent clauses. So when generating code we take clauses up
// until the first one containing a disjunctive pattern with a 'when' clause.
//
-// Disjunction will still cause significant expansion, e.g.
+// Disjunction will still cause significant expansion, e.g.
// (A | B), (C | D) ->
// is immediately expanded out to four frontiers each with two investigation points.
// A, C -> ...
@@ -1682,7 +1682,7 @@ let CompilePatternBasic
//
// Of course, some decision-logic expansion here is expected. Further, for unions, integers, characters, enums etc.
// the column-based matching on A/B and C/D eliminates these relatively efficiently, e.g. to
-// one-switch-on-A/B
+// one-switch-on-A/B
// on each path, one switch on C/D
// So disjunction alone isn't considered problematic, but in combination with 'when' patterns
@@ -1702,7 +1702,7 @@ let rec CompilePattern g denv amap tcVal infoReader mExpr mMatch warnOnUnused a
// First make sure we generate at least some of the obvious incomplete match warnings.
let warnOnUnused = false // we can't turn this on since we're pretending all partials fail in order to control the complexity of this.
let warnOnIncomplete = true
- let clausesPretendAllPartialFail = clausesL |> List.collect (fun (MatchClause(p, whenOpt, tg, m)) -> [MatchClause(erasePartialPatterns p, whenOpt, tg, m)])
+ let clausesPretendAllPartialFail = clausesL |> List.collect (fun (MatchClause(p, whenOpt, tg, m)) -> [MatchClause(erasePartialPatterns p, whenOpt, tg, m)])
let _ = CompilePatternBasic g denv amap tcVal infoReader mExpr mMatch warnOnUnused warnOnIncomplete actionOnFailure (origInputVal, origInputValTypars, origInputExprOpt) clausesPretendAllPartialFail inputTy resultTy
let warnOnIncomplete = false
diff --git a/src/Compiler/Checking/PostInferenceChecks.fs b/src/Compiler/Checking/PostInferenceChecks.fs
index 4df0185a2e5..d22f50cdc2f 100644
--- a/src/Compiler/Checking/PostInferenceChecks.fs
+++ b/src/Compiler/Checking/PostInferenceChecks.fs
@@ -335,9 +335,9 @@ let RecordAnonRecdInfo cenv (anonInfo: AnonRecdTypeInfo) =
// approx walk of type
//--------------------------------------------------------------------------
-/// Represents the container for nester type instantions, carrying information about the parent (generic type) and data about correspinding generic typar definition.
+/// Represents the container for nester type instantions, carrying information about the parent (generic type) and data about corresponding generic typar definition.
/// For current use, IlGenericParameterDef was enough. For other future use cases, conversion into F# Typar might be needed.
-type TypeInstCtx =
+type TypeInstCtx =
| NoInfo
| IlGenericInst of parent:TyconRef * genericArg:ILGenericParameterDef
| TyparInst of parent:TyconRef
@@ -649,7 +649,7 @@ let CheckTypeAux permitByRefLike (cenv: cenv) env m ty onInnerByrefError =
errorR (Error(FSComp.SR.checkNotSufficientlyGenericBecauseOfScope(tp.DisplayName), m))
let visitTyconRef (ctx:TypeInstCtx) tcref =
- let checkInner() =
+ let checkInner() =
match ctx with
| TopLevelAllowingByRef -> false
| TyparInst(parentTcRef)
@@ -694,11 +694,11 @@ let CheckTypeAux permitByRefLike (cenv: cenv) env m ty onInnerByrefError =
cenv.potentialUnboundUsesOfVals <- cenv.potentialUnboundUsesOfVals.Add(vref.Stamp, m)
| _ -> ()
- let initialCtx =
+ let initialCtx =
match permitByRefLike with
| PermitByRefType.SpanLike
| PermitByRefType.NoInnerByRefLike -> TopLevelAllowingByRef
- | _ -> NoInfo
+ | _ -> NoInfo
CheckTypeDeep cenv (ignore, Some visitTyconRef, Some visitAppTy, Some visitTraitSolution, Some visitTyar) cenv.g env initialCtx ty
@@ -1958,7 +1958,7 @@ and CheckAttribArgExpr cenv env expr =
| Const.Single _
| Const.Char _
| Const.Zero
- | Const.String _
+ | Const.String _
| Const.Decimal _ -> ()
| _ ->
if cenv.reportErrors then
@@ -2231,7 +2231,7 @@ let CheckModuleBinding cenv env (TBind(v, e, _) as bind) =
// Default augmentation contains the nasty 'Is' etc.
let prefix = "Is"
if not v.IsImplied && nm.StartsWithOrdinal prefix && hasDefaultAugmentation then
- match tcref.GetUnionCaseByName(nm[prefix.Length ..]) with
+ match tcref.GetUnionCaseByName(nm[prefix.Length ..]) with
| Some uc -> error(NameClash(nm, kind, v.DisplayName, v.Range, FSComp.SR.chkUnionCaseDefaultAugmentation(), uc.DisplayName, uc.Range))
| None -> ()
@@ -2398,10 +2398,10 @@ let CheckEntityDefn cenv env (tycon: Entity) =
errorR(Error(FSComp.SR.chkCurriedMethodsCantHaveOutParams(), m))
if numCurriedArgSets = 1 then
- let errorIfNotStringTy m ty callerInfo =
+ let errorIfNotStringTy m ty callerInfo =
if not (typeEquiv g g.string_ty ty) then
errorR(Error(FSComp.SR.tcCallerInfoWrongType(callerInfo |> string, "string", NicePrint.minimalStringOfType cenv.denv ty), m))
-
+
let errorIfNotStringOptionTy m ty callerInfo =
if not ((isOptionTy g ty) && (typeEquiv g g.string_ty (destOptionTy g ty))) then
errorR(Error(FSComp.SR.tcCallerInfoWrongType(callerInfo |> string, "string", NicePrint.minimalStringOfType cenv.denv (destOptionTy g ty)), m))
@@ -2523,7 +2523,7 @@ let CheckEntityDefn cenv env (tycon: Entity) =
if TyconRefHasAttribute g m g.attrib_IsReadOnlyAttribute tcref && not tycon.IsStructOrEnumTycon then
errorR(Error(FSComp.SR.tcIsReadOnlyNotStruct(), tycon.Range))
- // Considers TFSharpTyconRepr and TFSharpUnionRepr.
+ // Considers TFSharpTyconRepr and TFSharpUnionRepr.
// [Review] are all cases covered: TILObjectRepr, TAsmRepr. [Yes - these are FSharp.Core.dll only]
tycon.AllFieldsArray |> Array.iter (CheckRecdField false cenv env tycon)
@@ -2559,10 +2559,10 @@ let CheckEntityDefn cenv env (tycon: Entity) =
// We do not have to check access of interface implementations.
- if tycon.IsFSharpDelegateTycon then
- match tycon.TypeReprInfo with
+ if tycon.IsFSharpDelegateTycon then
+ match tycon.TypeReprInfo with
| TFSharpTyconRepr r ->
- match r.fsobjmodel_kind with
+ match r.fsobjmodel_kind with
| TFSharpDelegate ss ->
//ss.ClassTypars
//ss.MethodTypars
diff --git a/src/Compiler/Checking/TailCallChecks.fs b/src/Compiler/Checking/TailCallChecks.fs
index 20e9bec8945..eba18dbeb4d 100644
--- a/src/Compiler/Checking/TailCallChecks.fs
+++ b/src/Compiler/Checking/TailCallChecks.fs
@@ -794,7 +794,7 @@ let CheckModuleBinding cenv (isRec: bool) (TBind _ as bind) =
| Expr.Op(args = exprs) -> exprs |> Seq.iter (checkTailCall insideSubBindingOrTry)
| Expr.Sequential(expr1 = expr1; expr2 = expr2) ->
match expr1 with
- | Expr.Op(args = exprs; op = TOp.IntegerForLoop _) -> checkTailCall insideSubBindingOrTry expr1
+ | Expr.Op(op = TOp.IntegerForLoop _) -> checkTailCall insideSubBindingOrTry expr1
| _ -> ()
checkTailCall insideSubBindingOrTry expr2
diff --git a/src/Compiler/Checking/infos.fs b/src/Compiler/Checking/infos.fs
index 8dcc5dc8ac1..81c777c3685 100644
--- a/src/Compiler/Checking/infos.fs
+++ b/src/Compiler/Checking/infos.fs
@@ -1438,10 +1438,10 @@ type MethInfo =
match retTy with
| Some retTy -> isTyparTy g retTy
| None -> false
- | MethInfoWithModifiedReturnType(_,retTy) -> false
+ | MethInfoWithModifiedReturnType _ -> false
| DefaultStructCtor _ -> false
#if !NO_TYPEPROVIDERS
- | ProvidedMeth(amap, mi, _, m) -> false
+ | ProvidedMeth _ -> false
#endif
/// Get the ParamData objects for the parameters of a MethInfo
diff --git a/src/Compiler/CodeGen/EraseUnions.fs b/src/Compiler/CodeGen/EraseUnions.fs
index 18eaed4be6f..3d5e9e4ec91 100644
--- a/src/Compiler/CodeGen/EraseUnions.fs
+++ b/src/Compiler/CodeGen/EraseUnions.fs
@@ -1211,7 +1211,6 @@ let convAlternativeDef
let basicCtorFields =
basicFields
|> List.map (fun fdef ->
- let existingAttrs = fdef.CustomAttrs.AsArray()
let nullableAttr = getFieldsNullability g fdef |> Option.toList
fdef.Name, fdef.FieldType, nullableAttr)
diff --git a/src/Compiler/DependencyManager/AssemblyResolveHandler.fsi b/src/Compiler/DependencyManager/AssemblyResolveHandler.fsi
index e1c0b2574e3..354eb07efd6 100644
--- a/src/Compiler/DependencyManager/AssemblyResolveHandler.fsi
+++ b/src/Compiler/DependencyManager/AssemblyResolveHandler.fsi
@@ -12,7 +12,7 @@ type AssemblyResolutionProbe = delegate of Unit -> seq
type AssemblyResolveHandler =
/// Construct a new DependencyProvider
- new: assemblyProbingPaths: AssemblyResolutionProbe|null -> AssemblyResolveHandler
+ new: assemblyProbingPaths: AssemblyResolutionProbe | null -> AssemblyResolveHandler
/// Construct a new DependencyProvider
internal new: assemblyProbingPaths: AssemblyResolutionProbe option -> AssemblyResolveHandler
diff --git a/src/Compiler/DependencyManager/DependencyProvider.fs b/src/Compiler/DependencyManager/DependencyProvider.fs
index 6e641af607b..a94e296d465 100644
--- a/src/Compiler/DependencyManager/DependencyProvider.fs
+++ b/src/Compiler/DependencyManager/DependencyProvider.fs
@@ -123,9 +123,6 @@ type IResolveDependenciesResult =
/// #I @"c:\somepath\to\packages\1.1.1\ResolvedPackage"
abstract Roots: seq
-#if NO_CHECKNULLS
-[]
-#endif
type IDependencyManagerProvider =
abstract Name: string
abstract Key: string
@@ -334,42 +331,36 @@ type ReflectionDependencyManagerProvider
member _.StdOut =
match getInstanceProperty (result.GetType()) "StdOut" with
| None -> [||]
- | Some p -> !! p.GetValue(result) :?> string[]
+ | Some p -> !!p.GetValue(result) :?> string[]
/// The resolution error log (* process stderror *)
member _.StdError =
match getInstanceProperty (result.GetType()) "StdError" with
| None -> [||]
- | Some p -> !! p.GetValue(result) :?> string[]
+ | Some p -> !!p.GetValue(result) :?> string[]
/// The resolution paths
member _.Resolutions =
match getInstanceProperty> (result.GetType()) "Resolutions" with
| None -> Seq.empty
- | Some p -> !! p.GetValue(result) :?> seq
+ | Some p -> !!p.GetValue(result) :?> seq
/// The source code file paths
member _.SourceFiles =
match getInstanceProperty> (result.GetType()) "SourceFiles" with
| None -> Seq.empty
- | Some p -> !! p.GetValue(result) :?> seq
+ | Some p -> !!p.GetValue(result) :?> seq
/// The roots to package directories
member _.Roots =
match getInstanceProperty> (result.GetType()) "Roots" with
| None -> Seq.empty
- | Some p -> !! p.GetValue(result) :?> seq
+ | Some p -> !!p.GetValue(result) :?> seq
}
static member MakeResultFromFields
- (
- success: bool,
- stdOut: string[],
- stdError: string[],
- resolutions: seq,
- sourceFiles: seq,
- roots: seq
- ) =
+ (success: bool, stdOut: string[], stdError: string[], resolutions: seq, sourceFiles: seq, roots: seq)
+ =
{ new IResolveDependenciesResult with
/// Succeeded?
member _.Success = success
@@ -409,16 +400,8 @@ type ReflectionDependencyManagerProvider
/// Resolve the dependencies for the given arguments
member _.ResolveDependencies
- (
- scriptDir,
- mainScriptName,
- scriptName,
- scriptExt,
- packageManagerTextLines,
- tfm,
- rid,
- timeout
- ) : IResolveDependenciesResult =
+ (scriptDir, mainScriptName, scriptName, scriptExt, packageManagerTextLines, tfm, rid, timeout)
+ : IResolveDependenciesResult =
// The ResolveDependencies method, has two signatures, the original signature in the variable resolveDeps and the updated signature resolveDepsEx
// the resolve method can return values in two different tuples:
// (bool * string list * string list * string list)
@@ -564,7 +547,7 @@ type DependencyProvider
new() = new DependencyProvider(None, None, true)
/// Returns a formatted help messages for registered dependencymanagers for the host to present
- member _.GetRegisteredDependencyManagerHelpText(compilerTools, outputDir : string | null, errorReport) =
+ member _.GetRegisteredDependencyManagerHelpText(compilerTools, outputDir: string | null, errorReport) =
[|
let managers =
RegisteredDependencyManagers compilerTools (Option.ofString outputDir) errorReport
@@ -575,7 +558,7 @@ type DependencyProvider
|]
/// Clear the DependencyManager results caches
- member _.ClearResultsCache(compilerTools, outputDir : string | null, errorReport) =
+ member _.ClearResultsCache(compilerTools, outputDir: string | null, errorReport) =
let managers =
RegisteredDependencyManagers compilerTools (Option.ofString outputDir) errorReport
@@ -584,12 +567,8 @@ type DependencyProvider
/// Returns a formatted error message for the host to present
member _.CreatePackageManagerUnknownError
- (
- compilerTools: seq,
- outputDir: string,
- packageManagerKey: string,
- reportError: ResolvingErrorReport
- ) =
+ (compilerTools: seq, outputDir: string, packageManagerKey: string, reportError: ResolvingErrorReport)
+ =
let registeredKeys =
String.Join(
", ",
@@ -602,12 +581,8 @@ type DependencyProvider
/// Fetch a dependencymanager that supports a specific key
member this.TryFindDependencyManagerInPath
- (
- compilerTools: seq,
- outputDir: string,
- reportError: ResolvingErrorReport,
- path: string
- ) : string | null * IDependencyManagerProvider | null =
+ (compilerTools: seq, outputDir: string, reportError: ResolvingErrorReport, path: string)
+ : string | null * IDependencyManagerProvider | null =
try
if path.Contains ":" && not (Path.IsPathRooted path) then
let managers =
@@ -632,12 +607,8 @@ type DependencyProvider
/// Fetch a dependencymanager that supports a specific key
member _.TryFindDependencyManagerByKey
- (
- compilerTools: seq,
- outputDir: string,
- reportError: ResolvingErrorReport,
- key: string
- ) : IDependencyManagerProvider | null =
+ (compilerTools: seq, outputDir: string, reportError: ResolvingErrorReport, key: string)
+ : IDependencyManagerProvider | null =
try
RegisteredDependencyManagers compilerTools (Option.ofString outputDir) reportError
|> Map.tryFind key
diff --git a/src/Compiler/DependencyManager/DependencyProvider.fsi b/src/Compiler/DependencyManager/DependencyProvider.fsi
index aa1bd27d5b7..1fe1c400525 100644
--- a/src/Compiler/DependencyManager/DependencyProvider.fsi
+++ b/src/Compiler/DependencyManager/DependencyProvider.fsi
@@ -39,9 +39,6 @@ type IResolveDependenciesResult =
abstract Roots: seq
/// Wraps access to a DependencyManager implementation
-#if NO_CHECKNULLS
-[]
-#endif
type IDependencyManagerProvider =
/// Name of the dependency manager
@@ -123,7 +120,7 @@ type DependencyProvider =
packageManagerTextLines: (string * string) seq *
reportError: ResolvingErrorReport *
executionTfm: string *
- [] executionRid: string MaybeNull*
+ [] executionRid: string MaybeNull *
[] implicitIncludeDir: string *
[] mainScriptName: string *
[] fileName: string *
@@ -138,4 +135,4 @@ type DependencyProvider =
/// TryFindDependencyManagerInPath - given a #r "key:sometext" go and find a DependencyManager that satisfies the key
member TryFindDependencyManagerInPath:
compilerTools: string seq * outputDir: string * reportError: ResolvingErrorReport * path: string ->
- string | null * IDependencyManagerProvider | null
\ No newline at end of file
+ string | null * IDependencyManagerProvider | null
diff --git a/src/Compiler/DependencyManager/NativeDllResolveHandler.fsi b/src/Compiler/DependencyManager/NativeDllResolveHandler.fsi
index 9d2961aa94e..e9d623df7bd 100644
--- a/src/Compiler/DependencyManager/NativeDllResolveHandler.fsi
+++ b/src/Compiler/DependencyManager/NativeDllResolveHandler.fsi
@@ -12,7 +12,7 @@ type NativeResolutionProbe = delegate of Unit -> seq
type NativeDllResolveHandler =
/// Construct a new NativeDllResolveHandler
- new: nativeProbingRoots: NativeResolutionProbe|null -> NativeDllResolveHandler
+ new: nativeProbingRoots: NativeResolutionProbe | null -> NativeDllResolveHandler
/// Construct a new NativeDllResolveHandler
internal new: nativeProbingRoots: NativeResolutionProbe option -> NativeDllResolveHandler
diff --git a/src/Compiler/Driver/CompilerDiagnostics.fs b/src/Compiler/Driver/CompilerDiagnostics.fs
index 9eb56d1cc54..68813e69a83 100644
--- a/src/Compiler/Driver/CompilerDiagnostics.fs
+++ b/src/Compiler/Driver/CompilerDiagnostics.fs
@@ -678,7 +678,7 @@ type Exception with
showNullnessAnnotations = Some true
}
- let t1, t2, _cxs = NicePrint.minimalStringsOfTwoTypes denv ty1 ty2
+ let t1, _t2, _cxs = NicePrint.minimalStringsOfTwoTypes denv ty1 ty2
os.Append(ConstraintSolverNullnessWarningEquivWithTypesE().Format t1) |> ignore
diff --git a/src/Compiler/Driver/CompilerImports.fs b/src/Compiler/Driver/CompilerImports.fs
index ae14ee51157..4ab1ca3d7e4 100644
--- a/src/Compiler/Driver/CompilerImports.fs
+++ b/src/Compiler/Driver/CompilerImports.fs
@@ -94,20 +94,22 @@ let GetSignatureDataResourceName (r: ILResource) =
failwith "unreachable"
let GetResourceNameAndSignatureDataFuncs (resources: ILResource list) =
- [ for r in resources do
- if IsSignatureDataResource r then
- let readerA, ccuName = GetSignatureDataResourceName r
-
- let readerB =
- resources |> List.tryPick (fun rB ->
- if IsSignatureDataResourceB rB then
- let readerB, ccuNameB = GetSignatureDataResourceName rB
- if ccuName = ccuNameB then
- Some readerB
- else None
- else None)
+ [
+ for r in resources do
+ if IsSignatureDataResource r then
+ let readerA, ccuName = GetSignatureDataResourceName r
+
+ let readerB =
+ resources
+ |> List.tryPick (fun rB ->
+ if IsSignatureDataResourceB rB then
+ let readerB, ccuNameB = GetSignatureDataResourceName rB
+ if ccuName = ccuNameB then Some readerB else None
+ else
+ None)
- ccuName, (readerA, readerB) ]
+ ccuName, (readerA, readerB)
+ ]
let GetOptimizationDataResourceName (r: ILResource) =
if r.Name.StartsWithOrdinal FSharpOptimizationDataResourceName then
@@ -124,19 +126,22 @@ let GetOptimizationDataResourceName (r: ILResource) =
failwith $"GetOptimizationDataResourceName - {r.Name}"
let GetResourceNameAndOptimizationDataFuncs (resources: ILResource list) =
- [ for r in resources do
- if IsOptimizationDataResource r then
- let readerA, ccuName = GetOptimizationDataResourceName r
-
- let readerB =
- resources |> List.tryPick (fun rB ->
- if IsOptimizationDataResourceB rB then
- let readerB, ccuNameB = GetOptimizationDataResourceName rB
- if ccuName = ccuNameB then
- Some readerB
- else None
- else None)
- ccuName, (readerA, readerB) ]
+ [
+ for r in resources do
+ if IsOptimizationDataResource r then
+ let readerA, ccuName = GetOptimizationDataResourceName r
+
+ let readerB =
+ resources
+ |> List.tryPick (fun rB ->
+ if IsOptimizationDataResourceB rB then
+ let readerB, ccuNameB = GetOptimizationDataResourceName rB
+ if ccuName = ccuNameB then Some readerB else None
+ else
+ None)
+
+ ccuName, (readerA, readerB)
+ ]
let IsReflectedDefinitionsResource (r: ILResource) =
r.Name.StartsWithOrdinal(QuotationPickler.SerializedReflectedDefinitionsResourceNameBase)
@@ -163,7 +168,7 @@ let PickleToResource inMem file (g: TcGlobals) compress scope rName rNameB p x =
let byteStorage = ByteStorage.FromByteArray(bytes)
let byteStorageB =
- if inMem then
+ if inMem then
ByteStorage.FromMemoryAndCopy(bytesB.AsMemory(), useBackingMemoryMappedFile = true)
else
ByteStorage.FromByteArray(bytesB.AsMemory().ToArray())
@@ -478,27 +483,28 @@ let isHashRReference (r: range) =
&& not (equals r rangeCmdArgs)
&& FileSystem.IsPathRootedShim r.FileName
-let IsNetModule (fileName:string) =
+let IsNetModule (fileName: string) =
let ext = Path.GetExtension fileName
String.Compare(ext, ".netmodule", StringComparison.OrdinalIgnoreCase) = 0
-let IsDLL (fileName:string) =
+let IsDLL (fileName: string) =
let ext = Path.GetExtension fileName
String.Compare(ext, ".dll", StringComparison.OrdinalIgnoreCase) = 0
-let IsExe (fileName:string) =
+let IsExe (fileName: string) =
let ext = Path.GetExtension fileName
String.Compare(ext, ".exe", StringComparison.OrdinalIgnoreCase) = 0
-let addConstraintSources(ia: ImportedAssembly) =
+let addConstraintSources (ia: ImportedAssembly) =
let contents = ia.FSharpViewOfMetadata.Contents
+
let addCxsToMember name (v: Val) =
for typar in fst v.GeneralizedType do
for cx in typar.Constraints do
match cx with
- | TyparConstraint.MayResolveMember(TTrait(source=source), _) ->
- source.Value <- Some name
+ | TyparConstraint.MayResolveMember(TTrait(source = source), _) -> source.Value <- Some name
| _ -> ()
+
let rec addCxsToModule name (m: ModuleOrNamespaceType) =
for e in m.ModuleAndNamespaceDefinitions do
if e.IsModuleOrNamespace then
@@ -506,8 +512,12 @@ let addConstraintSources(ia: ImportedAssembly) =
if String.length name > 0 then name + "." + e.DisplayName
elif e.IsModule then e.DisplayName
else ""
+
addCxsToModule mname e.ModuleOrNamespaceType
- for memb in m.AllValsAndMembers do addCxsToMember (name + "." + memb.LogicalName) memb
+
+ for memb in m.AllValsAndMembers do
+ addCxsToMember (name + "." + memb.LogicalName) memb
+
addCxsToModule "" contents.ModuleOrNamespaceType
type TcConfig with
@@ -541,7 +551,7 @@ type TcConfig with
yield! tcConfig.GetSearchPathsForLibraryFiles()
if isHashRReference m then
- !! Path.GetDirectoryName(m.FileName)
+ !!Path.GetDirectoryName(m.FileName)
}
let resolved = TryResolveFileUsingPaths(searchPaths, m, nm)
@@ -629,12 +639,8 @@ type TcConfig with
//
// NOTE!! if mode=ReportErrors then this method must not raise exceptions. It must just report the errors and recover
static member TryResolveLibsUsingMSBuildRules
- (
- tcConfig: TcConfig,
- originalReferences: AssemblyReference list,
- errorAndWarningRange: range,
- mode: ResolveAssemblyReferenceMode
- ) : AssemblyResolution list * UnresolvedAssemblyReference list =
+ (tcConfig: TcConfig, originalReferences: AssemblyReference list, errorAndWarningRange: range, mode: ResolveAssemblyReferenceMode)
+ : AssemblyResolution list * UnresolvedAssemblyReference list =
use _ = UseBuildPhase BuildPhase.Parameter
@@ -798,11 +804,8 @@ type TcAssemblyResolutions(tcConfig: TcConfig, results: AssemblyResolution list,
originalReferenceToResolution.TryFind nm
static member ResolveAssemblyReferences
- (
- tcConfig: TcConfig,
- assemblyList: AssemblyReference list,
- knownUnresolved: UnresolvedAssemblyReference list
- ) : TcAssemblyResolutions =
+ (tcConfig: TcConfig, assemblyList: AssemblyReference list, knownUnresolved: UnresolvedAssemblyReference list)
+ : TcAssemblyResolutions =
let resolved, unresolved =
if tcConfig.useSimpleResolution then
let resolutions =
@@ -899,7 +902,7 @@ type TcAssemblyResolutions(tcConfig: TcConfig, results: AssemblyResolution list,
let addedText =
"\nIf you want to debug this right now, attach a debugger, and put a breakpoint in 'CompileOps.fs' near the text '!itFailed', and you can re-step through the assembly resolution logic."
- for UnresolvedAssemblyReference (referenceText, _ranges) in unresolved do
+ for UnresolvedAssemblyReference(referenceText, _ranges) in unresolved do
if referenceText.Contains("mscorlib") then
Debug.Assert(false, sprintf "whoops, did not resolve mscorlib: '%s'%s" referenceText addedText)
itFailed <- true
@@ -989,7 +992,7 @@ type RawFSharpAssemblyDataBackedByFileOnDisk(ilModule: ILModuleDef, ilAssemblyRe
let sigDataReaders =
if sigDataReaders.IsEmpty && List.contains ilShortAssemName externalSigAndOptData then
- let sigFileName = !! Path.ChangeExtension(fileName, "sigdata")
+ let sigFileName = !!Path.ChangeExtension(fileName, "sigdata")
if not (FileSystem.FileExistsShim sigFileName) then
error (Error(FSComp.SR.buildExpectedSigdataFile (FileSystem.GetFullPathShim sigFileName), m))
@@ -1014,7 +1017,7 @@ type RawFSharpAssemblyDataBackedByFileOnDisk(ilModule: ILModuleDef, ilAssemblyRe
// Look for optimization data in a file
let optDataReaders =
if optDataReaders.IsEmpty && List.contains ilShortAssemName externalSigAndOptData then
- let optDataFile = !! Path.ChangeExtension(fileName, "optdata")
+ let optDataFile = !!Path.ChangeExtension(fileName, "optdata")
if not (FileSystem.FileExistsShim optDataFile) then
error (
@@ -1097,11 +1100,7 @@ type RawFSharpAssemblyData(ilModule: ILModuleDef, ilAssemblyRefs) =
[]
type TcImportsSafeDisposal
- (
- tciLock: TcImportsLock,
- disposeActions: ResizeArray unit>,
- disposeTypeProviderActions: ResizeArray unit>
- ) =
+ (tciLock: TcImportsLock, disposeActions: ResizeArray unit>, disposeTypeProviderActions: ResizeArray unit>) =
let mutable isDisposed = false
@@ -1194,7 +1193,7 @@ type TcImportsWeakFacade(tciLock: TcImportsLock, tcImportsWeak: WeakReference
match tcImports.Base with
- | Some (baseTcImports: TcImports) -> Some baseTcImports.Weak
+ | Some(baseTcImports: TcImports) -> Some baseTcImports.Weak
| _ -> None
| _ -> None
@@ -1218,11 +1217,11 @@ and [] TcImports
initialResolutions: TcAssemblyResolutions,
importsBase: TcImports option,
dependencyProviderOpt: DependencyProvider option
- )
+ )
#if !NO_TYPEPROVIDERS
as this
#endif
- =
+ =
let tciLock = TcImportsLock()
@@ -1298,7 +1297,7 @@ and [] TcImports
if publicOnly then
match e.TypeReprInfo with
| TILObjectRepr data ->
- let (TILObjectReprData (_, _, tyDef)) = data
+ let (TILObjectReprData(_, _, tyDef)) = data
tyDef.Access = ILTypeDefAccess.Public
| _ -> false
else
@@ -1433,14 +1432,14 @@ and [] TcImports
CheckDisposed()
match tcImports.FindCcuInfo(ctok, m, assemblyName, lookupOnly) with
- | ResolvedImportedAssembly (importedAssembly, _) -> ResolvedCcu(importedAssembly.FSharpViewOfMetadata)
- | UnresolvedImportedAssembly (assemblyName, _) -> UnresolvedCcu assemblyName
+ | ResolvedImportedAssembly(importedAssembly, _) -> ResolvedCcu(importedAssembly.FSharpViewOfMetadata)
+ | UnresolvedImportedAssembly(assemblyName, _) -> UnresolvedCcu assemblyName
member tcImports.FindCcuFromAssemblyRef(ctok, m, assemblyRef: ILAssemblyRef) =
CheckDisposed()
match tcImports.FindCcuInfo(ctok, m, assemblyRef.Name, lookupOnly = false) with
- | ResolvedImportedAssembly (importedAssembly, _) -> ResolvedCcu(importedAssembly.FSharpViewOfMetadata)
+ | ResolvedImportedAssembly(importedAssembly, _) -> ResolvedCcu(importedAssembly.FSharpViewOfMetadata)
| UnresolvedImportedAssembly _ -> UnresolvedCcu(assemblyRef.QualifiedName)
member tcImports.TryFindXmlDocumentationInfo(assemblyName: string) =
@@ -1562,7 +1561,7 @@ and [] TcImports
member _.RecordGeneratedTypeRoot root =
tciLock.AcquireLock(fun tcitok ->
// checking if given ProviderGeneratedType was already recorded before (probably for another set of static parameters)
- let (ProviderGeneratedType (_, ilTyRef, _)) = root
+ let (ProviderGeneratedType(_, ilTyRef, _)) = root
let index =
RequireTcImportsLock(tcitok, generatedTypeRoots)
@@ -1810,7 +1809,7 @@ and [] TcImports
| TNoRepr -> TProvidedNamespaceRepr(typeProviderEnvironment, [ provider ])
// Add to the existing list of extensions
- | TProvidedNamespaceRepr (resolutionFolder, prior) as repr ->
+ | TProvidedNamespaceRepr(resolutionFolder, prior) as repr ->
if not (prior |> List.exists (fun r -> Tainted.EqTainted r provider)) then
TProvidedNamespaceRepr(resolutionFolder, provider :: prior)
else
@@ -1860,7 +1859,7 @@ and [] TcImports
|> Option.get
// MSDN: this method causes the file to be opened and closed, but the assembly is not added to this domain
let name = AssemblyName.GetAssemblyName(resolution.resolvedPath)
- !! name.Version
+ !!name.Version
// Note, this only captures systemRuntimeContainsTypeRef (which captures tcImportsWeak, using name tcImports)
let systemRuntimeContainsType =
@@ -1869,8 +1868,7 @@ and [] TcImports
// The name of this captured value must not change, see comments on TcImportsWeakFacade above
assert (nameof (tcImports) = "tcImports")
- let mutable systemRuntimeContainsTypeRef =
- tcImports.SystemRuntimeContainsType
+ let mutable systemRuntimeContainsTypeRef = tcImports.SystemRuntimeContainsType
// When the tcImports is disposed the systemRuntimeContainsTypeRef thunk is replaced
// with one raising an exception.
@@ -1961,7 +1959,7 @@ and [] TcImports
match providers with
| [] ->
- let typeName = !! typeof.FullName
+ let typeName = !!typeof.FullName
warning (Error(FSComp.SR.etHostingAssemblyFoundWithoutHosts (fileNameOfRuntimeAssembly, typeName), m))
| _ ->
@@ -2122,7 +2120,7 @@ and [] TcImports
let minfo: PickledCcuInfo = data.RawData
let mspec = minfo.mspec
-
+
if mspec.DisplayName = "FSharp.Core" then
updateSeqTypeIsPrefix mspec
@@ -2167,7 +2165,7 @@ and [] TcImports
InterruptibleLazy(fun _ ->
match Map.tryFind ccuName optDatas with
| None -> None
- | Some (readerA, readerB) ->
+ | Some(readerA, readerB) ->
let data =
GetOptimizationData(fileName, ilScopeRef, ilModule.TryGetILModuleDef(), readerA, readerB)
@@ -2182,8 +2180,8 @@ and [] TcImports
if ccuThunk.IsUnresolvedReference then
ccuThunks.Add(ccuThunk, (fun () -> fixupThunk () |> ignore)))
- Some(fixupThunk ())
- )
+ Some(fixupThunk ()))
+
let ccuinfo =
{
FSharpViewOfMetadata = ccu
@@ -2250,10 +2248,8 @@ and [] TcImports
// NOTE: When used in the Language Service this can cause the transitive checking of projects. Hence it must be cancellable.
member tcImports.TryRegisterAndPrepareToImportReferencedDll
- (
- ctok,
- r: AssemblyResolution
- ) : Async<(_ * (unit -> AvailableImportedAssembly list)) option> =
+ (ctok, r: AssemblyResolution)
+ : Async<(_ * (unit -> AvailableImportedAssembly list)) option> =
async {
CheckDisposed()
let m = r.originalReference.Range
@@ -2349,9 +2345,11 @@ and [] TcImports
let _dllinfos, phase2s = results |> Array.choose id |> List.ofArray |> List.unzip
fixupOrphanCcus ()
let ccuinfos = List.collect (fun phase2 -> phase2 ()) phase2s
+
if importsBase.IsSome then
importsBase.Value.CcuTable.Values |> Seq.iter addConstraintSources
ccuTable.Values |> Seq.iter addConstraintSources
+
return ccuinfos
}
@@ -2374,7 +2372,7 @@ and [] TcImports
)
match foundFile with
- | OkResult (warns, res) ->
+ | OkResult(warns, res) ->
ReportWarnings warns
tcImports.RegisterAndImportReferencedAssemblies(ctok, res)
@@ -2382,7 +2380,7 @@ and [] TcImports
|> ignore
true
- | ErrorResult (_warns, _err) ->
+ | ErrorResult(_warns, _err) ->
// Throw away warnings and errors - this is speculative loading
false
@@ -2418,11 +2416,8 @@ and [] TcImports
|> Option.map (fun r -> r.resolvedPath))
member _.TryResolveAssemblyReference
- (
- ctok,
- assemblyReference: AssemblyReference,
- mode: ResolveAssemblyReferenceMode
- ) : OperationResult =
+ (ctok, assemblyReference: AssemblyReference, mode: ResolveAssemblyReferenceMode)
+ : OperationResult =
tciLock.AcquireLock(fun tcitok ->
let tcConfig = tcConfigP.Get ctok
@@ -2462,8 +2457,7 @@ and [] TcImports
| [], [] ->
// Note, if mode=ResolveAssemblyReferenceMode.Speculative and the resolution failed then TryResolveLibsUsingMSBuildRules returns
// the empty list and we convert the failure into an AssemblyNotResolved here.
- ErrorD(AssemblyNotResolved(assemblyReference.Text, assemblyReference.Range))
- )
+ ErrorD(AssemblyNotResolved(assemblyReference.Text, assemblyReference.Range)))
member tcImports.ResolveAssemblyReference(ctok, assemblyReference, mode) : AssemblyResolution list =
CommitOperationResult(tcImports.TryResolveAssemblyReference(ctok, assemblyReference, mode))
@@ -2507,7 +2501,7 @@ and [] TcImports
let primaryScopeRef =
match primaryAssem with
- | [ ResolvedImportedAssembly (ccu, _) ] -> ccu.FSharpViewOfMetadata.ILScopeRef
+ | [ ResolvedImportedAssembly(ccu, _) ] -> ccu.FSharpViewOfMetadata.ILScopeRef
| _ -> failwith "primaryScopeRef - unexpected"
let resolvedAssemblies = tcResolutions.GetAssemblyResolutions()
@@ -2568,7 +2562,7 @@ and [] TcImports
match resolvedAssemblyRef with
| Some coreLibraryResolution ->
match! frameworkTcImports.RegisterAndImportReferencedAssemblies(ctok, [ coreLibraryResolution ]) with
- | [ ResolvedImportedAssembly (fslibCcuInfo, _) ] ->
+ | [ ResolvedImportedAssembly(fslibCcuInfo, _) ] ->
return fslibCcuInfo.FSharpViewOfMetadata, fslibCcuInfo.ILScopeRef
| _ ->
return
@@ -2633,17 +2627,12 @@ and [] TcImports
knownUnresolved
|> List.map (function
- | UnresolvedAssemblyReference (file, originalReferences) -> file, originalReferences)
+ | UnresolvedAssemblyReference(file, originalReferences) -> file, originalReferences)
|> List.iter reportAssemblyNotResolved
static member BuildNonFrameworkTcImports
- (
- tcConfigP: TcConfigProvider,
- baseTcImports,
- nonFrameworkReferences,
- knownUnresolved,
- dependencyProvider
- ) =
+ (tcConfigP: TcConfigProvider, baseTcImports, nonFrameworkReferences, knownUnresolved, dependencyProvider)
+ =
async {
let ctok = CompilationThreadToken()
@@ -2700,8 +2689,8 @@ let RequireReferences (ctok, tcImports: TcImports, tcEnv, thisAssemblyName, reso
let asms =
ccuinfos
|> List.map (function
- | ResolvedImportedAssembly (asm, m) -> asm, m
- | UnresolvedImportedAssembly (assemblyName, m) -> error (Error(FSComp.SR.buildCouldNotResolveAssembly (assemblyName), m)))
+ | ResolvedImportedAssembly(asm, m) -> asm, m
+ | UnresolvedImportedAssembly(assemblyName, m) -> error (Error(FSComp.SR.buildCouldNotResolveAssembly (assemblyName), m)))
let g = tcImports.GetTcGlobals()
let amap = tcImports.GetImportMap()
diff --git a/src/Compiler/Driver/ScriptClosure.fs b/src/Compiler/Driver/ScriptClosure.fs
index b97b11a8054..b45049627cf 100644
--- a/src/Compiler/Driver/ScriptClosure.fs
+++ b/src/Compiler/Driver/ScriptClosure.fs
@@ -327,11 +327,13 @@ module ScriptPreprocessClosure =
for kv in tcConfig.packageManagerLines do
let packageManagerKey, packageManagerLines = kv.Key, kv.Value
- match packageManagerLines |> List.filter (not << isEditorCursorInPackageLines) with
+ let packageManagerLines =
+ packageManagerLines |> List.filter (not << isEditorCursorInPackageLines)
+
+ match packageManagerLines with
| [] -> ()
| packageManagerLine :: _ ->
let m = packageManagerLine.Range
- let packageManagerLines = packageManagerLines
yield! processPackageManagerLines m packageManagerLines scriptName packageManagerKey
]
diff --git a/src/Compiler/FSharp.Compiler.Service.fsproj b/src/Compiler/FSharp.Compiler.Service.fsproj
index 493248a11d3..74e59954e8f 100644
--- a/src/Compiler/FSharp.Compiler.Service.fsproj
+++ b/src/Compiler/FSharp.Compiler.Service.fsproj
@@ -10,12 +10,11 @@
$(NoWarn);75
$(NoWarn);1204
$(NoWarn);NU5125
- $(NoWarn);64;1182;1204
- $(OtherFlags) --warnaserror-:1182
+ $(NoWarn);64;1204
FSharp.Compiler.Service
true
$(DefineConstants);COMPILER
- true
+ enable
- $(FSharpNetCoreProductDefaultTargetFramework);$(TargetFrameworks)
+ $(FSharpNetCoreProductTargetFramework);$(TargetFrameworks)
$(DefineConstants);FSHARPCORE_USE_PACKAGE
$(OtherFlags) --extraoptimizationloops:1
-
-
-
- $(OtherFlags) --nowarn:1182
-
$(OtherFlags) --warnon:3218
$(OtherFlags) --warnon:3390
+
+ $(OtherFlags) --nowarn:3261
+
$(OtherFlags) --generate-filter-blocks
true
diff --git a/src/Compiler/Facilities/AsyncMemoize.fs b/src/Compiler/Facilities/AsyncMemoize.fs
index 991c8359312..ac52eaf8607 100644
--- a/src/Compiler/Facilities/AsyncMemoize.fs
+++ b/src/Compiler/Facilities/AsyncMemoize.fs
@@ -21,17 +21,21 @@ type AsyncLazyState<'t> =
/// When cacheException is false, subsequent requests will restart the computation after an exceptional result.
type AsyncLazy<'t> private (initial: AsyncLazyState<'t>, cancelUnawaited: bool, cacheException: bool) =
- let stateUpdateSync = obj()
+ let stateUpdateSync = obj ()
let mutable state = initial
// This should remain the only function that mutates the state.
let withStateUpdate f =
- lock stateUpdateSync <| fun () ->
+ lock stateUpdateSync
+ <| fun () ->
let next, result = f state
state <- next
result
- let updateState f = withStateUpdate <| fun prev -> f prev, ()
- let cancelIfUnawaited cancelUnawaited = function
+ let updateState f =
+ withStateUpdate <| fun prev -> f prev, ()
+
+ let cancelIfUnawaited cancelUnawaited =
+ function
| Running(computation, _, cts, 0) when cancelUnawaited ->
// To keep state updates fast we don't actually wait for the work to cancel.
// This means single execution is not strictly enforced.
@@ -39,7 +43,8 @@ type AsyncLazy<'t> private (initial: AsyncLazyState<'t>, cancelUnawaited: bool,
Initial computation
| state -> state
- let afterRequest = function
+ let afterRequest =
+ function
| Running(c, work, cts, count) -> Running(c, work, cts, count - 1) |> cancelIfUnawaited cancelUnawaited
| state -> state // Nothing more to do if state already transitioned.
@@ -49,37 +54,42 @@ type AsyncLazy<'t> private (initial: AsyncLazyState<'t>, cancelUnawaited: bool,
let! ct = Async.CancellationToken
// Using ContinueWith with a CancellationToken allows detaching from the running 'work' task.
// If the current async workflow is canceled, the 'work' task will continue running independently.
- do! work.ContinueWith(ignore>, ct) |> Async.AwaitTask
- with :? TaskCanceledException -> ()
+ do! work.ContinueWith(ignore>, ct) |> Async.AwaitTask
+ with :? TaskCanceledException ->
+ ()
// If we're here it means there was no cancellation and the 'work' task has completed.
return! work |> Async.AwaitTask
}
let onComplete (t: Task<'t>) =
- updateState <| function
- | Running (computation, _, _, _) ->
- try Completed t.Result with exn -> if cacheException then Faulted exn else Initial computation
+ updateState
+ <| function
+ | Running(computation, _, _, _) ->
+ try
+ Completed t.Result
+ with exn ->
+ if cacheException then Faulted exn else Initial computation
| state -> state
+
t.Result
- let request = function
+ let request =
+ function
| Initial computation ->
let cts = new CancellationTokenSource()
+
let work =
- Async.StartAsTask(computation, cancellationToken = cts.Token)
+ Async
+ .StartAsTask(computation, cancellationToken = cts.Token)
.ContinueWith(onComplete, TaskContinuationOptions.NotOnCanceled)
- Running (computation, work, cts, 1),
- detachable work
- | Running (c, work, cts, count) ->
- Running (c, work, cts, count + 1),
- detachable work
- | Completed result as state ->
- state, async { return result }
- | Faulted exn as state ->
- state, async { return raise exn }
+
+ Running(computation, work, cts, 1), detachable work
+ | Running(c, work, cts, count) -> Running(c, work, cts, count + 1), detachable work
+ | Completed result as state -> state, async { return result }
+ | Faulted exn as state -> state, async { return raise exn }
// computation will deallocate after state transition to Completed ot Faulted.
- new (computation, ?cancelUnawaited: bool, ?cacheException) =
+ new(computation, ?cancelUnawaited: bool, ?cacheException) =
AsyncLazy(Initial computation, defaultArg cancelUnawaited true, defaultArg cacheException true)
member _.Request() =
@@ -104,7 +114,7 @@ module internal Utils =
/// Return file name with one directory above it
let shortPath (path: string) =
- let dirPath = !! Path.GetDirectoryName(path)
+ let dirPath = !!Path.GetDirectoryName(path)
let dir =
dirPath.Split Path.DirectorySeparatorChar
@@ -126,7 +136,21 @@ type internal JobEvent =
| Strengthened
| Failed
| Cleared
- static member AllEvents = [Requested; Started; Restarted; Finished; Canceled; Evicted; Collected; Weakened; Strengthened; Failed; Cleared]
+
+ static member AllEvents =
+ [
+ Requested
+ Started
+ Restarted
+ Finished
+ Canceled
+ Evicted
+ Collected
+ Weakened
+ Strengthened
+ Failed
+ Cleared
+ ]
type internal ICacheKey<'TKey, 'TVersion> =
// TODO Key should probably be renamed to Identifier
@@ -155,20 +179,22 @@ type private KeyData<'TKey, 'TVersion> =
type Job<'t> = AsyncLazy * CapturingDiagnosticsLogger>
[]
-type internal AsyncMemoize<'TKey, 'TVersion, 'TValue when 'TKey: equality and 'TVersion: equality and 'TKey:not null and 'TVersion:not null>
+type internal AsyncMemoize<'TKey, 'TVersion, 'TValue
+ when 'TKey: equality and 'TVersion: equality and 'TKey: not null and 'TVersion: not null>
(?keepStrongly, ?keepWeakly, ?name: string, ?cancelUnawaitedJobs: bool, ?cancelDuplicateRunningJobs: bool) =
- let name = defaultArg name "N/A"
+ let _name = defaultArg name "N/A"
let cancelUnawaitedJobs = defaultArg cancelUnawaitedJobs true
let cancelDuplicateRunningJobs = defaultArg cancelDuplicateRunningJobs false
let event = Event<_>()
- let eventCounts = [for j in JobEvent.AllEvents -> j, ref 0] |> dict
+ let eventCounts = [ for j in JobEvent.AllEvents -> j, ref 0 ] |> dict
let mutable hits = 0
let mutable duration = 0L
- let keyTuple (keyData: KeyData<_, _>) = keyData.Label, keyData.Key, keyData.Version
+ let keyTuple (keyData: KeyData<_, _>) =
+ keyData.Label, keyData.Key, keyData.Version
let logK (eventType: JobEvent) key =
Interlocked.Increment(eventCounts[eventType]) |> ignore
@@ -186,7 +212,8 @@ type internal AsyncMemoize<'TKey, 'TVersion, 'TValue when 'TKey: equality and 'T
| CacheEvent.Collected -> logK JobEvent.Collected
| CacheEvent.Weakened -> logK JobEvent.Weakened
| CacheEvent.Strengthened -> logK JobEvent.Strengthened
- | CacheEvent.Cleared -> logK JobEvent.Cleared))
+ | CacheEvent.Cleared -> logK JobEvent.Cleared)
+ )
member _.Get(key: ICacheKey<_, _>, computation) =
let key =
@@ -197,38 +224,44 @@ type internal AsyncMemoize<'TKey, 'TVersion, 'TValue when 'TKey: equality and 'T
}
let wrappedComputation =
- Async.TryCancelled( async {
- let sw = Stopwatch.StartNew()
- log Started key
- let logger = CapturingDiagnosticsLogger "cache"
- SetThreadDiagnosticsLoggerNoUnwind logger
-
- match! computation |> Async.Catch with
- | Choice1Of2 result ->
- log Finished key
- Interlocked.Add(&duration, sw.ElapsedMilliseconds) |> ignore
- return Result.Ok result, logger
- | Choice2Of2 exn ->
- log Failed key
- return Result.Error exn, logger
- }, fun _ -> log Canceled key)
+ Async.TryCancelled(
+ async {
+ let sw = Stopwatch.StartNew()
+ log Started key
+ let logger = CapturingDiagnosticsLogger "cache"
+ SetThreadDiagnosticsLoggerNoUnwind logger
+
+ match! computation |> Async.Catch with
+ | Choice1Of2 result ->
+ log Finished key
+ Interlocked.Add(&duration, sw.ElapsedMilliseconds) |> ignore
+ return Result.Ok result, logger
+ | Choice2Of2 exn ->
+ log Failed key
+ return Result.Error exn, logger
+ },
+ fun _ -> log Canceled key
+ )
let getOrAdd () =
let cached, otherVersions = cache.GetAll(key.Key, key.Version)
- let countHit v = Interlocked.Increment &hits |> ignore; v
+ let countHit v =
+ Interlocked.Increment &hits |> ignore
+ v
+
let cacheSetNewJob () =
- let job = Job(wrappedComputation, cancelUnawaited = cancelUnawaitedJobs, cacheException = false)
+ let job =
+ Job(wrappedComputation, cancelUnawaited = cancelUnawaitedJobs, cacheException = false)
+
cache.Set(key.Key, key.Version, key.Label, job)
job
otherVersions,
- cached
- |> Option.map countHit
- |> Option.defaultWith cacheSetNewJob
+ cached |> Option.map countHit |> Option.defaultWith cacheSetNewJob
- async {
+ async {
let otherVersions, job = lock cache getOrAdd
log Requested key
@@ -240,15 +273,15 @@ type internal AsyncMemoize<'TKey, 'TVersion, 'TValue when 'TKey: equality and 'T
let! result, logger = job.Request()
logger.CommitDelayedDiagnostics DiagnosticsThreadStatics.DiagnosticsLogger
+
match result with
- | Ok result ->
- return result
- | Error exn ->
- return raise exn
+ | Ok result -> return result
+ | Error exn -> return raise exn
}
member _.TryGet(key: 'TKey, predicate: 'TVersion -> bool) : 'TValue option =
- lock cache <| fun () ->
+ lock cache
+ <| fun () ->
cache.GetAll(key)
|> Seq.tryPick (fun (version, job) ->
match predicate version, job.TryResult with
@@ -257,7 +290,8 @@ type internal AsyncMemoize<'TKey, 'TVersion, 'TValue when 'TKey: equality and 'T
member _.Clear() = lock cache cache.Clear
- member _.Clear predicate = lock cache <| fun () -> cache.Clear predicate
+ member _.Clear predicate =
+ lock cache <| fun () -> cache.Clear predicate
member val Event = event.Publish
@@ -267,26 +301,39 @@ type internal AsyncMemoize<'TKey, 'TVersion, 'TValue when 'TKey: equality and 'T
member this.DebuggerDisplay =
- let cachedJobs = cache.GetValues() |> Seq.map (fun (_,_,job) -> job)
+ let cachedJobs = cache.GetValues() |> Seq.map (fun (_, _, job) -> job)
- let jobStateName = function
- | Initial _ -> nameof Initial
- | Running _ -> nameof Running
- | Completed _ -> nameof Completed
- | Faulted _ -> nameof Faulted
+ let jobStateName =
+ function
+ | Initial _ -> nameof Initial
+ | Running _ -> nameof Running
+ | Completed _ -> nameof Completed
+ | Faulted _ -> nameof Faulted
let valueStats = cachedJobs |> Seq.countBy (_.State >> jobStateName) |> Map
- let getStat key = valueStats.TryFind key |> Option.defaultValue 0
+
+ let getStat key =
+ valueStats.TryFind key |> Option.defaultValue 0
let running =
let count = getStat "Running"
- if count > 0 then $" Running {count}" else ""
+ if count > 0 then $" Running {count}" else ""
let finished = eventCounts[Finished].Value
- let avgDuration = if finished = 0 then "" else $"| Avg: %.0f{float duration / float finished} ms"
+
+ let avgDuration =
+ if finished = 0 then
+ ""
+ else
+ $"| Avg: %.0f{float duration / float finished} ms"
let requests = eventCounts[Requested].Value
- let hitRatio = if requests = 0 then "" else $" (%.0f{float hits / (float (requests)) * 100.0} %%)"
+
+ let hitRatio =
+ if requests = 0 then
+ ""
+ else
+ $" (%.0f{float hits / (float (requests)) * 100.0} %%)"
let faulted = getStat "Faulted"
let failed = eventCounts[Failed].Value
@@ -295,9 +342,11 @@ type internal AsyncMemoize<'TKey, 'TVersion, 'TValue when 'TKey: equality and 'T
seq {
if faulted + failed > 0 then
" (_!_) "
+
for j in eventCounts.Keys do
let count = eventCounts[j].Value
if count > 0 then $"| {j}: {count}" else ""
+
$"| hits: {hits}{hitRatio} "
}
|> String.concat ""
@@ -317,4 +366,4 @@ type internal AsyncMemoizeDisabled<'TKey, 'TVersion, 'TValue when 'TKey: equalit
Interlocked.Increment &requests |> ignore
computation
- member _.DebuggerDisplay = $"(disabled) requests: {requests}"
\ No newline at end of file
+ member _.DebuggerDisplay = $"(disabled) requests: {requests}"
diff --git a/src/Compiler/Facilities/AsyncMemoize.fsi b/src/Compiler/Facilities/AsyncMemoize.fsi
index 6b9ffb4f433..1014dfc6874 100644
--- a/src/Compiler/Facilities/AsyncMemoize.fsi
+++ b/src/Compiler/Facilities/AsyncMemoize.fsi
@@ -42,7 +42,8 @@ type Extensions =
///
/// Strongly holds at most one result per key.
///
-type internal AsyncMemoize<'TKey, 'TVersion, 'TValue when 'TKey: equality and 'TVersion: equality and 'TKey:not null and 'TVersion:not null> =
+type internal AsyncMemoize<'TKey, 'TVersion, 'TValue
+ when 'TKey: equality and 'TVersion: equality and 'TKey: not null and 'TVersion: not null> =
/// Maximum number of strongly held results to keep in the cache
/// Maximum number of weakly held results to keep in the cache
@@ -50,7 +51,11 @@ type internal AsyncMemoize<'TKey, 'TVersion, 'TValue when 'TKey: equality and 'T
/// Cancels a job when all the awaiting requests are canceled. If set to false, unawaited job will run to completion and it's result will be cached.
/// If true, when a job is started, all other jobs with the same key will be canceled.
new:
- ?keepStrongly: int * ?keepWeakly: int * ?name: string * ?cancelUnawaitedJobs: bool * ?cancelDuplicateRunningJobs: bool ->
+ ?keepStrongly: int *
+ ?keepWeakly: int *
+ ?name: string *
+ ?cancelUnawaitedJobs: bool *
+ ?cancelDuplicateRunningJobs: bool ->
AsyncMemoize<'TKey, 'TVersion, 'TValue>
member Clear: unit -> unit
diff --git a/src/Compiler/Facilities/CompilerLocation.fs b/src/Compiler/Facilities/CompilerLocation.fs
index 7d902aefc27..abd436647ae 100644
--- a/src/Compiler/Facilities/CompilerLocation.fs
+++ b/src/Compiler/Facilities/CompilerLocation.fs
@@ -304,7 +304,7 @@ module internal FSharpEnvironment =
// How to find dotnet.exe --- woe is me; probing rules make me sad.
// Algorithm:
// 1. Look for DOTNET_HOST_PATH environment variable
- // this is the main user programable override .. provided by user to find a specific dotnet.exe
+ // this is the main user programmable override .. provided by user to find a specific dotnet.exe
// 2. Probe for are we part of an .NetSDK install
// In an sdk install we are always installed in: sdk\3.0.100-rc2-014234\FSharp
// dotnet or dotnet.exe will be found in the directory that contains the sdk directory
diff --git a/src/Compiler/Optimize/Optimizer.fs b/src/Compiler/Optimize/Optimizer.fs
index 69fb9b45974..2840331f54b 100644
--- a/src/Compiler/Optimize/Optimizer.fs
+++ b/src/Compiler/Optimize/Optimizer.fs
@@ -1734,9 +1734,9 @@ let TryEliminateBinding cenv _env bind e2 _m =
// Immediate consumption of delegate via an application in a sequential, e.g. 'let part1 = e in part1.Invoke(args); rest'
// See https://github.com/fsharp/fslang-design/blob/master/tooling/FST-1034-lambda-optimizations.md
- | Expr.Sequential(DebugPoints(DelegateInvokeExpr g (delInvokeRef, delInvokeTy, DebugPoints (Expr.Val (VRefLocal vspec2, _, _), recreate2), delInvokeArg, _), recreate1), rest, NormalSeq, m)
+ | Expr.Sequential(DebugPoints(DelegateInvokeExpr g (delInvokeRef, delInvokeTy, tyargs, DebugPoints (Expr.Val (VRefLocal vspec2, _, _), recreate2), delInvokeArg, _), recreate1), rest, NormalSeq, m)
when IsUniqueUse vspec2 [rest;delInvokeArg] ->
- let invoke = MakeFSharpDelegateInvokeAndTryBetaReduce g (delInvokeRef, recreate2 e1, delInvokeTy, delInvokeArg, m)
+ let invoke = MakeFSharpDelegateInvokeAndTryBetaReduce g (delInvokeRef, recreate2 e1, delInvokeTy, tyargs, delInvokeArg, m)
Some (Expr.Sequential(recreate1 invoke, rest, NormalSeq, m) |> recreate0)
// Immediate consumption of value by a pattern match 'let x = e in match x with ...'
@@ -2397,8 +2397,8 @@ let rec OptimizeExpr cenv (env: IncrementalOptimizationEnv) expr =
| Expr.App (f, fty, tyargs, argsl, m) ->
match expr with
- | DelegateInvokeExpr g (delInvokeRef, delInvokeTy, delExpr, delInvokeArg, m) ->
- OptimizeFSharpDelegateInvoke cenv env (delInvokeRef, delExpr, delInvokeTy, delInvokeArg, m)
+ | DelegateInvokeExpr g (delInvokeRef, delInvokeTy, tyargs, delExpr, delInvokeArg, m) ->
+ OptimizeFSharpDelegateInvoke cenv env (delInvokeRef, delExpr, delInvokeTy, tyargs, delInvokeArg, m)
| _ ->
let attempt =
if IsDebugPipeRightExpr cenv expr then
@@ -3799,18 +3799,18 @@ and OptimizeDebugPipeRights cenv env expr =
pipesExprR
expr, { pipesInfo with HasEffect=true}
-and OptimizeFSharpDelegateInvoke cenv env (delInvokeRef, delExpr, delInvokeTy, delInvokeArg, m) =
+and OptimizeFSharpDelegateInvoke cenv env (delInvokeRef, delExpr, delInvokeTy, tyargs, delInvokeArg, m) =
let g = cenv.g
let optf0, finfo = OptimizeExpr cenv env delExpr
- match StripPreComputationsFromComputedFunction g optf0 [delInvokeArg] (fun f delInvokeArgsR -> MakeFSharpDelegateInvokeAndTryBetaReduce g (delInvokeRef, f, delInvokeTy, List.head delInvokeArgsR, m)) with
+ match StripPreComputationsFromComputedFunction g optf0 [delInvokeArg] (fun f delInvokeArgsR -> MakeFSharpDelegateInvokeAndTryBetaReduce g (delInvokeRef, f, delInvokeTy, tyargs, List.head delInvokeArgsR, m)) with
| Choice1Of2 remade ->
OptimizeExpr cenv env remade
| Choice2Of2 (newf0, remake) ->
let newDelInvokeArgs, arginfos = OptimizeExprsThenConsiderSplits cenv env [delInvokeArg]
let newDelInvokeArg = List.head newDelInvokeArgs
- let reducedExpr = MakeFSharpDelegateInvokeAndTryBetaReduce g (delInvokeRef, newf0, delInvokeTy, newDelInvokeArg, m)
+ let reducedExpr = MakeFSharpDelegateInvokeAndTryBetaReduce g (delInvokeRef, newf0, delInvokeTy, tyargs, newDelInvokeArg, m)
let newExpr = reducedExpr |> remake
match newf0, reducedExpr with
| Expr.Obj _, Expr.Let _ ->
diff --git a/src/Compiler/Service/TransparentCompiler.fs b/src/Compiler/Service/TransparentCompiler.fs
index 39560cb3b6b..4385ca4f1e3 100644
--- a/src/Compiler/Service/TransparentCompiler.fs
+++ b/src/Compiler/Service/TransparentCompiler.fs
@@ -2355,7 +2355,7 @@ type internal TransparentCompiler
(
fileName: string,
sourceText: ISourceTextNew,
- caret: Position option,
+ _caret: Position option,
documentSource: DocumentSource,
previewEnabled: bool option,
loadedTimeStamp: DateTime option,
diff --git a/src/Compiler/Symbols/SymbolHelpers.fs b/src/Compiler/Symbols/SymbolHelpers.fs
index 1fedee2968a..c516f0c377b 100644
--- a/src/Compiler/Symbols/SymbolHelpers.fs
+++ b/src/Compiler/Symbols/SymbolHelpers.fs
@@ -5,15 +5,15 @@ namespace FSharp.Compiler.Symbols
open System
open System.IO
-open Internal.Utilities.Library
+open Internal.Utilities.Library
open Internal.Utilities.Library.Extras
open FSharp.Core.Printf
-open FSharp.Compiler
-open FSharp.Compiler.AbstractIL.Diagnostics
+open FSharp.Compiler
+open FSharp.Compiler.AbstractIL.Diagnostics
open FSharp.Compiler.DiagnosticsLogger
open FSharp.Compiler.InfoReader
open FSharp.Compiler.Infos
-open FSharp.Compiler.IO
+open FSharp.Compiler.IO
open FSharp.Compiler.NameResolution
open FSharp.Compiler.Syntax.PrettyNaming
open FSharp.Compiler.Text
@@ -25,7 +25,7 @@ open FSharp.Compiler.TypedTree
open FSharp.Compiler.TypedTreeBasics
open FSharp.Compiler.TypedTreeOps
open FSharp.Compiler.TypeHierarchy
-open FSharp.Compiler.TcGlobals
+open FSharp.Compiler.TcGlobals
/// Describe a comment as either a block of text or a file+signature reference into an intellidoc file.
[]
@@ -38,46 +38,46 @@ module EnvMisc2 =
let maxMembers = GetEnvInteger "FCS_MaxMembersInQuickInfo" 10
[]
-module internal SymbolHelpers =
+module internal SymbolHelpers =
let rangeOfValRef preferFlag (vref: ValRef) =
- match preferFlag with
- | None -> vref.Range
- | Some false -> vref.DefinitionRange
+ match preferFlag with
+ | None -> vref.Range
+ | Some false -> vref.DefinitionRange
| Some true -> vref.SigRange
let rangeOfEntityRef preferFlag (eref: EntityRef) =
- match preferFlag with
- | None -> eref.Range
- | Some false -> eref.DefinitionRange
+ match preferFlag with
+ | None -> eref.Range
+ | Some false -> eref.DefinitionRange
| Some true -> eref.SigRange
-
+
let rangeOfPropInfo preferFlag (pinfo: PropInfo) =
match pinfo with
-#if !NO_TYPEPROVIDERS
+#if !NO_TYPEPROVIDERS
| ProvidedProp(_, pi, _) -> Construct.ComputeDefinitionLocationOfProvidedItem pi
#endif
| _ -> pinfo.ArbitraryValRef |> Option.map (rangeOfValRef preferFlag)
- let rangeOfMethInfo (g: TcGlobals) preferFlag (minfo: MethInfo) =
+ let rangeOfMethInfo (g: TcGlobals) preferFlag (minfo: MethInfo) =
match minfo with
-#if !NO_TYPEPROVIDERS
+#if !NO_TYPEPROVIDERS
| ProvidedMeth(_, mi, _, _) -> Construct.ComputeDefinitionLocationOfProvidedItem mi
#endif
| DefaultStructCtor(_, AppTy g (tcref, _)) -> Some(rangeOfEntityRef preferFlag tcref)
| _ -> minfo.ArbitraryValRef |> Option.map (rangeOfValRef preferFlag)
- let rangeOfEventInfo preferFlag (einfo: EventInfo) =
+ let rangeOfEventInfo preferFlag (einfo: EventInfo) =
match einfo with
-#if !NO_TYPEPROVIDERS
+#if !NO_TYPEPROVIDERS
| ProvidedEvent (_, ei, _) -> Construct.ComputeDefinitionLocationOfProvidedItem ei
#endif
| _ -> einfo.ArbitraryValRef |> Option.map (rangeOfValRef preferFlag)
-
- let rangeOfUnionCaseInfo preferFlag (ucinfo: UnionCaseInfo) =
- match preferFlag with
- | None -> ucinfo.UnionCase.Range
- | Some false -> ucinfo.UnionCase.DefinitionRange
+
+ let rangeOfUnionCaseInfo preferFlag (ucinfo: UnionCaseInfo) =
+ match preferFlag with
+ | None -> ucinfo.UnionCase.Range
+ | Some false -> ucinfo.UnionCase.DefinitionRange
| Some true -> ucinfo.UnionCase.SigRange
let rangeOfRecdField preferFlag (rField: RecdField) =
@@ -89,7 +89,7 @@ module internal SymbolHelpers =
let rangeOfRecdFieldInfo preferFlag (rfinfo: RecdFieldInfo) =
rangeOfRecdField preferFlag rfinfo.RecdField
- let rec rangeOfItem (g: TcGlobals) preferFlag d =
+ let rec rangeOfItem (g: TcGlobals) preferFlag d =
match d with
| Item.Value vref | Item.CustomBuilder (_, vref) -> Some (rangeOfValRef preferFlag vref)
| Item.UnionCase(ucinfo, _) -> Some (rangeOfUnionCaseInfo preferFlag ucinfo)
@@ -103,13 +103,13 @@ module internal SymbolHelpers =
| Item.Property(info = pinfos; sourceIdentifierRange = mNameOpt) ->
match mNameOpt with
| Some m -> Some m
- | None -> rangeOfPropInfo preferFlag pinfos.Head
+ | None -> rangeOfPropInfo preferFlag pinfos.Head
| Item.Types(_, tys) -> tys |> List.tryPick (tryNiceEntityRefOfTyOption >> Option.map (rangeOfEntityRef preferFlag))
| Item.CustomOperation (_, _, Some minfo) -> rangeOfMethInfo g preferFlag minfo
| Item.Trait _ -> None
| Item.TypeVar (_, tp) -> Some tp.Range
| Item.ModuleOrNamespaces modrefs -> modrefs |> List.tryPick (rangeOfEntityRef preferFlag >> Some)
- | Item.MethodGroup(_, minfos, _)
+ | Item.MethodGroup(_, minfos, _)
| Item.CtorGroup(_, minfos) -> minfos |> List.tryPick (rangeOfMethInfo g preferFlag)
| Item.ActivePatternResult(APInfo _, _, _, m) -> Some m
| Item.SetterArg (_, item) -> rangeOfItem g preferFlag item
@@ -122,27 +122,27 @@ module internal SymbolHelpers =
| Item.NewDef _ -> None
// Provided type definitions do not have a useful F# CCU for the purposes of goto-definition.
- let computeCcuOfTyconRef (tcref: TyconRef) =
+ let computeCcuOfTyconRef (tcref: TyconRef) =
#if !NO_TYPEPROVIDERS
- if tcref.IsProvided then None else
+ if tcref.IsProvided then None else
#endif
ccuOfTyconRef tcref
- let ccuOfMethInfo (g: TcGlobals) (minfo: MethInfo) =
+ let ccuOfMethInfo (g: TcGlobals) (minfo: MethInfo) =
match minfo with
| DefaultStructCtor(_, AppTy g (tcref, _)) ->
computeCcuOfTyconRef tcref
- | _ ->
- minfo.ArbitraryValRef
- |> Option.bind ccuOfValRef
+ | _ ->
+ minfo.ArbitraryValRef
+ |> Option.bind ccuOfValRef
|> Option.orElseWith (fun () -> minfo.DeclaringTyconRef |> computeCcuOfTyconRef)
- let rec ccuOfItem (g: TcGlobals) d =
+ let rec ccuOfItem (g: TcGlobals) d =
match d with
| Item.Value vref
| Item.CustomBuilder (_, vref) ->
- ccuOfValRef vref
+ ccuOfValRef vref
| Item.UnionCase(ucinfo, _) ->
computeCcuOfTyconRef ucinfo.TyconRef
@@ -165,9 +165,9 @@ module internal SymbolHelpers =
| Item.ILField finfo ->
finfo.DeclaringTyconRef |> computeCcuOfTyconRef
- | Item.Property(info = pinfos) ->
- pinfos |> List.tryPick (fun pinfo ->
- pinfo.ArbitraryValRef
+ | Item.Property(info = pinfos) ->
+ pinfos |> List.tryPick (fun pinfo ->
+ pinfo.ArbitraryValRef
|> Option.bind ccuOfValRef
|> Option.orElseWith (fun () -> pinfo.DeclaringTyconRef |> computeCcuOfTyconRef))
@@ -192,9 +192,9 @@ module internal SymbolHelpers =
| Item.DelegateCtor(ty) ->
ty |> tryNiceEntityRefOfTyOption |> Option.bind computeCcuOfTyconRef
- | Item.ModuleOrNamespaces erefs
+ | Item.ModuleOrNamespaces erefs
| Item.UnqualifiedType erefs ->
- erefs |> List.tryPick computeCcuOfTyconRef
+ erefs |> List.tryPick computeCcuOfTyconRef
| Item.SetterArg (_, item) ->
ccuOfItem g item
@@ -219,22 +219,22 @@ module internal SymbolHelpers =
/// Work out the source file for an item and fix it up relative to the CCU if it is relative.
let fileNameOfItem (g: TcGlobals) qualProjectDir (m: range) h =
- let file = m.FileName
+ let file = m.FileName
if verbose then dprintf "file stored in metadata is '%s'\n" file
- if not (FileSystem.IsPathRootedShim file) then
- match ccuOfItem g h with
- | Some ccu ->
+ if not (FileSystem.IsPathRootedShim file) then
+ match ccuOfItem g h with
+ | Some ccu ->
Path.Combine(ccu.SourceCodeDirectory, file)
- | None ->
- match qualProjectDir with
+ | None ->
+ match qualProjectDir with
| None -> file
| Some dir -> Path.Combine(dir, file)
else file
- let ParamNameAndTypesOfUnaryCustomOperation g minfo =
- match minfo with
- | FSMeth(_, _, vref, _) ->
- let argInfos = ArgInfosOfMember g vref |> List.concat
+ let ParamNameAndTypesOfUnaryCustomOperation g minfo =
+ match minfo with
+ | FSMeth(_, _, vref, _) ->
+ let argInfos = ArgInfosOfMember g vref |> List.concat
// Drop the first 'seq' argument representing the computation space
let argInfos = if argInfos.IsEmpty then [] else argInfos.Tail
[ for ty, argInfo in argInfos do
@@ -258,12 +258,12 @@ module internal SymbolHelpers =
|> Option.map FSharpXmlDoc.FromXmlText
|> Option.defaultValue xmlDoc
- /// This function gets the signature to pass to Visual Studio to use its lookup functions for .NET stuff.
+ /// This function gets the signature to pass to Visual Studio to use its lookup functions for .NET stuff.
let rec GetXmlDocHelpSigOfItemForLookup (infoReader: InfoReader) m d =
let g = infoReader.g
match d with
- | Item.ActivePatternCase (APElemRef(_, vref, _, _))
- | Item.Value vref | Item.CustomBuilder (_, vref) ->
+ | Item.ActivePatternCase (APElemRef(_, vref, _, _))
+ | Item.Value vref | Item.CustomBuilder (_, vref) ->
mkXmlComment (GetXmlDocSigOfValRef g vref)
| Item.UnionCase (ucinfo, _) ->
@@ -311,7 +311,7 @@ module internal SymbolHelpers =
mkXmlComment (GetXmlDocSigOfMethInfo infoReader m minfo)
| Item.OtherName(container = Some argContainer) ->
- match argContainer with
+ match argContainer with
| ArgumentContainer.Method minfo -> mkXmlComment (GetXmlDocSigOfMethInfo infoReader m minfo)
| ArgumentContainer.Type tcref -> mkXmlComment (GetXmlDocSigOfEntityRef infoReader m tcref)
@@ -321,7 +321,7 @@ module internal SymbolHelpers =
| Item.SetterArg (_, item) ->
GetXmlDocHelpSigOfItemForLookup infoReader m item
- // These do not have entires in XML doc files
+ // These do not have entries in XML doc files
| Item.CustomOperation _
| Item.OtherName _
| Item.ActivePatternResult _
@@ -340,38 +340,38 @@ module internal SymbolHelpers =
|> GetXmlDocFromLoader infoReader
/// Produce an XmlComment with a signature or raw text, given the F# comment and the item
- let GetXmlCommentForItemAux (xmlDoc: XmlDoc option) (infoReader: InfoReader) m d =
- match xmlDoc with
- | Some xmlDoc when not xmlDoc.IsEmpty ->
+ let GetXmlCommentForItemAux (xmlDoc: XmlDoc option) (infoReader: InfoReader) m d =
+ match xmlDoc with
+ | Some xmlDoc when not xmlDoc.IsEmpty ->
FSharpXmlDoc.FromXmlText xmlDoc
| _ -> GetXmlDocHelpSigOfItemForLookup infoReader m d
- let GetXmlCommentForMethInfoItem infoReader m d (minfo: MethInfo) =
+ let GetXmlCommentForMethInfoItem infoReader m d (minfo: MethInfo) =
if minfo.HasDirectXmlComment || minfo.XmlDoc.NonEmpty then
- GetXmlCommentForItemAux (Some minfo.XmlDoc) infoReader m d
+ GetXmlCommentForItemAux (Some minfo.XmlDoc) infoReader m d
else
mkXmlComment (GetXmlDocSigOfMethInfo infoReader m minfo)
- let FormatTyparMapping denv (prettyTyparInst: TyparInstantiation) =
- [ for tp, ty in prettyTyparInst ->
+ let FormatTyparMapping denv (prettyTyparInst: TyparInstantiation) =
+ [ for tp, ty in prettyTyparInst ->
wordL (tagTypeParameter ("'" + tp.DisplayName)) ^^ wordL (tagText (FSComp.SR.descriptionWordIs())) ^^ NicePrint.layoutType denv ty ]
[]
- let (|ItemWhereTypIsPreferred|_|) item =
- match item with
+ let (|ItemWhereTypIsPreferred|_|) item =
+ match item with
| Item.DelegateCtor ty
| Item.CtorGroup(_, [DefaultStructCtor(_, ty)])
| Item.Types(_, [ty]) -> ValueSome ty
| _ -> ValueNone
- /// Specifies functions for comparing 'Item' objects with respect to the user
- /// (this means that some values that are not technically equal are treated as equal
+ /// Specifies functions for comparing 'Item' objects with respect to the user
+ /// (this means that some values that are not technically equal are treated as equal
/// if this is what we want to show to the user, because we're comparing just the name
// for some cases e.g. when using 'fullDisplayTextOfModRef')
- let ItemDisplayPartialEquality g =
- { new IPartialEqualityComparer<_> with
- member x.InEqualityRelation item =
- match item with
+ let ItemDisplayPartialEquality g =
+ { new IPartialEqualityComparer<_> with
+ member x.InEqualityRelation item =
+ match item with
| Item.Trait _ -> true
| Item.Types(_, _ :: _) -> true
| Item.ILField(_) -> true
@@ -385,7 +385,7 @@ module internal SymbolHelpers =
| Item.ActivePatternCase _ -> true
| Item.DelegateCtor _ -> true
| Item.UnionCase _ -> true
- | Item.ExnCase _ -> true
+ | Item.ExnCase _ -> true
| Item.Event _ -> true
| Item.Property _ -> true
| Item.CtorGroup _ -> true
@@ -404,17 +404,15 @@ module internal SymbolHelpers =
| Item.ModuleOrNamespaces [] -> false
//| _ -> false
-
- member x.Equals(item1, item2) =
-#if !NO_CHECKNULLS
+
+ member x.Equals(item1, item2) =
match item1,item2 with
| null,null -> true
| null,_ | _,null -> false
| item1,item2 ->
-#endif
// This may explore assemblies that are not in the reference set.
// In this case just bail out and assume items are not equal
- protectAssemblyExploration false (fun () ->
+ protectAssemblyExploration false (fun () ->
let equalHeadTypes(ty1, ty2) =
match tryTcrefOfAppTy g ty1 with
| ValueSome tcref1 ->
@@ -423,41 +421,41 @@ module internal SymbolHelpers =
| _ -> typeEquiv g ty1 ty2
| _ -> typeEquiv g ty1 ty2
- ItemsAreEffectivelyEqual g item1 item2 ||
+ ItemsAreEffectivelyEqual g item1 item2 ||
// Much of this logic is already covered by 'ItemsAreEffectivelyEqual'
- match item1, item2 with
+ match item1, item2 with
| Item.DelegateCtor ty1, Item.DelegateCtor ty2 -> equalHeadTypes(ty1, ty2)
| Item.Types(dn1, ty1 :: _), Item.Types(dn2, ty2 :: _) ->
// Bug 4403: We need to compare names as well, because 'int' and 'Int32' are physically the same type, but we want to show both
- dn1 = dn2 && equalHeadTypes(ty1, ty2)
-
- // Prefer a type to a DefaultStructCtor, a DelegateCtor and a FakeInterfaceCtor
- | ItemWhereTypIsPreferred ty1, ItemWhereTypIsPreferred ty2 -> equalHeadTypes(ty1, ty2)
+ dn1 = dn2 && equalHeadTypes(ty1, ty2)
+
+ // Prefer a type to a DefaultStructCtor, a DelegateCtor and a FakeInterfaceCtor
+ | ItemWhereTypIsPreferred ty1, ItemWhereTypIsPreferred ty2 -> equalHeadTypes(ty1, ty2)
| Item.ExnCase tcref1, Item.ExnCase tcref2 -> tyconRefEq g tcref1 tcref2
| Item.ILField(fld1), Item.ILField(fld2) ->
ILFieldInfo.ILFieldInfosUseIdenticalDefinitions fld1 fld2
- | Item.CustomOperation (_, _, Some minfo1), Item.CustomOperation (_, _, Some minfo2) ->
+ | Item.CustomOperation (_, _, Some minfo1), Item.CustomOperation (_, _, Some minfo2) ->
MethInfo.MethInfosUseIdenticalDefinitions minfo1 minfo2
- | Item.TypeVar (nm1, tp1), Item.TypeVar (nm2, tp2) ->
+ | Item.TypeVar (nm1, tp1), Item.TypeVar (nm2, tp2) ->
(nm1 = nm2) && typarRefEq tp1 tp2
| Item.ModuleOrNamespaces(modref1 :: _), Item.ModuleOrNamespaces(modref2 :: _) -> fullDisplayTextOfModRef modref1 = fullDisplayTextOfModRef modref2
| Item.SetterArg(id1, _), Item.SetterArg(id2, _) -> Range.equals id1.idRange id2.idRange && id1.idText = id2.idText
- | Item.MethodGroup(_, meths1, _), Item.MethodGroup(_, meths2, _) ->
+ | Item.MethodGroup(_, meths1, _), Item.MethodGroup(_, meths2, _) ->
Seq.zip meths1 meths2 |> Seq.forall (fun (minfo1, minfo2) ->
MethInfo.MethInfosUseIdenticalDefinitions minfo1 minfo2)
- | (Item.Value vref1 | Item.CustomBuilder (_, vref1)), (Item.Value vref2 | Item.CustomBuilder (_, vref2)) ->
+ | (Item.Value vref1 | Item.CustomBuilder (_, vref1)), (Item.Value vref2 | Item.CustomBuilder (_, vref2)) ->
valRefEq g vref1 vref2
| Item.ActivePatternCase(APElemRef(_apinfo1, vref1, idx1, _)), Item.ActivePatternCase(APElemRef(_apinfo2, vref2, idx2, _)) ->
idx1 = idx2 && valRefEq g vref1 vref2
- | Item.UnionCase(UnionCaseInfo(_, ur1), _), Item.UnionCase(UnionCaseInfo(_, ur2), _) ->
+ | Item.UnionCase(UnionCaseInfo(_, ur1), _), Item.UnionCase(UnionCaseInfo(_, ur2), _) ->
g.unionCaseRefEq ur1 ur2
- | Item.RecdField(RecdFieldInfo(_, RecdFieldRef(tcref1, n1))), Item.RecdField(RecdFieldInfo(_, RecdFieldRef(tcref2, n2))) ->
+ | Item.RecdField(RecdFieldInfo(_, RecdFieldRef(tcref1, n1))), Item.RecdField(RecdFieldInfo(_, RecdFieldRef(tcref2, n2))) ->
(tyconRefEq g tcref1 tcref2) && (n1 = n2) // there is no direct function as in the previous case
- | Item.Property(info = pi1s), Item.Property(info = pi2s) ->
+ | Item.Property(info = pi1s), Item.Property(info = pi2s) ->
(pi1s, pi2s) ||> List.forall2 PropInfo.PropInfosUseIdenticalDefinitions
- | Item.Event evt1, Item.Event evt2 ->
+ | Item.Event evt1, Item.Event evt2 ->
EventInfo.EventInfosUseIdenticalDefinitions evt1 evt2
| Item.AnonRecdField(anon1, _, i1, _), Item.AnonRecdField(anon2, _, i2, _) ->
anonInfoEquiv anon1 anon2 && i1 = i2
@@ -472,13 +470,13 @@ module internal SymbolHelpers =
| Item.Types(_, [AbbrevOrAppTy(tcref1, _)]), Item.UnqualifiedType([tcref2]) -> tyconRefEq g tcref1 tcref2
| Item.UnqualifiedType([tcref1]), Item.Types(_, [AbbrevOrAppTy(tcref2, _)]) -> tyconRefEq g tcref1 tcref2
| _ -> false)
-
+
member x.GetHashCode item =
// This may explore assemblies that are not in the reference set.
// In this case just bail out and use a random hash code
- protectAssemblyExploration 1027 (fun () ->
- match item with
- | ItemWhereTypIsPreferred ty ->
+ protectAssemblyExploration 1027 (fun () ->
+ match item with
+ | ItemWhereTypIsPreferred ty ->
match tryTcrefOfAppTy g ty with
| ValueSome tcref -> hash tcref.LogicalName
| _ -> 1010
@@ -487,7 +485,7 @@ module internal SymbolHelpers =
| Item.TypeVar (nm, _tp) -> hash nm
| Item.CustomOperation (_, _, Some minfo) -> minfo.ComputeHashCode()
| Item.CustomOperation (_, _, None) -> 1
- | Item.ModuleOrNamespaces(modref :: _) -> hash (fullDisplayTextOfModRef modref)
+ | Item.ModuleOrNamespaces(modref :: _) -> hash (fullDisplayTextOfModRef modref)
| Item.SetterArg(id, _) -> hash (id.idRange, id.idText)
| Item.MethodGroup(_, meths, _) -> meths |> List.fold (fun st a -> st + a.ComputeHashCode()) 0
| Item.CtorGroup(name, meths) -> name.GetHashCode() + (meths |> List.fold (fun st a -> st + a.ComputeHashCode()) 0)
@@ -514,30 +512,30 @@ module internal SymbolHelpers =
| Item.DelegateCtor _
| Item.ModuleOrNamespaces [] -> 0
) }
-
+
/// Remove all duplicate items
- let RemoveDuplicateItems g (items: ItemWithInst list) =
+ let RemoveDuplicateItems g (items: ItemWithInst list) =
if isNil items then items else
items |> IPartialEqualityComparer.partialDistinctBy (IPartialEqualityComparer.On (fun item -> item.Item) (ItemDisplayPartialEquality g))
- let IsExplicitlySuppressed (g: TcGlobals) (item: Item) =
+ let IsExplicitlySuppressed (g: TcGlobals) (item: Item) =
// This may explore assemblies that are not in the reference set.
// In this case just assume the item is not suppressed.
- protectAssemblyExploration true (fun () ->
- match item with
- | Item.Types(it, [ty]) ->
+ protectAssemblyExploration true (fun () ->
+ match item with
+ | Item.Types(it, [ty]) ->
match tryTcrefOfAppTy g ty with
| ValueSome tcr1 ->
- g.suppressed_types
+ g.suppressed_types
|> List.exists (fun supp ->
let generalizedSupp = generalizedTyconRef g supp
// check the display name is precisely the one we're suppressing
match tryTcrefOfAppTy g generalizedSupp with
| ValueSome tcr2 ->
it = supp.DisplayName &&
- // check if they are the same logical type (after removing all abbreviations)
+ // check if they are the same logical type (after removing all abbreviations)
tyconRefEq g tcr1 tcr2
- | _ -> false)
+ | _ -> false)
| _ -> false
| _ -> false)
@@ -545,7 +543,7 @@ module internal SymbolHelpers =
let RemoveExplicitlySuppressed (g: TcGlobals) (items: ItemWithInst list) =
items |> List.filter (fun item -> not (IsExplicitlySuppressed g item.Item))
- let SimplerDisplayEnv denv =
+ let SimplerDisplayEnv denv =
{ denv with shortConstraints=true
showStaticallyResolvedTyparAnnotations=false
showNullnessAnnotations = Some true
@@ -553,7 +551,7 @@ module internal SymbolHelpers =
suppressNestedTypes=true
maxMembers=Some EnvMisc2.maxMembers }
- let rec FullNameOfItem g item =
+ let rec FullNameOfItem g item =
let denv = DisplayEnv.Empty g
match item with
| Item.ImplicitOp(_, { contents = Some(TraitConstraintSln.FSMethSln(vref=vref)) })
@@ -561,7 +559,7 @@ module internal SymbolHelpers =
| Item.UnionCase (ucinfo, _) -> fullDisplayTextOfUnionCaseRef ucinfo.UnionCaseRef
| Item.ActivePatternResult(apinfo, _ty, idx, _) -> apinfo.DisplayNameByIdx idx
| Item.ActivePatternCase apref -> FullNameOfItem g (Item.Value apref.ActivePatternVal) + "." + apref.DisplayName
- | Item.ExnCase ecref -> fullDisplayTextOfExnRef ecref
+ | Item.ExnCase ecref -> fullDisplayTextOfExnRef ecref
| Item.AnonRecdField(anon, _argTys, i, _) -> anon.DisplayNameByIdx i
| Item.RecdField rfinfo -> fullDisplayTextOfRecdFieldRef rfinfo.RecdFieldRef
| Item.NewDef id -> id.idText
@@ -570,11 +568,11 @@ module internal SymbolHelpers =
| Item.Property(info = pinfo :: _) -> buildString (fun os -> NicePrint.outputTyconRef denv os pinfo.DeclaringTyconRef; bprintf os ".%s" pinfo.PropertyName)
| Item.CustomOperation (customOpName, _, _) -> customOpName
| Item.CtorGroup(_, minfo :: _) -> buildString (fun os -> NicePrint.outputTyconRef denv os minfo.DeclaringTyconRef)
- | Item.MethodGroup(_, _, Some minfo) -> buildString (fun os -> NicePrint.outputTyconRef denv os minfo.DeclaringTyconRef; bprintf os ".%s" minfo.DisplayName)
- | Item.MethodGroup(_, minfo :: _, _) -> buildString (fun os -> NicePrint.outputTyconRef denv os minfo.DeclaringTyconRef; bprintf os ".%s" minfo.DisplayName)
+ | Item.MethodGroup(_, _, Some minfo) -> buildString (fun os -> NicePrint.outputTyconRef denv os minfo.DeclaringTyconRef; bprintf os ".%s" minfo.DisplayName)
+ | Item.MethodGroup(_, minfo :: _, _) -> buildString (fun os -> NicePrint.outputTyconRef denv os minfo.DeclaringTyconRef; bprintf os ".%s" minfo.DisplayName)
| Item.UnqualifiedType (tcref :: _) -> buildString (fun os -> NicePrint.outputTyconRef denv os tcref)
- | Item.DelegateCtor ty
- | Item.Types(_, ty :: _) ->
+ | Item.DelegateCtor ty
+ | Item.Types(_, ty :: _) ->
match tryTcrefOfAppTy g ty with
| ValueSome tcref -> buildString (fun os -> NicePrint.outputTyconRef denv os tcref)
| _ -> ""
@@ -587,16 +585,16 @@ module internal SymbolHelpers =
| Item.SetterArg (_, item) -> FullNameOfItem g item
| Item.ImplicitOp(id, _) -> id.idText
| Item.UnionCaseField (UnionCaseInfo (_, ucref), fieldIndex) -> ucref.FieldByIndex(fieldIndex).DisplayName
- // unreachable
- | Item.UnqualifiedType([])
- | Item.Types(_, [])
- | Item.CtorGroup(_, [])
- | Item.MethodGroup(_, [], _)
+ // unreachable
+ | Item.UnqualifiedType([])
+ | Item.Types(_, [])
+ | Item.CtorGroup(_, [])
+ | Item.MethodGroup(_, [], _)
| Item.ModuleOrNamespaces []
| Item.Property(info = []) -> ""
/// Output the description of a language item
- let rec GetXmlCommentForItem (infoReader: InfoReader) m item =
+ let rec GetXmlCommentForItem (infoReader: InfoReader) m item =
let g = infoReader.g
match item with
| Item.ImplicitOp(_, sln) ->
@@ -611,19 +609,19 @@ module internal SymbolHelpers =
| None ->
GetXmlCommentForItemAux None infoReader m item
- | Item.Value vref | Item.CustomBuilder (_, vref) ->
+ | Item.Value vref | Item.CustomBuilder (_, vref) ->
let doc = if valRefInThisAssembly g.compilingFSharpCore vref || vref.XmlDoc.NonEmpty then Some vref.XmlDoc else None
GetXmlCommentForItemAux doc infoReader m item
- | Item.UnionCase(ucinfo, _) ->
+ | Item.UnionCase(ucinfo, _) ->
let doc = if tyconRefUsesLocalXmlDoc g.compilingFSharpCore ucinfo.TyconRef || ucinfo.UnionCase.XmlDoc.NonEmpty then Some ucinfo.UnionCase.XmlDoc else None
GetXmlCommentForItemAux doc infoReader m item
- | Item.ActivePatternCase apref ->
+ | Item.ActivePatternCase apref ->
let doc = Some apref.ActivePatternVal.XmlDoc
GetXmlCommentForItemAux doc infoReader m item
- | Item.ExnCase ecref ->
+ | Item.ExnCase ecref ->
let doc = if tyconRefUsesLocalXmlDoc g.compilingFSharpCore ecref || ecref.XmlDoc.NonEmpty then Some ecref.XmlDoc else None
GetXmlCommentForItemAux doc infoReader m item
@@ -643,13 +641,13 @@ module internal SymbolHelpers =
let doc = if einfo.HasDirectXmlComment || einfo.XmlDoc.NonEmpty then Some einfo.XmlDoc else None
GetXmlCommentForItemAux doc infoReader m item
- | Item.Property(info = pinfos) ->
+ | Item.Property(info = pinfos) ->
let pinfo = pinfos.Head
let doc = if pinfo.HasDirectXmlComment || pinfo.XmlDoc.NonEmpty then Some pinfo.XmlDoc else None
GetXmlCommentForItemAux doc infoReader m item
- | Item.CustomOperation (_, _, Some minfo)
- | Item.CtorGroup(_, minfo :: _)
+ | Item.CustomOperation (_, _, Some minfo)
+ | Item.CtorGroup(_, minfo :: _)
| Item.MethodGroup(_, minfo :: _, _) ->
GetXmlCommentForMethInfoItem infoReader m item minfo
@@ -675,7 +673,7 @@ module internal SymbolHelpers =
| _ -> None
GetXmlCommentForItemAux doc infoReader m item
- | Item.ModuleOrNamespaces(modref :: _ as modrefs) ->
+ | Item.ModuleOrNamespaces(modref :: _ as modrefs) ->
let definiteNamespace = modrefs |> List.forall (fun modref -> modref.IsNamespace)
if not definiteNamespace then
let doc = if entityRefInThisAssembly g.compilingFSharpCore modref || modref.XmlDoc.NonEmpty then Some modref.XmlDoc else None
@@ -687,7 +685,7 @@ module internal SymbolHelpers =
let doc =
match argContainer with
| Some(ArgumentContainer.Method minfo) ->
- if minfo.HasDirectXmlComment || minfo.XmlDoc.NonEmpty then Some minfo.XmlDoc else None
+ if minfo.HasDirectXmlComment || minfo.XmlDoc.NonEmpty then Some minfo.XmlDoc else None
| Some(ArgumentContainer.Type tcref) ->
if tyconRefUsesLocalXmlDoc g.compilingFSharpCore tcref || tcref.XmlDoc.NonEmpty then Some tcref.XmlDoc else None
| _ -> None
@@ -701,9 +699,9 @@ module internal SymbolHelpers =
None
GetXmlCommentForItemAux doc infoReader m item
- | Item.SetterArg (_, item) ->
+ | Item.SetterArg (_, item) ->
GetXmlCommentForItem infoReader m item
-
+
// In all these cases, there is no direct XML documentation from F# comments
| Item.MethodGroup (_, [], _)
| Item.CtorGroup (_, [])
@@ -737,7 +735,7 @@ module internal SymbolHelpers =
#if !NO_TYPEPROVIDERS
- /// Determine if an item is a provided type
+ /// Determine if an item is a provided type
[]
let (|ItemIsProvidedType|_|) g item =
match item with
@@ -759,11 +757,11 @@ module internal SymbolHelpers =
match tys with
| [AppTy g (tcref, _typeInst)] ->
if tcref.IsProvidedErasedTycon || tcref.IsProvidedGeneratedTycon then
- let typeBeforeArguments =
- match tcref.TypeReprInfo with
+ let typeBeforeArguments =
+ match tcref.TypeReprInfo with
| TProvidedTypeRepr info -> info.ProvidedType
| _ -> failwith "unreachable"
- let staticParameters = typeBeforeArguments.PApplyWithProvider((fun (typeBeforeArguments, provider) -> typeBeforeArguments.GetStaticParameters provider), range=m)
+ let staticParameters = typeBeforeArguments.PApplyWithProvider((fun (typeBeforeArguments, provider) -> typeBeforeArguments.GetStaticParameters provider), range=m)
let staticParameters = staticParameters.PApplyArray(id, "GetStaticParameters", m)
ValueSome staticParameters
else
@@ -776,11 +774,11 @@ module internal SymbolHelpers =
match item with
// Prefer the static parameters from the uninstantiated method info
| Item.MethodGroup(_, _, Some minfo) ->
- match minfo.ProvidedStaticParameterInfo with
+ match minfo.ProvidedStaticParameterInfo with
| Some (_, staticParameters) -> ValueSome staticParameters
| _ -> ValueNone
| Item.MethodGroup(_, [minfo], _) ->
- match minfo.ProvidedStaticParameterInfo with
+ match minfo.ProvidedStaticParameterInfo with
| Some (_, staticParameters) -> ValueSome staticParameters
| _ -> ValueNone
| _ -> ValueNone
@@ -796,20 +794,20 @@ module internal SymbolHelpers =
#endif
/// Get the "F1 Keyword" associated with an item, for looking up documentation help indexes on the web
- let rec GetF1Keyword (g: TcGlobals) item =
+ let rec GetF1Keyword (g: TcGlobals) item =
let rec getKeywordForMethInfo (minfo : MethInfo) =
- match minfo with
+ match minfo with
| FSMeth(_, _, vref, _) ->
match vref.TryDeclaringEntity with
| Parent tcref ->
(tcref |> ticksAndArgCountTextOfTyconRef) + "." + vref.CompiledName g.CompilerGlobalState |> Some
| ParentNone -> None
-
+
| ILMeth (_, minfo, _) ->
let typeString = minfo.DeclaringTyconRef |> ticksAndArgCountTextOfTyconRef
let paramString =
- let nGenericParams = minfo.RawMetadata.GenericParams.Length
+ let nGenericParams = minfo.RawMetadata.GenericParams.Length
if nGenericParams > 0 then "``"+(nGenericParams.ToString()) else ""
sprintf "%s.%s%s" typeString minfo.RawMetadata.Name paramString |> Some
@@ -818,17 +816,17 @@ module internal SymbolHelpers =
#if !NO_TYPEPROVIDERS
| ProvidedMeth _ -> None
#endif
-
+
match item with
- | Item.Value vref | Item.CustomBuilder (_, vref) ->
+ | Item.Value vref | Item.CustomBuilder (_, vref) ->
let v = vref.Deref
if v.IsModuleBinding && v.HasDeclaringEntity then
let tyconRef = v.DeclaringEntity
let paramsString =
match v.Typars with
| [] -> ""
- | l -> "``"+(List.length l).ToString()
-
+ | l -> "``"+(List.length l).ToString()
+
sprintf "%s.%s%s" (tyconRef |> ticksAndArgCountTextOfTyconRef) (v.CompiledName g.CompilerGlobalState) paramsString |> Some
else
None
@@ -841,39 +839,39 @@ module internal SymbolHelpers =
| Item.RecdField rfi ->
(rfi.TyconRef |> ticksAndArgCountTextOfTyconRef) + "." + rfi.DisplayName |> Some
-
+
| Item.AnonRecdField _ -> None
-
+
| Item.ILField finfo ->
- match finfo with
- | ILFieldInfo(tinfo, fdef) ->
+ match finfo with
+ | ILFieldInfo(tinfo, fdef) ->
(tinfo.TyconRefOfRawMetadata |> ticksAndArgCountTextOfTyconRef) + "." + fdef.Name |> Some
#if !NO_TYPEPROVIDERS
| ProvidedField _ -> None
#endif
- | Item.Types(_, AppTy g (tcref, _) :: _)
+ | Item.Types(_, AppTy g (tcref, _) :: _)
| Item.DelegateCtor(AppTy g (tcref, _))
| Item.UnqualifiedType (tcref :: _)
- | Item.ExnCase tcref ->
+ | Item.ExnCase tcref ->
// strip off any abbreviation
- match generalizedTyconRef g tcref with
+ match generalizedTyconRef g tcref with
| AppTy g (tcref, _) -> Some (ticksAndArgCountTextOfTyconRef tcref)
| _ -> None
// Pathological cases of the above
- | Item.Types _
+ | Item.Types _
| Item.DelegateCtor _
- | Item.UnqualifiedType [] ->
+ | Item.UnqualifiedType [] ->
None
- | Item.ModuleOrNamespaces modrefs ->
- match modrefs with
- | modref :: _ ->
+ | Item.ModuleOrNamespaces modrefs ->
+ match modrefs with
+ | modref :: _ ->
// namespaces from type providers need to be handled separately because they don't have compiled representation
// otherwise we'll fail at tast.fs
match modref.Deref.TypeReprInfo with
-#if !NO_TYPEPROVIDERS
- | TProvidedNamespaceRepr _ ->
+#if !NO_TYPEPROVIDERS
+ | TProvidedNamespaceRepr _ ->
modref.CompilationPathOpt
|> Option.bind (fun path ->
// works similar to generation of xml-docs at tastops.fs, probably too similar
@@ -886,17 +884,17 @@ module internal SymbolHelpers =
| _ -> modref.Deref.CompiledRepresentationForNamedType.FullName |> Some
| [] -> None // Pathological case of the above
- | Item.Property(info = pinfo :: _) ->
- match pinfo with
- | FSProp(_, _, Some vref, _)
- | FSProp(_, _, _, Some vref) ->
+ | Item.Property(info = pinfo :: _) ->
+ match pinfo with
+ | FSProp(_, _, Some vref, _)
+ | FSProp(_, _, _, Some vref) ->
// per spec, extension members in F1 keywords are qualified with definition class
- match vref.TryDeclaringEntity with
+ match vref.TryDeclaringEntity with
| Parent tcref ->
- (tcref |> ticksAndArgCountTextOfTyconRef)+"."+vref.PropertyName|> Some
+ (tcref |> ticksAndArgCountTextOfTyconRef)+"."+vref.PropertyName|> Some
| ParentNone -> None
- | ILProp(ILPropInfo(tinfo, pdef)) ->
+ | ILProp(ILPropInfo(tinfo, pdef)) ->
let tcref = tinfo.TyconRefOfRawMetadata
(tcref |> ticksAndArgCountTextOfTyconRef)+"."+pdef.Name |> Some
| FSProp _ -> None
@@ -904,25 +902,25 @@ module internal SymbolHelpers =
| ProvidedProp _ -> None
#endif
| Item.Property(info = []) -> None // Pathological case of the above
-
- | Item.Event einfo ->
- match einfo with
+
+ | Item.Event einfo ->
+ match einfo with
| ILEvent _ ->
let tcref = einfo.DeclaringTyconRef
(tcref |> ticksAndArgCountTextOfTyconRef)+"."+einfo.EventName |> Some
| FSEvent(_, pinfo, _, _) ->
- match pinfo.ArbitraryValRef with
+ match pinfo.ArbitraryValRef with
| Some vref ->
// per spec, members in F1 keywords are qualified with definition class
- match vref.TryDeclaringEntity with
- | Parent tcref -> (tcref |> ticksAndArgCountTextOfTyconRef)+"."+vref.PropertyName|> Some
+ match vref.TryDeclaringEntity with
+ | Parent tcref -> (tcref |> ticksAndArgCountTextOfTyconRef)+"."+vref.PropertyName|> Some
| ParentNone -> None
| None -> None
#if !NO_TYPEPROVIDERS
- | ProvidedEvent _ -> None
+ | ProvidedEvent _ -> None
#endif
| Item.CtorGroup(_, minfos) ->
- match minfos with
+ match minfos with
| [] -> None
| FSMeth(_, _, vref, _) :: _ ->
match vref.TryDeclaringEntity with
@@ -937,14 +935,14 @@ module internal SymbolHelpers =
| Item.CustomOperation (_, _, Some minfo) -> getKeywordForMethInfo minfo
| Item.MethodGroup(_, _, Some minfo) -> getKeywordForMethInfo minfo
| Item.MethodGroup(_, minfo :: _, _) -> getKeywordForMethInfo minfo
- | Item.SetterArg (_, propOrField) -> GetF1Keyword g propOrField
- | Item.MethodGroup(_, [], _)
+ | Item.SetterArg (_, propOrField) -> GetF1Keyword g propOrField
+ | Item.MethodGroup(_, [], _)
| Item.CustomOperation (_, _, None) // "into"
| Item.NewDef _ // "let x$yz = ..." - no keyword
- | Item.OtherName _ // no keyword on named parameters
+ | Item.OtherName _ // no keyword on named parameters
| Item.Trait _
| Item.UnionCaseField _
- | Item.TypeVar _
+ | Item.TypeVar _
| Item.ImplicitOp _
| Item.ActivePatternResult _ // "let (|Foo|Bar|) = .. Fo$o ..." - no keyword
-> None
@@ -956,21 +954,21 @@ module internal SymbolHelpers =
// the VS integration.
let SelectMethodGroupItems2 g (m: range) (item: ItemWithInst) : ItemWithInst list =
ignore m
- match item.Item with
+ match item.Item with
| Item.MethodGroup(nm, minfos, orig) ->
minfos |> List.map (fun minfo -> { Item = Item.MethodGroup(nm, [minfo], orig); TyparInstantiation = item.TyparInstantiation })
| Item.CtorGroup(nm, cinfos) ->
- cinfos |> List.map (fun minfo -> { Item = Item.CtorGroup(nm, [minfo]); TyparInstantiation = item.TyparInstantiation })
+ cinfos |> List.map (fun minfo -> { Item = Item.CtorGroup(nm, [minfo]); TyparInstantiation = item.TyparInstantiation })
| Item.DelegateCtor _ -> [item]
- | Item.NewDef _
+ | Item.NewDef _
| Item.ILField _ -> []
| Item.Event _ -> []
| Item.RecdField rfinfo -> if isForallFunctionTy g rfinfo.FieldType then [item] else []
| Item.Value v -> if isForallFunctionTy g v.Type then [item] else []
| Item.UnionCase(ucr, _) -> if not ucr.UnionCase.IsNullary then [item] else []
| Item.ExnCase ecr -> if isNil (recdFieldsOfExnDefRef ecr) then [] else [item]
- | Item.Property(info = pinfos) ->
- let pinfo = List.head pinfos
+ | Item.Property(info = pinfos) ->
+ let pinfo = List.head pinfos
if pinfo.IsIndexer then [item] else []
#if !NO_TYPEPROVIDERS
| ItemIsWithStaticArguments m g _ -> [item] // we pretend that provided-types-with-static-args are method-like in order to get ParamInfo for them
diff --git a/src/Compiler/SyntaxTree/LexerStore.fs b/src/Compiler/SyntaxTree/LexerStore.fs
index 711e9530cd9..2914d944c20 100644
--- a/src/Compiler/SyntaxTree/LexerStore.fs
+++ b/src/Compiler/SyntaxTree/LexerStore.fs
@@ -32,8 +32,6 @@ let private tryGetStoreData<'T when 'T: not null> (lexbuf: Lexbuf) key =
| true, data -> Some(data :?> 'T)
| _ -> None
-let private setStoreData (lexbuf: Lexbuf) key data = lexbuf.BufferLocalStore[key] <- data
-
//------------------------------------------------------------------------
// A SynArgNameGenerator for the current file, used by the parser
//------------------------------------------------------------------------
diff --git a/src/Compiler/SyntaxTree/SyntaxTreeOps.fs b/src/Compiler/SyntaxTree/SyntaxTreeOps.fs
index ffb9bd65647..6633dab2408 100644
--- a/src/Compiler/SyntaxTree/SyntaxTreeOps.fs
+++ b/src/Compiler/SyntaxTree/SyntaxTreeOps.fs
@@ -1024,9 +1024,9 @@ let parsedHashDirectiveArgumentsNoCheck (input: ParsedHashDirectiveArgument list
(function
| ParsedHashDirectiveArgument.String(s, _, _) -> s
| ParsedHashDirectiveArgument.SourceIdentifier(_, v, _) -> v
- | ParsedHashDirectiveArgument.Int32(n, m) -> string n
- | ParsedHashDirectiveArgument.Ident(ident, m) -> ident.idText
- | ParsedHashDirectiveArgument.LongIdent(ident, m) -> longIdentToString ident)
+ | ParsedHashDirectiveArgument.Int32(n, _) -> string n
+ | ParsedHashDirectiveArgument.Ident(ident, _) -> ident.idText
+ | ParsedHashDirectiveArgument.LongIdent(ident, _) -> longIdentToString ident)
input
let parsedHashDirectiveStringArguments (input: ParsedHashDirectiveArgument list) (_langVersion: LanguageVersion) =
diff --git a/src/Compiler/SyntaxTree/XmlDoc.fs b/src/Compiler/SyntaxTree/XmlDoc.fs
index a366a69a8a6..d4c4cada576 100644
--- a/src/Compiler/SyntaxTree/XmlDoc.fs
+++ b/src/Compiler/SyntaxTree/XmlDoc.fs
@@ -139,7 +139,8 @@ type XmlDocCollector() =
let xmlDocBlock =
struct (savedLines.Count - currentGrabPointCommentsCount, savedLines.Count - 1, false)
- savedGrabPoints.Add(pos, xmlDocBlock)
+ // silently override duplicate grab points (which happen only when preceded by nonsensical line directives)
+ savedGrabPoints[pos] <- xmlDocBlock
currentGrabPointCommentsCount <- 0
delayedGrabPoint <- ValueNone
diff --git a/src/Compiler/TypedTree/QuotationPickler.fs b/src/Compiler/TypedTree/QuotationPickler.fs
index f2a58203ec6..de18b73e5c0 100644
--- a/src/Compiler/TypedTree/QuotationPickler.fs
+++ b/src/Compiler/TypedTree/QuotationPickler.fs
@@ -249,11 +249,7 @@ let PickleBufferCapacity = 100000
module SimplePickle =
- type Table<'T
-#if !NO_CHECKNULLS
- when 'T:not null
-#endif
- > =
+ type Table<'T when 'T:not null> =
{ tbl: HashMultiMap<'T, int> // This should be "Dictionary"
mutable rows: 'T list
mutable count: int }
diff --git a/src/Compiler/TypedTree/TypeProviders.fs b/src/Compiler/TypedTree/TypeProviders.fs
index 42caa723619..425e31ea453 100644
--- a/src/Compiler/TypedTree/TypeProviders.fs
+++ b/src/Compiler/TypedTree/TypeProviders.fs
@@ -220,13 +220,8 @@ let TryTypeMemberArray (st: Tainted<_>, fullName, memberName, m, f) =
[||]
/// Try to access a member on a provided type, catching and reporting errors and checking the result is non-null,
-#if NO_CHECKNULLS
-let TryTypeMemberNonNull<'T, 'U when 'U : null and 'U : not struct>(st: Tainted<'T>, fullName, memberName, m, recover: 'U, (f: 'T -> 'U)) : Tainted<'U> =
- match TryTypeMember(st, fullName, memberName, m, recover, f) with
-#else
let TryTypeMemberNonNull<'T, 'U when 'U : not null and 'U : not struct>(st: Tainted<'T>, fullName, memberName, m, recover: 'U, (f: 'T -> 'U | null)) : Tainted<'U> =
match TryTypeMember<'T, 'U | null>(st, fullName, memberName, m, withNull recover, f) with
-#endif
| Tainted.Null ->
errorR(Error(FSComp.SR.etUnexpectedNullFromProvidedTypeMember(fullName, memberName), m))
st.PApplyNoFailure(fun _ -> recover)
@@ -339,9 +334,6 @@ type ProvidedTypeContext =
))
[]
-#if NO_CHECKNULLS
-[]
-#endif
type ProvidedType (x: Type, ctxt: ProvidedTypeContext) =
inherit ProvidedMemberInfo(x, ctxt)
@@ -506,9 +498,6 @@ type ProvidedType (x: Type, ctxt: ProvidedTypeContext) =
static member TaintedEquals (pt1: Tainted, pt2: Tainted) =
Tainted.EqTainted (pt1.PApplyNoFailure(fun st -> st.Handle)) (pt2.PApplyNoFailure(fun st -> st.Handle))
-#if NO_CHECKNULLS
-[]
-#endif
type IProvidedCustomAttributeProvider =
abstract GetDefinitionLocationAttribute : provider: ITypeProvider -> (string MaybeNull * int * int) option
@@ -569,9 +558,6 @@ type ProvidedCustomAttributeProvider (attributes :ITypeProvider -> seq Seq.toArray
[]
-#if NO_CHECKNULLS
-[]
-#endif
type ProvidedMemberInfo (x: MemberInfo, ctxt) =
let provide () = ProvidedCustomAttributeProvider (fun _ -> x.CustomAttributes) :> IProvidedCustomAttributeProvider
@@ -594,9 +580,6 @@ type ProvidedMemberInfo (x: MemberInfo, ctxt) =
provide().GetAttributeConstructorArgs (provider, attribName)
[]
-#if NO_CHECKNULLS
-[]
-#endif
type ProvidedParameterInfo (x: ParameterInfo, ctxt) =
let provide () = ProvidedCustomAttributeProvider (fun _ -> x.CustomAttributes) :> IProvidedCustomAttributeProvider
@@ -645,9 +628,6 @@ type ProvidedParameterInfo (x: ParameterInfo, ctxt) =
override _.GetHashCode() = assert false; x.GetHashCode()
[]
-#if NO_CHECKNULLS
-[]
-#endif
type ProvidedAssembly (x: Assembly) =
member _.GetName() = x.GetName()
@@ -665,9 +645,6 @@ type ProvidedAssembly (x: Assembly) =
override _.GetHashCode() = assert false; x.GetHashCode()
[]
-#if NO_CHECKNULLS
-[]
-#endif
type ProvidedMethodBase (x: MethodBase, ctxt) =
inherit ProvidedMemberInfo(x, ctxt)
@@ -762,9 +739,6 @@ type ProvidedMethodBase (x: MethodBase, ctxt) =
[]
-#if NO_CHECKNULLS
-[]
-#endif
type ProvidedFieldInfo (x: FieldInfo, ctxt) =
inherit ProvidedMemberInfo(x, ctxt)
@@ -812,9 +786,6 @@ type ProvidedFieldInfo (x: FieldInfo, ctxt) =
Tainted.EqTainted (pt1.PApplyNoFailure(fun st -> st.Handle)) (pt2.PApplyNoFailure(fun st -> st.Handle))
[]
-#if NO_CHECKNULLS
-[]
-#endif
type ProvidedMethodInfo (x: MethodInfo, ctxt) =
inherit ProvidedMethodBase(x, ctxt)
@@ -841,9 +812,6 @@ type ProvidedMethodInfo (x: MethodInfo, ctxt) =
override _.GetHashCode() = assert false; x.GetHashCode()
[]
-#if NO_CHECKNULLS
-[]
-#endif
type ProvidedPropertyInfo (x: PropertyInfo, ctxt) =
inherit ProvidedMemberInfo(x, ctxt)
@@ -885,9 +853,6 @@ type ProvidedPropertyInfo (x: PropertyInfo, ctxt) =
Tainted.EqTainted (pt1.PApplyNoFailure(fun st -> st.Handle)) (pt2.PApplyNoFailure(fun st -> st.Handle))
[]
-#if NO_CHECKNULLS
-[]
-#endif
type ProvidedEventInfo (x: EventInfo, ctxt) =
inherit ProvidedMemberInfo(x, ctxt)
@@ -923,9 +888,6 @@ type ProvidedEventInfo (x: EventInfo, ctxt) =
Tainted.EqTainted (pt1.PApplyNoFailure(fun st -> st.Handle)) (pt2.PApplyNoFailure(fun st -> st.Handle))
[]
-#if NO_CHECKNULLS
-[]
-#endif
type ProvidedConstructorInfo (x: ConstructorInfo, ctxt) =
inherit ProvidedMethodBase(x, ctxt)
@@ -967,11 +929,8 @@ type ProvidedExprType =
| ProvidedIfThenElseExpr of ProvidedExpr * ProvidedExpr * ProvidedExpr
| ProvidedVarExpr of ProvidedVar
-#if NO_CHECKNULLS
-[]
-#else
+
[]
-#endif
type ProvidedExpr (x: Expr, ctxt) =
member _.Type = x.Type |> ProvidedType.CreateNonNull ctxt
@@ -1043,11 +1002,7 @@ type ProvidedExpr (x: Expr, ctxt) =
override _.GetHashCode() = x.GetHashCode()
-#if NO_CHECKNULLS
-[]
-#else
[]
-#endif
type ProvidedVar (x: Var, ctxt) =
member _.Type = x.Type |> ProvidedType.CreateNonNull ctxt
member _.Name = x.Name
@@ -1097,11 +1052,9 @@ let ValidateExpectedName m expectedPath expectedName (st: Tainted)
if name <> expectedName then
raise (TypeProviderError(FSComp.SR.etProvidedTypeHasUnexpectedName(expectedName, name), st.TypeProviderDesignation, m))
-#if NO_CHECKNULLS
- let namespaceName = TryTypeMember(st, name, "Namespace", m, "", fun st -> st.Namespace) |> unmarshal
-#else
- let namespaceName = TryTypeMember<_, string | null>(st, name, "Namespace", m, "", fun st -> st.Namespace) |> unmarshal // TODO NULLNESS: why is this explicit instantiation needed?
-#endif
+
+ let namespaceName = TryTypeMember(st, name, "Namespace", m, ("":_|null), fun st -> st.Namespace) |> unmarshal
+
let rec declaringTypes (st: Tainted) accu =
match TryTypeMember(st, name, "DeclaringType", m, null, fun st -> st.DeclaringType) with
@@ -1124,11 +1077,7 @@ let ValidateProvidedTypeAfterStaticInstantiation(m, st: Tainted, e
// Do all the calling into st up front with recovery
let fullName, namespaceName, usedMembers =
let name = CheckAndComputeProvidedNameProperty(m, st, (fun st -> st.Name), "Name")
-#if NO_CHECKNULLS
- let namespaceName = TryTypeMember(st, name, "Namespace", m, FSComp.SR.invalidNamespaceForProvidedType(), fun st -> st.Namespace) |> unmarshal
-#else
let namespaceName = TryTypeMember<_, string | null>(st, name, "Namespace", m, FSComp.SR.invalidNamespaceForProvidedType(), fun st -> st.Namespace) |> unmarshal
-#endif
let fullName = TryTypeMemberNonNull(st, name, "FullName", m, FSComp.SR.invalidFullNameForProvidedType(), fun st -> st.FullName) |> unmarshal
ValidateExpectedName m expectedPath expectedName st
// Must be able to call (GetMethods|GetEvents|GetProperties|GetNestedTypes|GetConstructors)(bindingFlags).
@@ -1233,11 +1182,7 @@ let ValidateProvidedTypeDefinition(m, st: Tainted, expectedPath: s
// Validate the Name, Namespace and FullName properties
let name = CheckAndComputeProvidedNameProperty(m, st, (fun st -> st.Name), "Name")
-#if NO_CHECKNULLS
- let _namespaceName = TryTypeMember(st, name, "Namespace", m, FSComp.SR.invalidNamespaceForProvidedType(), fun st -> st.Namespace) |> unmarshal
-#else
let _namespaceName = TryTypeMember<_, string | null>(st, name, "Namespace", m, FSComp.SR.invalidNamespaceForProvidedType(), fun st -> st.Namespace) |> unmarshal
-#endif
let _fullname = TryTypeMemberNonNull(st, name, "FullName", m, FSComp.SR.invalidFullNameForProvidedType(), fun st -> st.FullName) |> unmarshal
ValidateExpectedName m expectedPath expectedName st
diff --git a/src/Compiler/TypedTree/TypeProviders.fsi b/src/Compiler/TypedTree/TypeProviders.fsi
index b8ec2158ea4..c29f091be78 100755
--- a/src/Compiler/TypedTree/TypeProviders.fsi
+++ b/src/Compiler/TypedTree/TypeProviders.fsi
@@ -15,7 +15,7 @@ open FSharp.Compiler.AbstractIL.IL
open FSharp.Compiler.Text
type TypeProviderDesignation = TypeProviderDesignation of string
-type 'a ProvidedArray= ('a[]) MaybeNull
+type 'a ProvidedArray = ('a[]) MaybeNull
/// Raised when a type provider has thrown an exception.
exception ProvidedTypeResolution of range * exn
@@ -92,10 +92,7 @@ type ProvidedTypeContext =
/// Map the TyconRef objects, if any
member RemapTyconRefs: (obj -> obj) -> ProvidedTypeContext
-[]
-#if NO_CHECKNULLS
-[]
-#endif
+[]
type ProvidedType =
inherit ProvidedMemberInfo
@@ -209,9 +206,6 @@ type ProvidedType =
static member TaintedEquals: Tainted * Tainted -> bool
-#if NO_CHECKNULLS
-[]
-#endif
type IProvidedCustomAttributeProvider =
abstract GetHasTypeProviderEditorHideMethodsAttribute: provider: ITypeProvider -> bool
@@ -221,12 +215,9 @@ type IProvidedCustomAttributeProvider =
abstract GetAttributeConstructorArgs:
provider: ITypeProvider * attribName: string -> (obj option list * (string * obj option) list) option
-
-[]
-#if NO_CHECKNULLS
-[]
-#endif
-type ProvidedAssembly =
+
+[]
+type ProvidedAssembly =
member GetName: unit -> System.Reflection.AssemblyName
member FullName: string
@@ -235,23 +226,17 @@ type ProvidedAssembly =
member Handle: System.Reflection.Assembly
-[]
-#if NO_CHECKNULLS
-[]
-#endif
-type ProvidedMemberInfo =
+[]
+type ProvidedMemberInfo =
member Name: string
member DeclaringType: ProvidedType MaybeNull
- interface IProvidedCustomAttributeProvider
+ interface IProvidedCustomAttributeProvider
-[]
-#if NO_CHECKNULLS
-[]
-#endif
-type ProvidedMethodBase =
+[]
+type ProvidedMethodBase =
inherit ProvidedMemberInfo
member IsGenericMethod: bool
@@ -286,11 +271,8 @@ type ProvidedMethodBase =
static member TaintedEquals: Tainted * Tainted -> bool
-[]
-#if NO_CHECKNULLS
-[]
-#endif
-type ProvidedMethodInfo =
+[]
+type ProvidedMethodInfo =
inherit ProvidedMethodBase
@@ -298,11 +280,8 @@ type ProvidedMethodInfo =
member MetadataToken: int
-[]
-#if NO_CHECKNULLS
-[]
-#endif
-type ProvidedParameterInfo =
+[]
+type ProvidedParameterInfo =
member Name: string
@@ -320,11 +299,8 @@ type ProvidedParameterInfo =
interface IProvidedCustomAttributeProvider
-[]
-#if NO_CHECKNULLS
-[]
-#endif
-type ProvidedFieldInfo =
+[]
+type ProvidedFieldInfo =
inherit ProvidedMemberInfo
@@ -352,11 +328,8 @@ type ProvidedFieldInfo =
static member TaintedEquals: Tainted * Tainted -> bool
-[]
-#if NO_CHECKNULLS
-[]
-#endif
-type ProvidedPropertyInfo =
+[]
+type ProvidedPropertyInfo =
inherit ProvidedMemberInfo
@@ -376,11 +349,8 @@ type ProvidedPropertyInfo =
static member TaintedEquals: Tainted * Tainted -> bool
-[]
-#if NO_CHECKNULLS
-[]
-#endif
-type ProvidedEventInfo =
+[]
+type ProvidedEventInfo =
inherit ProvidedMemberInfo
@@ -394,11 +364,8 @@ type ProvidedEventInfo =
static member TaintedEquals: Tainted * Tainted -> bool
-[]
-#if NO_CHECKNULLS
-[]
-#endif
-type ProvidedConstructorInfo =
+[]
+type ProvidedConstructorInfo =
inherit ProvidedMethodBase
type ProvidedExprType =
@@ -442,11 +409,8 @@ type ProvidedExprType =
| ProvidedIfThenElseExpr of ProvidedExpr * ProvidedExpr * ProvidedExpr
| ProvidedVarExpr of ProvidedVar
-
-[]
-#if NO_CHECKNULLS
-[]
-#endif
+
+[]
type ProvidedExpr =
member Type: ProvidedType
@@ -456,10 +420,7 @@ type ProvidedExpr =
member GetExprType: unit -> ProvidedExprType option
-[]
-#if NO_CHECKNULLS
-[]
-#endif
+[]
type ProvidedVar =
member Type: ProvidedType
@@ -481,7 +442,10 @@ val ValidateProvidedTypeAfterStaticInstantiation:
/// to check the type name is as expected (this function is called by the caller of TryApplyProvidedType
/// after other checks are made).
val TryApplyProvidedType:
- typeBeforeArguments: Tainted * optGeneratedTypePath: string list option * staticArgs: objnull[] * range ->
+ typeBeforeArguments: Tainted *
+ optGeneratedTypePath: string list option *
+ staticArgs: objnull[] *
+ range ->
(Tainted * (unit -> unit)) option
/// Try to apply a provided method to the given static arguments.
diff --git a/src/Compiler/TypedTree/TypedTreeOps.fs b/src/Compiler/TypedTree/TypedTreeOps.fs
index e5e330759dc..4b41db72349 100644
--- a/src/Compiler/TypedTree/TypedTreeOps.fs
+++ b/src/Compiler/TypedTree/TypedTreeOps.fs
@@ -39,17 +39,11 @@ let RemapExprStackGuardDepth = GetEnvInteger "FSHARP_RemapExpr" 50
let FoldExprStackGuardDepth = GetEnvInteger "FSHARP_FoldExpr" 50
let inline compareBy (x: 'T MaybeNull) (y: 'T MaybeNull) ([]func: 'T -> 'K) =
-#if NO_CHECKNULLS
- compare (func x) (func y)
-#else
match x,y with
| null,null -> 0
| null,_ -> -1
| _,null -> 1
| x,y -> compare (func !!x) (func !!y)
-#endif
-
-
//---------------------------------------------------------------------------
// Basic data structures
@@ -3576,12 +3570,7 @@ let TryFindLocalizedFSharpStringAttribute g nm attrs =
match TryFindFSharpAttribute g nm attrs with
| Some(Attrib(_, _, [ AttribStringArg b ], namedArgs, _, _, _)) ->
match namedArgs with
- | ExtractAttribNamedArg "Localize" (AttribBoolArg true) ->
- #if PROTO || BUILDING_WITH_LKG
- Some b
- #else
- FSComp.SR.GetTextOpt(b)
- #endif
+ | ExtractAttribNamedArg "Localize" (AttribBoolArg true) -> FSComp.SR.GetTextOpt(b)
| _ -> Some b
| _ -> None
@@ -8476,9 +8465,9 @@ let (|NewDelegateExpr|_|) g expr =
[]
let (|DelegateInvokeExpr|_|) g expr =
match expr with
- | Expr.App ((Expr.Val (invokeRef, _, _)) as delInvokeRef, delInvokeTy, [], [delExpr;delInvokeArg], m)
+ | Expr.App ((Expr.Val (invokeRef, _, _)) as delInvokeRef, delInvokeTy, tyargs, [delExpr;delInvokeArg], m)
when invokeRef.LogicalName = "Invoke" && isFSharpDelegateTy g (tyOfExpr g delExpr) ->
- ValueSome(delInvokeRef, delInvokeTy, delExpr, delInvokeArg, m)
+ ValueSome(delInvokeRef, delInvokeTy, tyargs, delExpr, delInvokeArg, m)
| _ -> ValueNone
[]
@@ -8505,17 +8494,17 @@ let (|OpPipeRight3|_|) g expr =
ValueSome(resType, arg1, arg2, arg3, fExpr, m)
| _ -> ValueNone
-let rec MakeFSharpDelegateInvokeAndTryBetaReduce g (delInvokeRef, delExpr, delInvokeTy, delInvokeArg, m) =
+let rec MakeFSharpDelegateInvokeAndTryBetaReduce g (delInvokeRef, delExpr, delInvokeTy, tyargs, delInvokeArg, m) =
match delExpr with
| Expr.Let (bind, body, mLet, _) ->
- mkLetBind mLet bind (MakeFSharpDelegateInvokeAndTryBetaReduce g (delInvokeRef, body, delInvokeTy, delInvokeArg, m))
- | NewDelegateExpr g (_, argvs, body, m, _) when argvs.Length > 0 ->
+ mkLetBind mLet bind (MakeFSharpDelegateInvokeAndTryBetaReduce g (delInvokeRef, body, delInvokeTy, tyargs, delInvokeArg, m))
+ | NewDelegateExpr g (_, argvs & _ :: _, body, m, _) ->
let pairs, body = MultiLambdaToTupledLambdaIfNeeded g (argvs, delInvokeArg) body
let argvs2, args2 = List.unzip pairs
mkLetsBind m (mkCompGenBinds argvs2 args2) body
| _ ->
// Remake the delegate invoke
- Expr.App (delInvokeRef, delInvokeTy, [], [delExpr; delInvokeArg], m)
+ Expr.App (delInvokeRef, delInvokeTy, tyargs, [delExpr; delInvokeArg], m)
//---------------------------------------------------------------------------
// Adjust for expected usage
@@ -9252,7 +9241,7 @@ let GetDisallowedNullness (g:TcGlobals) (ty:TType) =
| None -> []
| Some t -> hasWithNullAnyWhere t withNull
- | TType_app (tcr, tinst, nullnessOrig) ->
+ | TType_app (tcr, tinst, _) ->
let tyArgs = tinst |> List.collect (fun t -> hasWithNullAnyWhere t false)
match alreadyWrappedInOuterWithNull, tcr.TypeAbbrev with
@@ -9271,7 +9260,7 @@ let GetDisallowedNullness (g:TcGlobals) (ty:TType) =
let inner = tupTypes |> List.collect (fun t -> hasWithNullAnyWhere t false)
if alreadyWrappedInOuterWithNull then ty :: inner else inner
- | TType_anon (anon,tys) ->
+ | TType_anon (tys=tys) ->
let inner = tys |> List.collect (fun t -> hasWithNullAnyWhere t false)
if alreadyWrappedInOuterWithNull then ty :: inner else inner
| TType_fun (d, r, _) ->
diff --git a/src/Compiler/TypedTree/TypedTreeOps.fsi b/src/Compiler/TypedTree/TypedTreeOps.fsi
index c67ccb30800..06200be47f7 100755
--- a/src/Compiler/TypedTree/TypedTreeOps.fsi
+++ b/src/Compiler/TypedTree/TypedTreeOps.fsi
@@ -1438,7 +1438,9 @@ val MakeApplicationAndBetaReduce: TcGlobals -> Expr * TType * TypeInst list * Ex
/// Make a delegate invoke expression for an F# delegate type, doing beta reduction by introducing let-bindings
/// if the delegate expression is a construction of a delegate.
val MakeFSharpDelegateInvokeAndTryBetaReduce:
- TcGlobals -> delInvokeRef: Expr * delExpr: Expr * delInvokeTy: TType * delInvokeArg: Expr * m: range -> Expr
+ TcGlobals ->
+ delInvokeRef: Expr * delExpr: Expr * delInvokeTy: TType * tyargs: TypeInst * delInvokeArg: Expr * m: range ->
+ Expr
/// Combine two static-resolution requirements on a type parameter
val JoinTyparStaticReq: TyparStaticReq -> TyparStaticReq -> TyparStaticReq
@@ -2751,7 +2753,7 @@ val (|NewDelegateExpr|_|): TcGlobals -> Expr -> (Unique * Val list * Expr * rang
/// Match a .Invoke on a delegate
[]
-val (|DelegateInvokeExpr|_|): TcGlobals -> Expr -> (Expr * TType * Expr * Expr * range) voption
+val (|DelegateInvokeExpr|_|): TcGlobals -> Expr -> (Expr * TType * TypeInst * Expr * Expr * range) voption
/// Match 'if __useResumableCode then ... else ...' expressions
[]
diff --git a/src/Compiler/TypedTree/tainted.fs b/src/Compiler/TypedTree/tainted.fs
index 76a0ba131e4..8b3561aaaa3 100644
--- a/src/Compiler/TypedTree/tainted.fs
+++ b/src/Compiler/TypedTree/tainted.fs
@@ -171,13 +171,8 @@ type internal Tainted<'T> (context: TaintedContext, value: 'T) =
module internal Tainted =
-#if NO_CHECKNULLS
- let (|Null|NonNull|) (p:Tainted<'T>) : Choice> when 'T : null and 'T : not struct =
- if p.PUntaintNoFailure isNull then Null else NonNull (p.PApplyNoFailure id)
-#else
let (|Null|NonNull|) (p:Tainted<'T | null>) : Choice> when 'T : not null and 'T : not struct =
if p.PUntaintNoFailure isNull then Null else NonNull (p.PApplyNoFailure nonNull)
-#endif
let Eq (p:Tainted<'T>) (v:'T) = p.PUntaintNoFailure (fun pv -> pv = v)
diff --git a/src/Compiler/TypedTree/tainted.fsi b/src/Compiler/TypedTree/tainted.fsi
index d066eefd3b2..b75c8c43a5b 100644
--- a/src/Compiler/TypedTree/tainted.fsi
+++ b/src/Compiler/TypedTree/tainted.fsi
@@ -81,7 +81,7 @@ type internal Tainted<'T> =
member PApplyArray: ('T -> 'U[] MaybeNull) * string * range: range -> Tainted<'U>[]
/// Apply an operation that returns an array. Filter the array. Unwrap array. Any exception will be attributed to the type provider with an error located at the given range. String is method name of thing-returning-array, to diagnostically attribute if it is null
- member PApplyFilteredArray: ('T -> 'U[] MaybeNull) * ('U -> bool) *string * range: range -> Tainted<'U>[]
+ member PApplyFilteredArray: ('T -> 'U[] MaybeNull) * ('U -> bool) * string * range: range -> Tainted<'U>[]
/// Apply an operation that returns an option. Unwrap option. Any exception will be attributed to the type provider with an error located at the given range
member PApplyOption: ('T -> 'U option) * range: range -> Tainted<'U> option
@@ -104,11 +104,7 @@ type internal Tainted<'T> =
module internal Tainted =
/// Test whether the tainted value is null
-#if NO_CHECKNULLS
- val (|Null|NonNull|) : Tainted<'T MaybeNull> -> Choice> when 'T : null and 'T : not struct
-#else
- val (|Null|NonNull|) : Tainted<'T MaybeNull> -> Choice> when 'T : not null and 'T : not struct
-#endif
+ val (|Null|NonNull|): Tainted<'T MaybeNull> -> Choice> when 'T: not null and 'T: not struct
/// Test whether the tainted value equals given value.
/// Failure in call to equality operation will be blamed on type provider of first operand
diff --git a/src/Compiler/Utilities/Activity.fs b/src/Compiler/Utilities/Activity.fs
index 2d204864f69..121b52cf07f 100644
--- a/src/Compiler/Utilities/Activity.fs
+++ b/src/Compiler/Utilities/Activity.fs
@@ -9,7 +9,6 @@ open System.Text
open Internal.Utilities.Library
open System.Collections.Generic
-
module ActivityNames =
[]
let FscSourceName = "fsc"
@@ -90,18 +89,18 @@ module internal Activity =
let private activitySource = new ActivitySource(ActivityNames.FscSourceName)
- let start (name: string) (tags: (string * string) seq) : IDisposable MaybeNull =
+ let start (name: string) (tags: (string * string) seq) : ActivityDisposable =
let activity = activitySource.CreateActivity(name, ActivityKind.Internal)
match activity with
- | null -> activity
+ | null -> activity
| activity ->
for key, value in tags do
activity.AddTag(key, value) |> ignore
activity.Start()
- let startNoTags (name: string) : IDisposable MaybeNull = activitySource.StartActivity name
+ let startNoTags (name: string) : ActivityDisposable = activitySource.StartActivity name
let addEventWithTags name (tags: (string * objnull) seq) =
match Activity.Current with
@@ -128,7 +127,7 @@ module internal Activity =
let private profiledSource = new ActivitySource(ActivityNames.ProfiledSourceName)
- let startAndMeasureEnvironmentStats (name: string) : IDisposable MaybeNull = profiledSource.StartActivity(name)
+ let startAndMeasureEnvironmentStats (name: string) : ActivityDisposable = profiledSource.StartActivity(name)
type private GCStats = int[]
@@ -210,7 +209,11 @@ module internal Activity =
match o with
| null -> ""
| o ->
- let mutable txtVal = match o.ToString() with | null -> "" | s -> s
+ let mutable txtVal =
+ match o.ToString() with
+ | null -> ""
+ | s -> s
+
let hasComma = txtVal.IndexOf(',') > -1
let hasQuote = txtVal.IndexOf('"') > -1
@@ -243,7 +246,7 @@ module internal Activity =
sb.ToString()
- let addCsvFileListener (pathToFile:string) =
+ let addCsvFileListener (pathToFile: string) =
if pathToFile |> File.Exists |> not then
File.WriteAllLines(
pathToFile,
@@ -265,7 +268,7 @@ module internal Activity =
let l =
new ActivityListener(
- ShouldListenTo = (fun a ->ActivityNames.AllRelevantNames |> Array.contains a.Name),
+ ShouldListenTo = (fun a -> ActivityNames.AllRelevantNames |> Array.contains a.Name),
Sample = (fun _ -> ActivitySamplingResult.AllData),
ActivityStopped = (fun a -> msgQueue.Post(createCsvRow a))
)
diff --git a/src/Compiler/Utilities/Activity.fsi b/src/Compiler/Utilities/Activity.fsi
index 041b2998765..773c7528869 100644
--- a/src/Compiler/Utilities/Activity.fsi
+++ b/src/Compiler/Utilities/Activity.fsi
@@ -40,16 +40,16 @@ module internal Activity =
module Events =
val cacheHit: string
- val startNoTags: name: string -> IDisposable MaybeNull
+ val startNoTags: name: string -> ActivityDisposable
- val start: name: string -> tags: (string * string) seq -> IDisposable MaybeNull
+ val start: name: string -> tags: (string * string) seq -> ActivityDisposable
val addEvent: name: string -> unit
val addEventWithTags: name: string -> tags: (string * objnull) seq -> unit
module Profiling =
- val startAndMeasureEnvironmentStats: name: string -> IDisposable MaybeNull
+ val startAndMeasureEnvironmentStats: name: string -> ActivityDisposable
val addConsoleListener: unit -> IDisposable
module CsvExport =
diff --git a/src/Compiler/Utilities/Cancellable.fsi b/src/Compiler/Utilities/Cancellable.fsi
index e74404c7eec..0d82faa68cb 100644
--- a/src/Compiler/Utilities/Cancellable.fsi
+++ b/src/Compiler/Utilities/Cancellable.fsi
@@ -68,12 +68,9 @@ type internal CancellableBuilder =
comp: Cancellable<'T> * [] handler: (exn -> Cancellable<'T>) -> Cancellable<'T>
member inline Using:
- resource: 'Resource MaybeNull * [] comp: ('Resource MaybeNull -> Cancellable<'T>) -> Cancellable<'T>
- when 'Resource :> IDisposable
- and 'Resource:not struct
-#if !(NO_CHECKNULLS || BUILDING_WITH_LKG)
- and 'Resource:not null
-#endif
+ resource: 'Resource MaybeNull * [] comp: ('Resource MaybeNull -> Cancellable<'T>) ->
+ Cancellable<'T>
+ when 'Resource :> IDisposable and 'Resource: not struct and 'Resource: not null
member inline Zero: unit -> Cancellable
diff --git a/src/Compiler/Utilities/HashMultiMap.fs b/src/Compiler/Utilities/HashMultiMap.fs
index c0fc897121d..2688869136e 100644
--- a/src/Compiler/Utilities/HashMultiMap.fs
+++ b/src/Compiler/Utilities/HashMultiMap.fs
@@ -8,11 +8,7 @@ open System.Collections.Concurrent
// Each entry in the HashMultiMap dictionary has at least one entry. Under normal usage each entry has _only_
// one entry. So use two hash tables: one for the main entries and one for the overflow.
[]
-type internal HashMultiMap<'Key, 'Value
-#if !NO_CHECKNULLS
- when 'Key:not null
-#endif
- >(size: int, comparer: IEqualityComparer<'Key>, ?useConcurrentDictionary: bool) =
+type internal HashMultiMap<'Key, 'Value when 'Key: not null>(size: int, comparer: IEqualityComparer<'Key>, ?useConcurrentDictionary: bool) =
let comparer = comparer
diff --git a/src/Compiler/Utilities/HashMultiMap.fsi b/src/Compiler/Utilities/HashMultiMap.fsi
index 6a4ba2ce119..475f9db558d 100644
--- a/src/Compiler/Utilities/HashMultiMap.fsi
+++ b/src/Compiler/Utilities/HashMultiMap.fsi
@@ -7,11 +7,7 @@ open System.Collections.Generic
/// Hash tables, by default based on F# structural "hash" and (=) functions.
/// The table may map a single key to multiple bindings.
[]
-type internal HashMultiMap<'Key, 'Value
-#if !NO_CHECKNULLS
- when 'Key:not null
-#endif
- > =
+type internal HashMultiMap<'Key, 'Value when 'Key: not null> =
/// Create a new empty mutable HashMultiMap with the given key hash/equality functions.
new: comparer: IEqualityComparer<'Key> * ?useConcurrentDictionary: bool -> HashMultiMap<'Key, 'Value>
@@ -20,7 +16,9 @@ type internal HashMultiMap<'Key, 'Value
new: size: int * comparer: IEqualityComparer<'Key> * ?useConcurrentDictionary: bool -> HashMultiMap<'Key, 'Value>
/// Build a map that contains the bindings of the given IEnumerable.
- new: entries: seq<'Key * 'Value> * comparer: IEqualityComparer<'Key> * ?useConcurrentDictionary: bool -> HashMultiMap<'Key, 'Value>
+ new:
+ entries: seq<'Key * 'Value> * comparer: IEqualityComparer<'Key> * ?useConcurrentDictionary: bool ->
+ HashMultiMap<'Key, 'Value>
/// Make a shallow copy of the collection.
member Copy: unit -> HashMultiMap<'Key, 'Value>
diff --git a/src/Compiler/Utilities/LruCache.fs b/src/Compiler/Utilities/LruCache.fs
index 92f73885eb7..942b9acfc34 100644
--- a/src/Compiler/Utilities/LruCache.fs
+++ b/src/Compiler/Utilities/LruCache.fs
@@ -23,12 +23,8 @@ type internal ValueLink<'T when 'T: not struct> =
| Weak of WeakReference<'T>
[]
-type internal LruCache<'TKey, 'TVersion, 'TValue when 'TKey: equality and 'TVersion: equality and 'TValue: not struct
-#if !NO_CHECKNULLS
- and 'TKey:not null
- and 'TVersion:not null
-#endif
- >
+type internal LruCache<'TKey, 'TVersion, 'TValue
+ when 'TKey: equality and 'TVersion: equality and 'TValue: not struct and 'TKey: not null and 'TVersion: not null>
(keepStrongly, ?keepWeakly, ?requiredToKeep, ?event) =
let keepWeakly = defaultArg keepWeakly 100
@@ -72,7 +68,7 @@ type internal LruCache<'TKey, 'TVersion, 'TValue when 'TKey: equality and 'TVers
let mutable node = weakList.Last
while weakList.Count > keepWeakly && node <> null do
- let notNullNode = !! node
+ let notNullNode = !!node
let previous = notNullNode.Previous
let key, version, label, _ = notNullNode.Value
weakList.Remove notNullNode
@@ -90,7 +86,7 @@ type internal LruCache<'TKey, 'TVersion, 'TValue when 'TKey: equality and 'TVers
let mutable anythingWeakened = false
while strongList.Count > keepStrongly && node <> null do
- let notNullNode = !! node
+ let notNullNode = !!node
let previous = notNullNode.Previous
match notNullNode.Value with
diff --git a/src/Compiler/Utilities/LruCache.fsi b/src/Compiler/Utilities/LruCache.fsi
index 5979304f163..0d6b9c2e750 100644
--- a/src/Compiler/Utilities/LruCache.fsi
+++ b/src/Compiler/Utilities/LruCache.fsi
@@ -12,13 +12,8 @@ type internal CacheEvent =
///
/// It's also versioned, meaning each key can have multiple versions and only the latest one is kept strongly.
/// Older versions are kept weakly and can be collected by GC.
-type internal LruCache<'TKey, 'TVersion, 'TValue when 'TKey: equality and 'TVersion: equality and 'TValue: not struct
-#if !NO_CHECKNULLS
- and 'TKey:not null
- and 'TVersion:not null
-#endif
- > =
-
+type internal LruCache<'TKey, 'TVersion, 'TValue
+ when 'TKey: equality and 'TVersion: equality and 'TValue: not struct and 'TKey: not null and 'TVersion: not null> =
/// Maximum number of strongly held results to keep in the cache
/// Maximum number of weakly held results to keep in the cache
/// A predicate that determines if a value should be kept strongly (no matter what)
diff --git a/src/Compiler/Utilities/NullnessShims.fs b/src/Compiler/Utilities/NullnessShims.fs
index ee801610255..848bf650e98 100644
--- a/src/Compiler/Utilities/NullnessShims.fs
+++ b/src/Compiler/Utilities/NullnessShims.fs
@@ -7,44 +7,6 @@ module internal NullnessShims =
let inline isNotNull (x: 'T) = not (isNull x)
-#if NO_CHECKNULLS || BUILDING_WITH_LKG
- type 'T MaybeNull when 'T: not struct = 'T
- type objnull = obj
-
- let inline (^) (a: 'a) ([] b: 'a -> 'b) : 'b =
- match a with
- | null -> Unchecked.defaultof<'b>
- | _ -> b a
-
- let inline (|NonNullQuick|) (x: 'T MaybeNull) =
- match x with
- | null -> raise (NullReferenceException())
- | v -> v
-
- let inline nonNull<'T when 'T:not struct and 'T:null> (x: 'T MaybeNull ) =
- match x with
- | null -> raise (NullReferenceException())
- | v -> v
-
- let inline (|Null|NonNull|) (x: 'T MaybeNull) : Choice =
- match x with
- | null -> Null
- | v -> NonNull v
-
- let inline nullArgCheck paramName (x: 'T MaybeNull) =
- if isNull (box x) then raise (ArgumentNullException(paramName))
- else x
-
- let inline (!!) x = x
-
- let inline defaultIfNull defaultValue arg = match arg with | null -> defaultValue | _ -> arg
-
- let inline nullSafeEquality (x: MaybeNull<'T>) (y: MaybeNull<'T>) ([]nonNullEqualityFunc:'T->'T->bool) =
- match box x, box y with
- | null, null -> true
- | null,_ | _, null -> false
- | _,_ -> nonNullEqualityFunc x y
-#else
type 'T MaybeNull when 'T: not null and 'T: not struct = 'T | null
let inline (^) (a: 'a | null) ([] b: 'a -> 'b) : ('b | null) =
@@ -52,16 +14,20 @@ module internal NullnessShims =
| Null -> null
| NonNull v -> b v
- let inline (!!) (x:'T | null) = Unchecked.nonNull x
+ let inline (!!) (x: 'T | null) = Unchecked.nonNull x
- let inline nullSafeEquality (x: MaybeNull<'T>) (y: MaybeNull<'T>) ([]nonNullEqualityFunc:'T->'T->bool) =
+ let inline nullSafeEquality (x: MaybeNull<'T>) (y: MaybeNull<'T>) ([] nonNullEqualityFunc: 'T -> 'T -> bool) =
match x, y with
| null, null -> true
- | null,_ | _, null -> false
+ | null, _
+ | _, null -> false
| x, y -> nonNullEqualityFunc !!x !!y
-#endif
-
+#if BUILDING_WITH_LKG
+ type ActivityDisposable = System.IDisposable
+#else
+ type ActivityDisposable = System.IDisposable | null
+#endif
#if NET5_0_OR_GREATER
// Argument type for overriding System.Object.Equals(arg)
@@ -71,10 +37,9 @@ module internal NullnessShims =
type objEqualsArg = obj
#endif
-
- []
+ []
let inline (|NonEmptyString|_|) (x: string MaybeNull) =
match x with
| null -> ValueNone
| "" -> ValueNone
- | v -> ValueSome v
\ No newline at end of file
+ | v -> ValueSome v
diff --git a/src/Compiler/Utilities/illib.fs b/src/Compiler/Utilities/illib.fs
index 0f68d92a429..470d7402e07 100644
--- a/src/Compiler/Utilities/illib.fs
+++ b/src/Compiler/Utilities/illib.fs
@@ -17,8 +17,7 @@ type InterruptibleLazy<'T> private (value, valueFactory: unit -> 'T) =
[]
// TODO nullness - this is boxed to obj because of an attribute targets bug fixed in main, but not yet shipped (needs shipped 8.0.400)
- let mutable valueFactory : objnull = valueFactory
-
+ let mutable valueFactory: objnull = valueFactory
let mutable value = value
@@ -104,7 +103,7 @@ module internal PervasiveAutoOpens =
member inline x.EndsWithOrdinalIgnoreCase value =
x.EndsWith(value, StringComparison.OrdinalIgnoreCase)
- member inline x.IndexOfOrdinal (value:string) =
+ member inline x.IndexOfOrdinal(value: string) =
x.IndexOf(value, StringComparison.Ordinal)
member inline x.IndexOfOrdinal(value, startIndex) =
@@ -154,8 +153,8 @@ module internal PervasiveAutoOpens =
type DelayInitArrayMap<'T, 'TDictKey, 'TDictValue>(f: unit -> 'T[]) =
let syncObj = obj ()
- let mutable arrayStore : _ array MaybeNull = null
- let mutable dictStore : _ MaybeNull = null
+ let mutable arrayStore: _ array MaybeNull = null
+ let mutable dictStore: _ MaybeNull = null
let mutable func = f
@@ -206,12 +205,12 @@ module Order =
member _.Compare(x, xx) = compare (p !!x) (p !!xx)
}
- let orderOn (p:'T->'U) (pxOrder: IComparer<'U>) =
+ let orderOn (p: 'T -> 'U) (pxOrder: IComparer<'U>) =
{ new IComparer<'T> with
member _.Compare(x, xx) = pxOrder.Compare(p !!x, p !!xx)
}
- let toFunction (pxOrder: IComparer<'U>) (x:'U) (y:'U) = pxOrder.Compare(x, y)
+ let toFunction (pxOrder: IComparer<'U>) (x: 'U) (y: 'U) = pxOrder.Compare(x, y)
//-------------------------------------------------------------------------
// Library: arrays, lists, options, resizearrays
@@ -242,7 +241,7 @@ module Array =
let order (eltOrder: IComparer<'T>) =
{ new IComparer<'T array> with
member _.Compare(xs, ys) =
- let xs,ys = nullArgCheck "xs" xs, nullArgCheck "ys" ys
+ let xs, ys = nullArgCheck "xs" xs, nullArgCheck "ys" ys
let c = compare xs.Length ys.Length
if c <> 0 then
@@ -412,8 +411,8 @@ module Option =
with _ ->
None
-module internal ValueTuple =
- let inline map1Of2 ([]f) struct(a1, a2) = struct(f a1, a2)
+module internal ValueTuple =
+ let inline map1Of2 ([] f) struct (a1, a2) = struct (f a1, a2)
module List =
@@ -539,7 +538,8 @@ module List =
let order (eltOrder: IComparer<'T>) =
{ new IComparer<'T list> with
member _.Compare(xs, ys) =
- let xs,ys = nullArgCheck "xs" xs, nullArgCheck "ys" ys
+ let xs, ys = nullArgCheck "xs" xs, nullArgCheck "ys" ys
+
let rec loop xs ys =
match xs, ys with
| [], [] -> 0
@@ -642,21 +642,22 @@ module List =
| Some x -> x :: l
| _ -> l
-
[]
- let rec private vMapFoldWithAcc<'T, 'State, 'Result> (mapping: 'State -> 'T -> struct('Result * 'State)) state list acc : struct('Result list * 'State) =
+ let rec private vMapFoldWithAcc<'T, 'State, 'Result>
+ (mapping: 'State -> 'T -> struct ('Result * 'State))
+ state
+ list
+ acc
+ : struct ('Result list * 'State) =
match list with
| [] -> acc, state
- | [h] ->
- mapping state h
- |> ValueTuple.map1Of2 (fun x -> x::acc)
+ | [ h ] -> mapping state h |> ValueTuple.map1Of2 (fun x -> x :: acc)
| h :: t ->
- let struct(mappedHead, stateHead) = mapping state h
+ let struct (mappedHead, stateHead) = mapping state h
vMapFoldWithAcc mapping stateHead t (mappedHead :: acc)
- let vMapFold<'T, 'State, 'Result> (mapping: 'State -> 'T -> struct('Result * 'State)) state list : struct('Result list * 'State) =
- vMapFoldWithAcc mapping state list []
- |> ValueTuple.map1Of2 List.rev
+ let vMapFold<'T, 'State, 'Result> (mapping: 'State -> 'T -> struct ('Result * 'State)) state list : struct ('Result list * 'State) =
+ vMapFoldWithAcc mapping state list [] |> ValueTuple.map1Of2 List.rev
module ResizeArray =
@@ -796,13 +797,11 @@ module String =
elif (!!value).StartsWithOrdinal pattern then Some()
else None
- let (|Contains|_|) (pattern:string) (value:string|null) =
- match value with
+ let (|Contains|_|) (pattern: string) (value: string | null) =
+ match value with
| null -> None
| value when String.IsNullOrWhiteSpace value -> None
- | value ->
- if value.Contains pattern then Some()
- else None
+ | value -> if value.Contains pattern then Some() else None
let getLines (str: string) =
use reader = new StringReader(str)
@@ -854,9 +853,7 @@ module Lazy =
// Single threaded execution and mutual exclusion
/// Represents a permission active at this point in execution
-type ExecutionToken =
- interface
- end
+type ExecutionToken = interface end
/// Represents a token that indicates execution on the compilation thread, i.e.
/// - we have full access to the (partially mutable) TAST and TcImports data structures
@@ -941,11 +938,7 @@ module ResultOrException =
| Exception _err -> f ()
/// Generates unique stamps
-type UniqueStampGenerator<'T when 'T: equality
-#if !NO_CHECKNULLS
- and 'T:not null
-#endif
- >() =
+type UniqueStampGenerator<'T when 'T: equality and 'T: not null>() =
let encodeTable = ConcurrentDictionary<'T, Lazy>(HashIdentity.Structural)
let mutable nItems = -1
@@ -957,11 +950,7 @@ type UniqueStampGenerator<'T when 'T: equality
member _.Table = encodeTable.Keys
/// memoize tables (all entries cached, never collected)
-type MemoizationTable<'T, 'U
-#if !NO_CHECKNULLS
- when 'T:not null
-#endif
- >(compute: 'T -> 'U, keyComparer: IEqualityComparer<'T>, ?canMemoize) =
+type MemoizationTable<'T, 'U when 'T: not null>(compute: 'T -> 'U, keyComparer: IEqualityComparer<'T>, ?canMemoize) =
let table = new ConcurrentDictionary<'T, Lazy<'U>>(keyComparer)
let computeFunc = Func<_, _>(fun key -> lazy (compute key))
@@ -977,11 +966,7 @@ type MemoizationTable<'T, 'U
compute x
/// A thread-safe lookup table which is assigning an auto-increment stamp with each insert
-type internal StampedDictionary<'T, 'U
-#if !NO_CHECKNULLS
- when 'T:not null
-#endif
- >(keyComparer: IEqualityComparer<'T>) =
+type internal StampedDictionary<'T, 'U when 'T: not null>(keyComparer: IEqualityComparer<'T>) =
let table = new ConcurrentDictionary<'T, Lazy>(keyComparer)
let mutable count = -1
@@ -1307,12 +1292,13 @@ module MultiMap =
let initBy f xs : MultiMap<_, _> =
xs |> Seq.groupBy f |> Seq.map (fun (k, v) -> (k, List.ofSeq v)) |> Map.ofSeq
- let ofList (xs: ('a * 'b) list) : MultiMap<'a,'b> =
+ let ofList (xs: ('a * 'b) list) : MultiMap<'a, 'b> =
(Map.empty, xs)
||> List.fold (fun m (k, v) ->
- m |> Map.change k (function
- | None -> Some [v]
- | Some vs -> Some (v :: vs)))
+ m
+ |> Map.change k (function
+ | None -> Some [ v ]
+ | Some vs -> Some(v :: vs)))
|> Map.map (fun _ values -> List.rev values)
type LayeredMap<'Key, 'Value when 'Key: comparison> = Map<'Key, 'Value>
diff --git a/src/Compiler/Utilities/illib.fsi b/src/Compiler/Utilities/illib.fsi
index bd9d330cfe4..e2fba355366 100644
--- a/src/Compiler/Utilities/illib.fsi
+++ b/src/Compiler/Utilities/illib.fsi
@@ -86,18 +86,9 @@ type DelayInitArrayMap<'T, 'TDictKey, 'TDictValue> =
module internal Order =
- val orderBy: p: ('T -> 'U) -> IComparer<'T>
- when 'U: comparison
-#if !NO_CHECKNULLS
- and 'T:not null
- and 'T:not struct
-#endif
+ val orderBy: p: ('T -> 'U) -> IComparer<'T> when 'U: comparison and 'T: not null and 'T: not struct
- val orderOn: p: ('T -> 'U) -> pxOrder: IComparer<'U> -> IComparer<'T>
-#if !NO_CHECKNULLS
- when 'T:not null
- and 'T:not struct
-#endif
+ val orderOn: p: ('T -> 'U) -> pxOrder: IComparer<'U> -> IComparer<'T> when 'T: not null and 'T: not struct
val toFunction: pxOrder: IComparer<'U> -> x: 'U -> y: 'U -> int
@@ -230,7 +221,11 @@ module internal List =
val prependIfSome: x: 'a option -> l: 'a list -> 'a list
- val vMapFold<'T,'State,'Result> : mapping:('State -> 'T -> struct('Result * 'State)) -> state:'State -> list:'T list -> struct('Result list * 'State)
+ val vMapFold<'T, 'State, 'Result> :
+ mapping: ('State -> 'T -> struct ('Result * 'State)) ->
+ state: 'State ->
+ list: 'T list ->
+ struct ('Result list * 'State)
module internal ResizeArray =
@@ -284,7 +279,7 @@ module internal String =
val (|StartsWith|_|): pattern: string -> value: string -> unit option
- val (|Contains|_|): pattern: string -> value: string|null -> unit option
+ val (|Contains|_|): pattern: string -> value: string | null -> unit option
val getLines: str: string -> string[]
@@ -306,9 +301,7 @@ module internal Lazy =
val force: x: Lazy<'T> -> 'T
/// Represents a permission active at this point in execution
-type internal ExecutionToken =
- interface
- end
+type internal ExecutionToken = interface end
/// Represents a token that indicates execution on the compilation thread, i.e.
/// - we have full access to the (partially mutable) TAST and TcImports data structures
@@ -381,11 +374,7 @@ module internal ResultOrException =
val otherwise: f: (unit -> ResultOrException<'a>) -> x: ResultOrException<'a> -> ResultOrException<'a>
/// Generates unique stamps
-type internal UniqueStampGenerator<'T when 'T: equality
-#if !NO_CHECKNULLS
- and 'T:not null
-#endif
- > =
+type internal UniqueStampGenerator<'T when 'T: equality and 'T: not null> =
new: unit -> UniqueStampGenerator<'T>
@@ -394,11 +383,7 @@ type internal UniqueStampGenerator<'T when 'T: equality
member Table: ICollection<'T>
/// Memoize tables (all entries cached, never collected unless whole table is collected)
-type internal MemoizationTable<'T, 'U
-#if !NO_CHECKNULLS
- when 'T:not null
-#endif
- > =
+type internal MemoizationTable<'T, 'U when 'T: not null> =
new:
compute: ('T -> 'U) * keyComparer: IEqualityComparer<'T> * ?canMemoize: ('T -> bool) -> MemoizationTable<'T, 'U>
@@ -406,11 +391,7 @@ type internal MemoizationTable<'T, 'U
member Apply: x: 'T -> 'U
/// A thread-safe lookup table which is assigning an auto-increment stamp with each insert
-type internal StampedDictionary<'T, 'U
-#if !NO_CHECKNULLS
- when 'T:not null
-#endif
- > =
+type internal StampedDictionary<'T, 'U when 'T: not null> =
new: keyComparer: IEqualityComparer<'T> -> StampedDictionary<'T, 'U>
@@ -443,10 +424,10 @@ type internal LazyWithContext<'T, 'ctxt> =
/// Intern tables to save space.
module internal Tables =
- val memoize: f: ('a -> 'b) -> ('a -> 'b)
- when 'a: equality
-#if !NO_CHECKNULLS && NET8_0_OR_GREATER
- and 'a:not null
+#if NET8_0_OR_GREATER
+ val memoize: f: ('a -> 'b) -> ('a -> 'b) when 'a: equality and 'a: not null
+#else
+ val memoize: f: ('a -> 'b) -> ('a -> 'b) when 'a: equality
#endif
/// Interface that defines methods for comparing objects using partial equality relation
@@ -456,11 +437,9 @@ type internal IPartialEqualityComparer<'T> =
/// Interface that defines methods for comparing objects using partial equality relation
module internal IPartialEqualityComparer =
- val On: f: ('a -> 'b) -> c: IPartialEqualityComparer<'b> -> IPartialEqualityComparer<'a>
-#if !NO_CHECKNULLS
- when 'a:not null
- and 'a:not struct
-#endif
+ val On:
+ f: ('a -> 'b) -> c: IPartialEqualityComparer<'b> -> IPartialEqualityComparer<'a>
+ when 'a: not null and 'a: not struct
/// Like Seq.distinctBy but only filters out duplicates for some of the elements
val partialDistinctBy: per: IPartialEqualityComparer<'T> -> seq: 'T list -> 'T list
@@ -574,7 +553,7 @@ module internal MultiMap =
val initBy: f: ('a -> 'b) -> xs: seq<'a> -> MultiMap<'b, 'a> when 'b: comparison
- val ofList: xs: ('a * 'b) list -> MultiMap<'a,'b> when 'a: comparison
+ val ofList: xs: ('a * 'b) list -> MultiMap<'a, 'b> when 'a: comparison
type internal LayeredMap<'Key, 'Value when 'Key: comparison> = Map<'Key, 'Value>
diff --git a/src/Compiler/Utilities/lib.fsi b/src/Compiler/Utilities/lib.fsi
index ea0669bdf4a..1dfd610d55a 100644
--- a/src/Compiler/Utilities/lib.fsi
+++ b/src/Compiler/Utilities/lib.fsi
@@ -263,12 +263,7 @@ type DisposablesTracker =
new: unit -> DisposablesTracker
/// Register some items to dispose
- member Register: i:'a MaybeNull -> unit
- when 'a:>System.IDisposable
-#if !(NO_CHECKNULLS || BUILDING_WITH_LKG)
- and 'a:not null
-#endif
- and 'a:not struct
+ member Register: i: 'a MaybeNull -> unit when 'a :> System.IDisposable and 'a: not struct and 'a: not null
interface System.IDisposable
diff --git a/src/Compiler/Utilities/range.fsi b/src/Compiler/Utilities/range.fsi
index 40a52efa879..90deb76d976 100755
--- a/src/Compiler/Utilities/range.fsi
+++ b/src/Compiler/Utilities/range.fsi
@@ -6,7 +6,7 @@ namespace FSharp.Compiler.Text
open System.Collections.Generic
/// An index into a global tables of filenames
-type internal FileIndex = int32
+type internal FileIndex = int32
[]
type internal NotedSourceConstruct =
@@ -59,10 +59,10 @@ type Position =
/// Check if the position is adjacent to another position
member internal IsAdjacentTo: otherPos: Position -> bool
- /// Decode a position fro a 64-bit integer
+ /// Decode a position for a 64-bit integer
static member internal Decode: int64 -> pos
- /// The maximum number of bits needed to store an encoded position
+ /// The maximum number of bits needed to store an encoded position
static member internal EncodingSize: int
/// Represents a position in a file
@@ -105,7 +105,7 @@ type Range =
/// Synthetic marks ranges which are produced by intermediate compilation phases. This
/// bit signifies that the range covers something that should not be visible to language
/// service operations like dot-completion.
- member IsSynthetic: bool
+ member IsSynthetic: bool
/// Convert a range to be synthetic
member internal MakeSynthetic: unit -> range
@@ -122,13 +122,13 @@ type Range =
/// The range where all values are zero
static member Zero: range
-
+
/// Represents a range within a file
and range = Range
/// Represents a line number when using zero-based line counting (used by Visual Studio)
#if CHECK_LINE0_TYPES
-// Visual Studio uses line counts starting at 0, F# uses them starting at 1
+// Visual Studio uses line counts starting at 0, F# uses them starting at 1
[] type ZeroBasedLineAnnotation
type Line0 = int
@@ -158,7 +158,7 @@ module Position =
/// Compare positions for greater-than-or-equal-to
val posGeq: pos -> pos -> bool
- /// Convert a position from zero-based line counting (used by Visual Studio) to one-based line counting (used internally in the F# compiler and in F# error messages)
+ /// Convert a position from zero-based line counting (used by Visual Studio) to one-based line counting (used internally in the F# compiler and in F# error messages)
val fromZ: line:Line0 -> column:int -> pos
/// Convert a position from one-based line counting (used internally in the F# compiler and in F# error messages) to zero-based line counting (used by Visual Studio)
@@ -188,10 +188,10 @@ module Range =
/// Ordering on positions
val posOrder: IComparer
- /// This view of range marks uses file indexes explicitly
+ /// This view of range marks uses file indexes explicitly
val mkFileIndexRange: FileIndex -> pos -> pos -> range
- /// This view hides the use of file indexes and just uses filenames
+ /// This view hides the use of file indexes and just uses filenames
val mkRange: string -> pos -> pos -> range
/// Make a range for the first non-whitespace line of the file if any. Otherwise use line 1 chars 0-80.
@@ -211,21 +211,21 @@ module Range =
/// Union two ranges, taking their first occurring start position and last occurring end position
val unionRanges: range -> range -> range
-
+
// Create a new range with the given start and end positions
val withStartEnd: Position -> Position -> range -> range
-
+
// Create a new range with the given start position
val withStart: Position -> range -> range
-
+
// Create a new range with the given end position
val withEnd: Position -> range -> range
-
+
// Create a new range with the start position shifted by the given deltas
val shiftStart: int -> int -> range -> range
-
+
// Create a new range with the end position shifted by the given deltas
- val shiftEnd: int -> int -> range -> range
+ val shiftEnd: int -> int -> range -> range
/// Test to see if one range contains another range
val rangeContainsRange: range -> range -> bool
@@ -247,7 +247,7 @@ module Range =
/// A range associated with a dummy file for the command line arguments
val rangeCmdArgs: range
-
+
/// Convert a range to a string
val stringOfRange: range -> string
@@ -263,10 +263,8 @@ module Range =
/// Functions related to converting between lines indexed at 0 and 1
module Line =
- /// Convert a line number from zero-based line counting (used by Visual Studio) to one-based line counting (used internally in the F# compiler and in F# error messages)
+ /// Convert a line number from zero-based line counting (used by Visual Studio) to one-based line counting (used internally in the F# compiler and in F# error messages)
val fromZ: Line0 -> int
/// Convert a line number from one-based line counting (used internally in the F# compiler and in F# error messages) to zero-based line counting (used by Visual Studio)
- val toZ: int -> Line0
-
-
+ val toZ: int -> Line0
diff --git a/src/Compiler/Utilities/sformat.fs b/src/Compiler/Utilities/sformat.fs
index f6fc27b1e51..6ba5b68c462 100644
--- a/src/Compiler/Utilities/sformat.fs
+++ b/src/Compiler/Utilities/sformat.fs
@@ -122,13 +122,6 @@ type IEnvironment =
abstract MaxColumns: int
abstract MaxRows: int
-#if NO_CHECKNULLS
-[]
-module NullShim =
- // Shim to match nullness checking library support in preview
- let inline (|Null|NonNull|) (x: 'T) : Choice = match x with null -> Null | v -> NonNull v
-#endif
-
[]
module TaggedText =
let mkTag tag text = TaggedText(tag, text)
@@ -575,6 +568,7 @@ module ReflectUtils =
let GetValueInfo bindingFlags (x: 'a, ty: Type) (* x could be null *) =
let obj = (box x)
+
match obj with
| Null ->
let isNullaryUnion =
@@ -594,8 +588,7 @@ module ReflectUtils =
UnitValue
else
NullValue
- | NonNull obj ->
- GetValueInfoOfObject bindingFlags obj
+ | NonNull obj -> GetValueInfoOfObject bindingFlags obj
module Display =
open ReflectUtils
@@ -1014,6 +1007,7 @@ module Display =
and objL showMode depthLim prec (x: objnull, ty: Type) =
let info = Value.GetValueInfo bindingFlags (x, ty)
+
try
if depthLim <= 0 || exceededPrintSize () then
wordL (tagPunctuation "...")
@@ -1034,9 +1028,11 @@ module Display =
Some(wordL (tagText (x.ToString())))
else
// Try the StructuredFormatDisplayAttribute extensibility attribute
- match ty.GetCustomAttributes (typeof, true) with
- | Null | [| |] -> None
- | NonNull res -> structuredFormatObjectL showMode ty depthLim (res[0] :?> StructuredFormatDisplayAttribute) x
+ match ty.GetCustomAttributes(typeof, true) with
+ | Null
+ | [||] -> None
+ | NonNull res ->
+ structuredFormatObjectL showMode ty depthLim (res[0] :?> StructuredFormatDisplayAttribute) x
#if COMPILER
// This is the PrintIntercepts extensibility point currently revealed by fsi.exe's AddPrinter
@@ -1069,6 +1065,7 @@ module Display =
// Format an object that has a layout specified by StructuredFormatAttribute
and structuredFormatObjectL showMode ty depthLim (attr: StructuredFormatDisplayAttribute) (obj: obj) =
let txt = attr.Value
+
if isNull (box txt) || txt.Length <= 1 then
None
else
diff --git a/src/FSharp.Build/CreateFSharpManifestResourceName.fs b/src/FSharp.Build/CreateFSharpManifestResourceName.fs
index a19c9fada32..c39f7ae3da0 100644
--- a/src/FSharp.Build/CreateFSharpManifestResourceName.fs
+++ b/src/FSharp.Build/CreateFSharpManifestResourceName.fs
@@ -18,7 +18,7 @@ type CreateFSharpManifestResourceName public () =
linkFileName: string,
rootNamespace: string, // may be null
dependentUponFileName: string, // may be null
- binaryStream: Stream // may be null
+ _binaryStream: Stream // may be null
) : string =
// The Visual CSharp and XBuild CSharp toolchains transform resource names like this:
diff --git a/src/FSharp.Build/FSharp.Build.fsproj b/src/FSharp.Build/FSharp.Build.fsproj
index 3c392ef1158..8f2fd4f5951 100644
--- a/src/FSharp.Build/FSharp.Build.fsproj
+++ b/src/FSharp.Build/FSharp.Build.fsproj
@@ -9,11 +9,13 @@
FSharp.Build
$(NoWarn);75
true
- true
+ enable
$(DefineConstants);LOCALIZATION_FSBUILD
$(NoWarn);NU1701;FS0075
+
+ $(OtherFlags) --nowarn:3261
true
- 7.0
+ 9
Debug;Release;Proto
diff --git a/src/FSharp.Build/FSharpCommandLineBuilder.fs b/src/FSharp.Build/FSharpCommandLineBuilder.fs
index 51d7b12f1b7..a708f94fe87 100644
--- a/src/FSharp.Build/FSharpCommandLineBuilder.fs
+++ b/src/FSharp.Build/FSharpCommandLineBuilder.fs
@@ -15,21 +15,10 @@ do ()
// Shim to match nullness checking library support in preview
[]
module Utils =
-#if NO_CHECKNULLS
- /// Match on the nullness of an argument.
- let inline (|Null|NonNull|) (x: 'T) : Choice =
- match x with
- | null -> Null
- | v -> NonNull v
/// Indicates that a type may be null. 'MaybeNull' used internally in the F# compiler as unchecked
/// replacement for 'string?' for example for future FS-1060.
- type MaybeNull<'T when 'T : null> = 'T
-#else
- /// Indicates that a type may be null. 'MaybeNull' used internally in the F# compiler as unchecked
- /// replacement for 'string?' for example for future FS-1060.
- type MaybeNull<'T when 'T : not null and 'T : not struct> = 'T | null
-#endif
+ type MaybeNull<'T when 'T: not null and 'T: not struct> = 'T | null
type FSharpCommandLineBuilder() =
diff --git a/src/FSharp.Build/FSharpEmbedResourceText.fs b/src/FSharp.Build/FSharpEmbedResourceText.fs
index 3e3c79f82ee..1c5ffbfb68b 100644
--- a/src/FSharp.Build/FSharpEmbedResourceText.fs
+++ b/src/FSharp.Build/FSharpEmbedResourceText.fs
@@ -270,6 +270,9 @@ open Microsoft.FSharp.Collections
open Printf
#nowarn ""3262"" // The call to Option.ofObj below is applied in multiple compilation modes for GetString, sometimes the value is typed as a non-nullable string
+#if BUILDING_WITH_LKG
+#nowarn ""3261"" // Nullness warnings can happen due to LKG not having latest fixes
+#endif
"
let StringBoilerPlate fileName =
@@ -319,7 +322,7 @@ open Printf
// PERF: this technique is a bit slow (e.g. in simple cases, like 'sprintf ""%x""')
mkFunctionValue tys (fun inp -> impl rty inp)
- #if BUILDING_WITH_LKG || NO_NULLCHECKING_LIB_SUPPORT
+ #if !NULLABLE
static let capture1 (fmt:string) i args ty (go: obj list -> System.Type -> int -> obj) : obj =
#else
static let capture1 (fmt:string) i args ty (go: objnull list -> System.Type -> int -> obj) : obj =
@@ -345,7 +348,7 @@ open Printf
if i >= len || (fmt.[i] = '%' && i+1 >= len) then
let b = new System.Text.StringBuilder()
b.AppendFormat(messageString, [| for x in List.rev args -> x |]) |> ignore
- #if BUILDING_WITH_LKG || NO_NULLCHECKING_LIB_SUPPORT
+ #if !NULLABLE
box(b.ToString())
#else
box(b.ToString()) |> Unchecked.nonNull
@@ -444,7 +447,7 @@ open Printf
let lines =
File.ReadAllLines(fileName)
|> Array.mapi (fun i s -> i, s) // keep line numbers
- |> Array.filter (fun (i, s) -> not (s.StartsWith "#")) // filter out comments
+ |> Array.filter (fun (_i, s) -> not (s.StartsWith "#")) // filter out comments
printMessage "Parsing %s" fileName
let stringInfos = lines |> Array.map (fun (i, s) -> ParseLine fileName i s)
@@ -508,7 +511,7 @@ open Printf
printMessage "Generating resource methods for %s" outFileName
// gen each resource method
stringInfos
- |> Seq.iter (fun (lineNum, (optErrNum, ident), str, holes, netFormatString) ->
+ |> Seq.iter (fun (lineNum, (optErrNum, ident), str, holes, _netFormatString) ->
let formalArgs = new System.Text.StringBuilder()
let actualArgs = new System.Text.StringBuilder()
let mutable firstTime = true
@@ -586,7 +589,7 @@ open Printf
fprintfn outSignature " static member RunStartupValidation: unit -> unit"
stringInfos
- |> Seq.iter (fun (lineNum, (optErrNum, ident), str, holes, netFormatString) ->
+ |> Seq.iter (fun (_lineNum, (_optErrNum, ident), _str, _holes, _netFormatString) ->
fprintfn out " ignore(GetString(\"%s\"))" ident)
fprintfn out " ()" // in case there are 0 strings, we need the generated code to parse
@@ -595,7 +598,7 @@ open Printf
xd.LoadXml(xmlBoilerPlateString)
stringInfos
- |> Seq.iter (fun (lineNum, (optErrNum, ident), str, holes, netFormatString) ->
+ |> Seq.iter (fun (_lineNum, (_optErrNum, ident), _str, _holes, netFormatString) ->
let xn = xd.CreateElement("data")
xn.SetAttribute("name", ident) |> ignore
xn.SetAttribute("xml:space", "preserve") |> ignore
diff --git a/src/FSharp.Build/Fsc.fs b/src/FSharp.Build/Fsc.fs
index ccbece545d5..3cce873e722 100644
--- a/src/FSharp.Build/Fsc.fs
+++ b/src/FSharp.Build/Fsc.fs
@@ -69,7 +69,6 @@ type public Fsc() as this =
let mutable tailcalls: bool = true
let mutable targetProfile: string MaybeNull = null
let mutable targetType: string MaybeNull = null
- let mutable toolExe: string = "fsc.exe"
let defaultToolPath =
let locationOfThisDll =
@@ -733,8 +732,6 @@ type public Fsc() as this =
match host with
| null -> base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands)
| _ ->
- let sources = sources |> Array.map (fun i -> i.ItemSpec)
-
let invokeCompiler baseCallDelegate =
try
let ret =
@@ -765,7 +762,7 @@ type public Fsc() as this =
->
fsc.Log.LogError(tie.InnerException.Message, [||])
-1
- | e -> reraise ()
+ | _ -> reraise ()
let baseCallDelegate =
Func(fun () -> fsc.BaseExecuteTool(pathToTool, responseFileCommands, commandLineCommands))
diff --git a/src/FSharp.Build/Fsi.fs b/src/FSharp.Build/Fsi.fs
index a8ad12d1b2c..88a6dbf3adb 100644
--- a/src/FSharp.Build/Fsi.fs
+++ b/src/FSharp.Build/Fsi.fs
@@ -37,15 +37,12 @@ type public Fsi() as this =
let mutable provideCommandLineArgs = false
let mutable references: ITaskItem[] = [||]
let mutable referencePath: string MaybeNull = null
- let mutable resources: ITaskItem[] = [||]
let mutable skipCompilerExecution = false
let mutable sources: ITaskItem[] = [||]
let mutable loadSources: ITaskItem[] = [||]
let mutable useSources: ITaskItem[] = [||]
let mutable tailcalls: bool = true
let mutable targetProfile: string MaybeNull = null
- let mutable targetType: string MaybeNull = null
- let mutable toolExe: string = "fsi.exe"
let mutable toolPath: string =
let locationOfThisDll =
diff --git a/src/FSharp.Build/MapSourceRoots.fs b/src/FSharp.Build/MapSourceRoots.fs
index c2131209dad..8ea92c02197 100644
--- a/src/FSharp.Build/MapSourceRoots.fs
+++ b/src/FSharp.Build/MapSourceRoots.fs
@@ -130,7 +130,7 @@ type MapSourceRoots() =
for root in mappedSourceRoots do
match root.GetMetadata SourceControl with
- | HasValue v when isSourceControlled -> mapNestedRootIfEmpty root
+ | HasValue _ when isSourceControlled -> mapNestedRootIfEmpty root
| NullOrEmpty when not isSourceControlled -> mapNestedRootIfEmpty root
| _ -> ()
diff --git a/src/FSharp.Build/Microsoft.FSharp.NetSdk.props b/src/FSharp.Build/Microsoft.FSharp.NetSdk.props
index 38d83cd8ab4..e45f864ce22 100644
--- a/src/FSharp.Build/Microsoft.FSharp.NetSdk.props
+++ b/src/FSharp.Build/Microsoft.FSharp.NetSdk.props
@@ -94,7 +94,7 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
- 4.4.0
+ 4.6.1
diff --git a/src/FSharp.Core/array.fs b/src/FSharp.Core/array.fs
index 27c6d6426b6..ca88e22465d 100644
--- a/src/FSharp.Core/array.fs
+++ b/src/FSharp.Core/array.fs
@@ -836,21 +836,13 @@ module Array =
count
-#if BUILDING_WITH_LKG || NO_NULLCHECKING_LIB_SUPPORT
- let private createMask<'a>
- (f: 'a -> bool)
- (src: 'a array)
- (maskArrayOut: byref)
- (leftoverMaskOut: byref)
- =
-#else
let private createMask<'a>
(f: 'a -> bool)
(src: array<'a>)
(maskArrayOut: byref | null>)
(leftoverMaskOut: byref)
=
-#endif
+
let maskArrayLength = src.Length / 0x20
// null when there are less than 32 items in src array.
@@ -1040,11 +1032,8 @@ module Array =
dstIdx
-#if BUILDING_WITH_LKG || NO_NULLCHECKING_LIB_SUPPORT
- let private filterViaMask (maskArray: uint32 array) (leftoverMask: uint32) (count: int) (src: _ array) =
-#else
let private filterViaMask (maskArray: uint32 array | null) (leftoverMask: uint32) (count: int) (src: _ array) =
-#endif
+
let dst = Microsoft.FSharp.Primitives.Basics.Array.zeroCreateUnchecked count
let mutable dstIdx = 0
@@ -2196,14 +2185,20 @@ module Array =
[]
let tryFindIndex predicate (array: _ array) =
let i = tryFindIndexAux predicate array
- if i.HasValue then Some (int (i.GetValueOrDefault()))
- else None
+
+ if i.HasValue then
+ Some(int (i.GetValueOrDefault()))
+ else
+ None
[]
let tryFind predicate (array: _ array) =
let i = tryFindIndexAux predicate array
- if i.HasValue then Some array[int (i.GetValueOrDefault())]
- else None
+
+ if i.HasValue then
+ Some array[int (i.GetValueOrDefault())]
+ else
+ None
[]
let tryPick chooser (array: _ array) =
@@ -2222,8 +2217,10 @@ module Array =
pState.Break())
)
- if pResult.LowestBreakIteration.HasValue then allChosen[int (pResult.LowestBreakIteration.GetValueOrDefault())]
- else None
+ if pResult.LowestBreakIteration.HasValue then
+ allChosen[int (pResult.LowestBreakIteration.GetValueOrDefault())]
+ else
+ None
[]
let choose chooser (array: 'T array) =
diff --git a/src/FSharp.Core/fslib-extra-pervasives.fs b/src/FSharp.Core/fslib-extra-pervasives.fs
index c0b0bc05a04..07a03675937 100644
--- a/src/FSharp.Core/fslib-extra-pervasives.fs
+++ b/src/FSharp.Core/fslib-extra-pervasives.fs
@@ -347,21 +347,15 @@ open Microsoft.FSharp.Quotations
/// Represents the product of two measure expressions when returned as a generic argument of a provided type.
[]
-type MeasureProduct<'Measure1, 'Measure2>() =
- class
- end
+type MeasureProduct<'Measure1, 'Measure2>() = class end
/// Represents the inverse of a measure expressions when returned as a generic argument of a provided type.
[]
-type MeasureInverse<'Measure> =
- class
- end
+type MeasureInverse<'Measure> = class end
/// Represents the '1' measure expression when returned as a generic argument of a provided type.
[]
-type MeasureOne =
- class
- end
+type MeasureOne = class end
[]
type TypeProviderAttribute() =
@@ -473,7 +467,7 @@ type IProvidedNamespace =
abstract GetTypes: unit -> Type array
- abstract ResolveTypeName: typeName: string -> (Type|null)
+ abstract ResolveTypeName: typeName: string -> (Type | null)
type ITypeProvider =
inherit System.IDisposable
diff --git a/src/FSharp.Core/local.fs b/src/FSharp.Core/local.fs
index 206ccf4ee3d..a1c9c2fa644 100644
--- a/src/FSharp.Core/local.fs
+++ b/src/FSharp.Core/local.fs
@@ -1090,11 +1090,8 @@ module internal Array =
if array.Length > 1 then
Array.Sort<_>(array, fastComparerForArraySort())
-#if BUILDING_WITH_LKG || NO_NULLCHECKING_LIB_SUPPORT
- let stableSortWithKeysAndComparer (cFast:IComparer<'Key>) (c:IComparer<'Key>) (array:'T array) (keys: 'Key array) =
-#else
let stableSortWithKeysAndComparer (cFast:IComparer<'Key> | null) (c:IComparer<'Key>) (array:array<'T>) (keys:array<'Key>) =
-#endif
+
// 'places' is an array or integers storing the permutation performed by the sort
let len = array.Length
let places = zeroCreateUnchecked len
diff --git a/src/FSharp.Core/option.fs b/src/FSharp.Core/option.fs
index 1b29141df64..ea5da774d87 100644
--- a/src/FSharp.Core/option.fs
+++ b/src/FSharp.Core/option.fs
@@ -148,35 +148,21 @@ module Option =
[]
let inline ofNullable (value: System.Nullable<'T>) =
if value.HasValue then
- Some (value.GetValueOrDefault())
+ Some(value.GetValueOrDefault())
else
None
-#if BUILDING_WITH_LKG || NO_NULLCHECKING_LIB_SUPPORT
[]
- let inline ofObj value =
+ let inline ofObj (value: 'T | null) : 'T option when 'T: not struct and 'T: not null =
match value with
| null -> None
| _ -> Some value
[]
- let inline toObj value =
+ let inline toObj (value: 'T option) : 'T | null when 'T: not struct =
match value with
| None -> null
| Some x -> x
-#else
- []
- let inline ofObj (value: 'T | null) : 'T option when 'T: not struct and 'T : not null =
- match value with
- | null -> None
- | _ -> Some value
-
- []
- let inline toObj (value: 'T option) : 'T | null when 'T: not struct (* and 'T : not null *) =
- match value with
- | None -> null
- | Some x -> x
-#endif
[]
let inline ofValueOption (voption: 'T voption) =
@@ -338,35 +324,21 @@ module ValueOption =
[]
let inline ofNullable (value: System.Nullable<'T>) =
if value.HasValue then
- ValueSome (value.GetValueOrDefault())
+ ValueSome(value.GetValueOrDefault())
else
ValueNone
-#if BUILDING_WITH_LKG || NO_NULLCHECKING_LIB_SUPPORT
[]
- let inline ofObj value =
- match value with
- | null -> ValueNone
- | _ -> ValueSome value
-
- []
- let inline toObj value =
- match value with
- | ValueNone -> null
- | ValueSome x -> x
-#else
- []
- let inline ofObj (value: 'T | null) : 'T voption when 'T: not struct and 'T : not null =
+ let inline ofObj (value: 'T | null) : 'T voption when 'T: not struct and 'T: not null =
match value with
| null -> ValueNone
| _ -> ValueSome value
[]
- let inline toObj (value : 'T voption) : 'T | null when 'T: not struct (* and 'T : not null *) =
+ let inline toObj (value: 'T voption) : 'T | null when 'T: not struct =
match value with
| ValueNone -> null
| ValueSome x -> x
-#endif
[]
let inline ofOption (option: 'T option) =
diff --git a/src/FSharp.Core/option.fsi b/src/FSharp.Core/option.fsi
index 57adb485cb4..db381aec8ad 100644
--- a/src/FSharp.Core/option.fsi
+++ b/src/FSharp.Core/option.fsi
@@ -440,13 +440,8 @@ module Option =
///
///
[]
-#if BUILDING_WITH_LKG || NO_NULLCHECKING_LIB_SUPPORT
- val inline ofObj: value: 'T -> 'T option when 'T : null
-#else
- // TODO NULLNESS: assess this change - is it a breaking change?
- []
- val inline ofObj: value: 'T | null -> 'T option when 'T : not null and 'T : not struct
-#endif
+ []
+ val inline ofObj: value: 'T | null -> 'T option when 'T: not null and 'T: not struct
/// Convert an option to a potentially null value.
///
@@ -461,12 +456,7 @@ module Option =
///
///
[]
-#if BUILDING_WITH_LKG || NO_NULLCHECKING_LIB_SUPPORT
- val inline toObj: value: 'T option -> 'T when 'T : null
-#else
- // TODO NULLNESS: assess this change - is it a breaking change?
- val inline toObj: value: 'T option -> 'T | null when 'T : not struct (* and 'T : not null *)
-#endif
+ val inline toObj: value: 'T option -> 'T | null when 'T: not struct
/// Convert a value option to an option.
///
@@ -929,13 +919,8 @@ module ValueOption =
///
///
[]
-#if BUILDING_WITH_LKG || NO_NULLCHECKING_LIB_SUPPORT
- val inline ofObj: value: 'T -> 'T voption when 'T : null
-#else
- // TODO NULLNESS: assess this change - is it a breaking change?
- []
- val inline ofObj: value: 'T | null -> 'T voption when 'T : not struct and 'T : not null
-#endif
+ []
+ val inline ofObj: value: 'T | null -> 'T voption when 'T: not struct and 'T: not null
/// Convert an option to a potentially null value.
///
@@ -950,12 +935,7 @@ module ValueOption =
///
///
[]
-#if BUILDING_WITH_LKG || NO_NULLCHECKING_LIB_SUPPORT
- val inline toObj: value: 'T voption -> 'T when 'T : null
-#else
- // TODO NULLNESS: assess this change - is it a breaking change?
- val inline toObj: value: 'T voption -> 'T | null when 'T : not struct (* and 'T : not null *)
-#endif
+ val inline toObj: value: 'T voption -> 'T | null when 'T: not struct
/// Convert an option to a value option.
///
diff --git a/src/FSharp.Core/prim-types-prelude.fs b/src/FSharp.Core/prim-types-prelude.fs
index 12ed91cfba2..f8797339628 100644
--- a/src/FSharp.Core/prim-types-prelude.fs
+++ b/src/FSharp.Core/prim-types-prelude.fs
@@ -6,11 +6,7 @@ namespace Microsoft.FSharp.Core
// Basic type abbreviations
type obj = System.Object
-#if BUILDING_WITH_LKG || NO_NULLCHECKING_LIB_SUPPORT
- type objnull = obj
-#else
type objnull = obj | null
-#endif
type exn = System.Exception
type nativeint = System.IntPtr
type unativeint = System.UIntPtr
diff --git a/src/FSharp.Core/prim-types-prelude.fsi b/src/FSharp.Core/prim-types-prelude.fsi
index 8cc0515350d..a32ccdbf105 100644
--- a/src/FSharp.Core/prim-types-prelude.fsi
+++ b/src/FSharp.Core/prim-types-prelude.fsi
@@ -22,11 +22,7 @@ namespace Microsoft.FSharp.Core
/// With the 'nullable reference types' feature, this is an alias to 'obj | null'.
///
/// Basic Types
-#if BUILDING_WITH_LKG || NO_NULLCHECKING_LIB_SUPPORT
- type objnull = obj
-#else
type objnull = obj | null
-#endif
/// An abbreviation for the CLI type .
///
diff --git a/src/FSharp.Core/prim-types.fs b/src/FSharp.Core/prim-types.fs
index 4f4849eb849..d9a7e41bf55 100644
--- a/src/FSharp.Core/prim-types.fs
+++ b/src/FSharp.Core/prim-types.fs
@@ -739,11 +739,8 @@ namespace Microsoft.FSharp.Core
let inline TypeTestFast<'T>(source: objnull) =
//assert not(TypeInfo<'T>.TypeInfo = TypeNullnessSemantics_NullTrueValue)
notnullPrim(isinstPrim<'T>(source))
-#if !BUILDING_WITH_LKG && !NO_NULLCHECKING_LIB_SUPPORT
+
let Dispose<'T when 'T :> IDisposable >(resource:'T|null) =
-#else
- let Dispose<'T when 'T :> IDisposable >(resource:'T) =
-#endif
match box resource with
| null -> ()
| _ -> resource.Dispose()
@@ -4419,8 +4416,6 @@ namespace Microsoft.FSharp.Core
| null -> false
| _ -> true
-#if !BUILDING_WITH_LKG && !NO_NULLCHECKING_LIB_SUPPORT
-
[]
let inline isNullV (value : Nullable<'T>) = not value.HasValue
@@ -4473,13 +4468,6 @@ namespace Microsoft.FSharp.Core
match value with
| null -> raise (new ArgumentNullException(argumentName))
| _ -> (# "" value : 'T #)
-#else
- []
- let inline (|Null|NonNull|) (value : 'T) : Choice when 'T : null and 'T : not struct =
- match value with
- | null -> Null ()
- | _ -> NonNull (# "" value : 'T #)
-#endif
[]
let inline raise (exn: exn) =
@@ -4573,7 +4561,6 @@ namespace Microsoft.FSharp.Core
[]
let defaultValueArg arg defaultValue = match arg with ValueNone -> defaultValue | ValueSome v -> v
-#if !BUILDING_WITH_LKG && !NO_NULLCHECKING_LIB_SUPPORT
[]
let inline defaultIfNull defaultValue (arg: 'T | null when 'T : not null and 'T : not struct) =
match arg with null -> defaultValue | _ -> (# "" arg : 'T #)
@@ -4581,7 +4568,6 @@ namespace Microsoft.FSharp.Core
[]
let inline defaultIfNullV defaultValue (arg: Nullable<'T>) =
if arg.HasValue then arg.Value else defaultValue
-#endif
[]
let inline (~-) (n: ^T) : ^T =
@@ -5527,24 +5513,12 @@ namespace Microsoft.FSharp.Core
[]
let inline hash x = GenericHash x
- #if !BUILDING_WITH_LKG && !NO_NULLCHECKING_LIB_SUPPORT
-
[]
let inline nonNull (x: 'T | null when 'T : not null and 'T : not struct) : 'T = (# "" x : 'T #)
[]
let inline (|NonNullQuick|) (value : 'T | null when 'T : not null and 'T : not struct) = nonNull value
- #else
-
- []
- let inline nonNull (x: 'T ) : 'T = x
-
- []
- let inline (|NonNullQuick|) (value) = nonNull value
-
- #endif
-
module Checked =
let inline (+) (x: ^T) (y: ^U) : ^V =
diff --git a/src/FSharp.Core/prim-types.fsi b/src/FSharp.Core/prim-types.fsi
index c56fe5375e4..7c2f171a600 100644
--- a/src/FSharp.Core/prim-types.fsi
+++ b/src/FSharp.Core/prim-types.fsi
@@ -1391,11 +1391,8 @@ namespace Microsoft.FSharp.Core
val inline FastGenericComparer<'T> : System.Collections.Generic.IComparer<'T> when 'T: comparison
/// Make an F# comparer object for the given type, where it can be null if System.Collections.Generic.Comparer<'T>.Default
-#if BUILDING_WITH_LKG || NO_NULLCHECKING_LIB_SUPPORT
- val internal FastGenericComparerCanBeNull<'T> : System.Collections.Generic.IComparer<'T> when 'T : comparison
-#else
val internal FastGenericComparerCanBeNull<'T> : System.Collections.Generic.IComparer<'T> | null when 'T : comparison
-#endif
+
/// Make an F# hash/equality object for the given type
val inline FastGenericEqualityComparer<'T> : System.Collections.Generic.IEqualityComparer<'T> when 'T: equality
@@ -1796,11 +1793,8 @@ namespace Microsoft.FSharp.Core
/// A compiler intrinsic for the efficient compilation of sequence expressions
[]
-#if !BUILDING_WITH_LKG && !NO_NULLCHECKING_LIB_SUPPORT
val Dispose<'T when 'T :> System.IDisposable> : resource: 'T|null -> unit
-#else
- val Dispose<'T when 'T :> System.IDisposable> : resource: 'T -> unit
-#endif
+
/// A compiler intrinsic for checking initialization soundness of recursive bindings
[]
@@ -3206,7 +3200,6 @@ namespace Microsoft.FSharp.Core
///
val inline (<|||): func: ('T1 -> 'T2 -> 'T3 -> 'U) -> arg1: 'T1 * arg2: 'T2 * arg3: 'T3 -> 'U
-#if !BUILDING_WITH_LKG && !NO_NULLCHECKING_LIB_SUPPORT
/// Used to specify a default value for a nullable reference argument in the implementation of a function
/// The default value of the argument.
/// A nullable value representing the argument.
@@ -3220,7 +3213,6 @@ namespace Microsoft.FSharp.Core
/// The argument value. If it is null, the defaultValue is returned.
[]
val inline defaultIfNullV : defaultValue:'T -> arg:Nullable<'T> -> 'T
-#endif
/// Used to specify a default value for an optional argument in the implementation of a function
///
@@ -3519,7 +3511,6 @@ namespace Microsoft.FSharp.Core
[]
val inline isNull: value: 'T -> bool when 'T: null
-#if !BUILDING_WITH_LKG && !NO_NULLCHECKING_LIB_SUPPORT
/// Determines whether the given value is null.
/// The value to check.
/// A choice indicating whether the value is null or not-null.
@@ -3554,13 +3545,6 @@ namespace Microsoft.FSharp.Core
/// True when value is null, false otherwise.
[]
val inline isNullV : value:Nullable<'T> -> bool
-#else
- /// Determines whether the given value is null.
- /// The value to check.
- /// A choice indicating whether the value is null or not-null.
- []
- val inline (|Null|NonNull|) : value: 'T -> Choice when 'T : null and 'T : not struct
-#endif
/// Determines whether the given value is not null.
///
@@ -3570,7 +3554,6 @@ namespace Microsoft.FSharp.Core
[]
val inline internal isNotNull: value:'T -> bool when 'T : null
-#if !BUILDING_WITH_LKG && !NO_NULLCHECKING_LIB_SUPPORT
/// Get the null value for a value type.
/// In a future revision of nullness support this may be unified with 'null'.
/// The null value for a value type.
@@ -3603,7 +3586,6 @@ namespace Microsoft.FSharp.Core
/// System.Nullable wrapper of the input argument.
[]
val inline withNullV : value:'T -> Nullable<'T>
-#endif
/// Throw a exception.
///
@@ -3669,7 +3651,6 @@ namespace Microsoft.FSharp.Core
[]
val inline nullArg: argumentName: string -> 'T
-#if !BUILDING_WITH_LKG && !NO_NULLCHECKING_LIB_SUPPORT
/// Throw a System.ArgumentNullException if the given value is null exception
///
/// The argument name.
@@ -3677,7 +3658,6 @@ namespace Microsoft.FSharp.Core
/// The result value.
[]
val inline nullArgCheck : argumentName:string -> 'T | null -> 'T when 'T : not null and 'T : not struct
-#endif
/// Throw a exception
///
@@ -5812,21 +5792,13 @@ namespace Microsoft.FSharp.Core
/// The possibly nullable value.
/// The same value as in the input.
[]
- #if !BUILDING_WITH_LKG && !NO_NULLCHECKING_LIB_SUPPORT
val inline nonNull : value: 'T | null -> 'T when 'T : not null and 'T : not struct
- #else
- val inline nonNull : value: 'T -> 'T
- #endif
/// When used in a pattern forgets 'nullness' of the value without any runtime check. This is an unsafe operation, as null check is being skipped and null value can be returned.
/// The value to retype from ('T | null) to 'T .
/// The non-null value.
[]
- #if !BUILDING_WITH_LKG && !NO_NULLCHECKING_LIB_SUPPORT
val inline (|NonNullQuick|) : value: 'T | null -> 'T when 'T : not null and 'T : not struct
- #else
- val inline (|NonNullQuick|) : value: 'T -> 'T
- #endif
/// A module of comparison and equality operators that are statically resolved, but which are not fully generic and do not make structural comparison. Opening this
/// module may make code that relies on structural or generic comparison no longer compile.
diff --git a/src/FSharp.Core/resumable.fs b/src/FSharp.Core/resumable.fs
index 1488ab220cf..9e24b64bffc 100644
--- a/src/FSharp.Core/resumable.fs
+++ b/src/FSharp.Core/resumable.fs
@@ -131,11 +131,8 @@ module ResumableCode =
/// Note that this requires that the first step has no result.
/// This prevents constructs like `task { return 1; return 2; }`.
let CombineDynamic
- (
- sm: byref>,
- code1: ResumableCode<'Data, unit>,
- code2: ResumableCode<'Data, 'T>
- ) : bool =
+ (sm: byref>, code1: ResumableCode<'Data, unit>, code2: ResumableCode<'Data, 'T>)
+ : bool =
if code1.Invoke(&sm) then
code2.Invoke(&sm)
else
@@ -170,11 +167,8 @@ module ResumableCode =
CombineDynamic(&sm, code1, code2))
let rec WhileDynamic
- (
- sm: byref>,
- condition: unit -> bool,
- body: ResumableCode<'Data, unit>
- ) : bool =
+ (sm: byref>, condition: unit -> bool, body: ResumableCode<'Data, unit>)
+ : bool =
if condition () then
if body.Invoke(&sm) then
WhileDynamic(&sm, condition, body)
@@ -207,10 +201,8 @@ module ResumableCode =
/// Builds a step that executes the body while the condition predicate is true.
let inline While
- (
- [] condition: unit -> bool,
- body: ResumableCode<'Data, unit>
- ) : ResumableCode<'Data, unit> =
+ ([] condition: unit -> bool, body: ResumableCode<'Data, unit>)
+ : ResumableCode<'Data, unit> =
ResumableCode<'Data, unit>(fun sm ->
if __useResumableCode then
//-- RESUMABLE CODE START
@@ -252,10 +244,8 @@ module ResumableCode =
/// Wraps a step in a try/with. This catches exceptions both in the evaluation of the function
/// to retrieve the step, and in the continuation of the step (if any).
let inline TryWith
- (
- body: ResumableCode<'Data, 'T>,
- catch: exn -> ResumableCode<'Data, 'T>
- ) : ResumableCode<'Data, 'T> =
+ (body: ResumableCode<'Data, 'T>, catch: exn -> ResumableCode<'Data, 'T>)
+ : ResumableCode<'Data, 'T> =
ResumableCode<'Data, 'T>(fun sm ->
if __useResumableCode then
//-- RESUMABLE CODE START
@@ -283,11 +273,8 @@ module ResumableCode =
TryWithDynamic(&sm, body, catch))
let rec TryFinallyCompensateDynamic
- (
- sm: byref>,
- mf: ResumptionFunc<'Data>,
- savedExn: exn option
- ) : bool =
+ (sm: byref>, mf: ResumptionFunc<'Data>, savedExn: exn option)
+ : bool =
let mutable fin = false
fin <- mf.Invoke(&sm)
@@ -362,10 +349,8 @@ module ResumableCode =
/// Wraps a step in a try/finally. This catches exceptions both in the evaluation of the function
/// to retrieve the step, and in the continuation of the step (if any).
let inline TryFinallyAsync
- (
- body: ResumableCode<'Data, 'T>,
- compensation: ResumableCode<'Data, unit>
- ) : ResumableCode<'Data, 'T> =
+ (body: ResumableCode<'Data, 'T>, compensation: ResumableCode<'Data, unit>)
+ : ResumableCode<'Data, 'T> =
ResumableCode<'Data, 'T>(fun sm ->
if __useResumableCode then
//-- RESUMABLE CODE START
@@ -396,10 +381,8 @@ module ResumableCode =
TryFinallyAsyncDynamic(&sm, body, compensation))
let inline Using
- (
- resource: 'Resource,
- body: 'Resource -> ResumableCode<'Data, 'T>
- ) : ResumableCode<'Data, 'T> when 'Resource :> IDisposable|null =
+ (resource: 'Resource, body: 'Resource -> ResumableCode<'Data, 'T>)
+ : ResumableCode<'Data, 'T> when 'Resource :> IDisposable | null =
// A using statement is just a try/finally with the finally block disposing if non-null.
TryFinally(
ResumableCode<'Data, 'T>(fun sm -> (body resource).Invoke(&sm)),
diff --git a/src/FSharp.Core/string.fsi b/src/FSharp.Core/string.fsi
index e7c6ef062ad..9178af3fcf9 100644
--- a/src/FSharp.Core/string.fsi
+++ b/src/FSharp.Core/string.fsi
@@ -139,7 +139,7 @@ module String =
[]
val forall: predicate: (char -> bool) -> str: string -> bool
- /// Builds a new string whose characters are the results of applying the function mapping
+ /// Builds a new string whose characters are the results of applying the function initializer
/// to each index from 0 to count-1 and concatenating the resulting
/// strings.
///
diff --git a/src/FSharp.Core/tasks.fs b/src/FSharp.Core/tasks.fs
index dfe7f4ba624..687bae5af85 100644
--- a/src/FSharp.Core/tasks.fs
+++ b/src/FSharp.Core/tasks.fs
@@ -58,36 +58,28 @@ type TaskBuilderBase() =
/// Note that this requires that the first step has no result.
/// This prevents constructs like `task { return 1; return 2; }`.
member inline _.Combine
- (
- task1: TaskCode<'TOverall, unit>,
- task2: TaskCode<'TOverall, 'T>
- ) : TaskCode<'TOverall, 'T> =
+ (task1: TaskCode<'TOverall, unit>, task2: TaskCode<'TOverall, 'T>)
+ : TaskCode<'TOverall, 'T> =
ResumableCode.Combine(task1, task2)
/// Builds a step that executes the body while the condition predicate is true.
member inline _.While
- (
- [] condition: unit -> bool,
- body: TaskCode<'TOverall, unit>
- ) : TaskCode<'TOverall, unit> =
+ ([] condition: unit -> bool, body: TaskCode<'TOverall, unit>)
+ : TaskCode<'TOverall, unit> =
ResumableCode.While(condition, body)
/// Wraps a step in a try/with. This catches exceptions both in the evaluation of the function
/// to retrieve the step, and in the continuation of the step (if any).
member inline _.TryWith
- (
- body: TaskCode<'TOverall, 'T>,
- catch: exn -> TaskCode<'TOverall, 'T>
- ) : TaskCode<'TOverall, 'T> =
+ (body: TaskCode<'TOverall, 'T>, catch: exn -> TaskCode<'TOverall, 'T>)
+ : TaskCode<'TOverall, 'T> =
ResumableCode.TryWith(body, catch)
/// Wraps a step in a try/finally. This catches exceptions both in the evaluation of the function
/// to retrieve the step, and in the continuation of the step (if any).
member inline _.TryFinally
- (
- body: TaskCode<'TOverall, 'T>,
- [] compensation: unit -> unit
- ) : TaskCode<'TOverall, 'T> =
+ (body: TaskCode<'TOverall, 'T>, [] compensation: unit -> unit)
+ : TaskCode<'TOverall, 'T> =
ResumableCode.TryFinally(
body,
ResumableCode<_, _>(fun _sm ->
@@ -100,10 +92,8 @@ type TaskBuilderBase() =
#if NETSTANDARD2_1
member inline internal this.TryFinallyAsync
- (
- body: TaskCode<'TOverall, 'T>,
- compensation: unit -> ValueTask
- ) : TaskCode<'TOverall, 'T> =
+ (body: TaskCode<'TOverall, 'T>, compensation: unit -> ValueTask)
+ : TaskCode<'TOverall, 'T> =
ResumableCode.TryFinallyAsync(
body,
ResumableCode<_, _>(fun sm ->
@@ -138,11 +128,9 @@ type TaskBuilderBase() =
false)
)
- member inline this.Using<'Resource, 'TOverall, 'T when 'Resource :> IAsyncDisposable|null>
- (
- resource: 'Resource,
- body: 'Resource -> TaskCode<'TOverall, 'T>
- ) : TaskCode<'TOverall, 'T> =
+ member inline this.Using<'Resource, 'TOverall, 'T when 'Resource :> IAsyncDisposable | null>
+ (resource: 'Resource, body: 'Resource -> TaskCode<'TOverall, 'T>)
+ : TaskCode<'TOverall, 'T> =
this.TryFinallyAsync(
(fun sm -> (body resource).Invoke(&sm)),
(fun () ->
@@ -310,11 +298,8 @@ module LowPriority =
and ^Awaiter :> ICriticalNotifyCompletion
and ^Awaiter: (member get_IsCompleted: unit -> bool)
and ^Awaiter: (member GetResult: unit -> 'TResult1)>
- (
- sm: byref<_>,
- task: ^TaskLike,
- continuation: ('TResult1 -> TaskCode<'TOverall, 'TResult2>)
- ) : bool =
+ (sm: byref<_>, task: ^TaskLike, continuation: ('TResult1 -> TaskCode<'TOverall, 'TResult2>))
+ : bool =
let mutable awaiter = (^TaskLike: (member GetAwaiter: unit -> ^Awaiter) (task))
@@ -337,10 +322,8 @@ module LowPriority =
and ^Awaiter :> ICriticalNotifyCompletion
and ^Awaiter: (member get_IsCompleted: unit -> bool)
and ^Awaiter: (member GetResult: unit -> 'TResult1)>
- (
- task: ^TaskLike,
- continuation: ('TResult1 -> TaskCode<'TOverall, 'TResult2>)
- ) : TaskCode<'TOverall, 'TResult2> =
+ (task: ^TaskLike, continuation: ('TResult1 -> TaskCode<'TOverall, 'TResult2>))
+ : TaskCode<'TOverall, 'TResult2> =
TaskCode<'TOverall, _>(fun sm ->
if __useResumableCode then
@@ -382,11 +365,9 @@ module LowPriority =
this.Bind(task, this.Return)
- member inline _.Using<'Resource, 'TOverall, 'T when 'Resource :> IDisposable|null>
- (
- resource: 'Resource,
- body: 'Resource -> TaskCode<'TOverall, 'T>
- ) =
+ member inline _.Using<'Resource, 'TOverall, 'T when 'Resource :> IDisposable | null>
+ (resource: 'Resource, body: 'Resource -> TaskCode<'TOverall, 'T>)
+ =
ResumableCode.Using(resource, body)
module HighPriority =
@@ -394,11 +375,8 @@ module HighPriority =
type TaskBuilderBase with
static member BindDynamic
- (
- sm: byref<_>,
- task: Task<'TResult1>,
- continuation: ('TResult1 -> TaskCode<'TOverall, 'TResult2>)
- ) : bool =
+ (sm: byref<_>, task: Task<'TResult1>, continuation: ('TResult1 -> TaskCode<'TOverall, 'TResult2>))
+ : bool =
let mutable awaiter = task.GetAwaiter()
let cont =
@@ -415,10 +393,8 @@ module HighPriority =
false
member inline _.Bind
- (
- task: Task<'TResult1>,
- continuation: ('TResult1 -> TaskCode<'TOverall, 'TResult2>)
- ) : TaskCode<'TOverall, 'TResult2> =
+ (task: Task<'TResult1>, continuation: ('TResult1 -> TaskCode<'TOverall, 'TResult2>))
+ : TaskCode<'TOverall, 'TResult2> =
TaskCode<'TOverall, _>(fun sm ->
if __useResumableCode then
@@ -455,10 +431,8 @@ module MediumPriority =
type TaskBuilderBase with
member inline this.Bind
- (
- computation: Async<'TResult1>,
- continuation: ('TResult1 -> TaskCode<'TOverall, 'TResult2>)
- ) : TaskCode<'TOverall, 'TResult2> =
+ (computation: Async<'TResult1>, continuation: ('TResult1 -> TaskCode<'TOverall, 'TResult2>))
+ : TaskCode<'TOverall, 'TResult2> =
this.Bind(Async.StartImmediateAsTask computation, continuation)
member inline this.ReturnFrom(computation: Async<'T>) : TaskCode<'T, 'T> =
diff --git a/src/FSharp.Core/tasks.fsi b/src/FSharp.Core/tasks.fsi
index c626cb4bb7b..e6c801351a1 100644
--- a/src/FSharp.Core/tasks.fsi
+++ b/src/FSharp.Core/tasks.fsi
@@ -237,7 +237,7 @@ module LowPriority =
///
member inline Using:
resource: 'Resource * body: ('Resource -> TaskCode<'TOverall, 'T>) -> TaskCode<'TOverall, 'T>
- when 'Resource :> IDisposable|null
+ when 'Resource :> IDisposable | null
///
/// Contains medium-priority overloads for the `task` computation expression builder.
diff --git a/src/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.Nuget.fsproj b/src/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.Nuget.fsproj
index 4700c172f52..96e318d282c 100644
--- a/src/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.Nuget.fsproj
+++ b/src/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.Nuget.fsproj
@@ -8,7 +8,6 @@
FSharp.DependencyManager.Nuget
true
$(DefineConstants);COMPILER
- $(OtherFlags) --warnon:1182
true
Debug;Release
diff --git a/src/fsi/console.fs b/src/fsi/console.fs
index d644180d384..1d495d0cd48 100644
--- a/src/fsi/console.fs
+++ b/src/fsi/console.fs
@@ -30,14 +30,14 @@ type internal History() =
list.Clear()
current <- -1
- member _.Add (line: string | null) =
- match line with
+ member _.Add(line: string | null) =
+ match line with
| null
| "" -> ()
| _ -> list.Add(line)
- member _.AddLast (line: string | null) =
- match line with
+ member _.AddLast(line: string | null) =
+ match line with
| null
| "" -> ()
| _ ->
diff --git a/tests/FSharp.Build.UnitTests/MapSourceRootsTests.fs b/tests/FSharp.Build.UnitTests/MapSourceRootsTests.fs
index bdefa03d96a..ec590e52e42 100644
--- a/tests/FSharp.Build.UnitTests/MapSourceRootsTests.fs
+++ b/tests/FSharp.Build.UnitTests/MapSourceRootsTests.fs
@@ -9,6 +9,8 @@ open Xunit
open System.Collections.Generic
open FSharp.Test
+#nowarn "1182" //Unused arguments
+
type MockEngine() =
member val Errors = ResizeArray() with get
member val Warnings = ResizeArray() with get
diff --git a/tests/FSharp.Compiler.ComponentTests/CompilerService/AsyncMemoize.fs b/tests/FSharp.Compiler.ComponentTests/CompilerService/AsyncMemoize.fs
index 3e940c51ea6..f37b64eb0f5 100644
--- a/tests/FSharp.Compiler.ComponentTests/CompilerService/AsyncMemoize.fs
+++ b/tests/FSharp.Compiler.ComponentTests/CompilerService/AsyncMemoize.fs
@@ -430,7 +430,7 @@ let ``Cancel running jobs with the same key`` () =
let current = eventsWhen events (received Requested)
Assert.Equal(0, current |> countOf Canceled)
- waitUntil events (countOf Canceled >> (=) 10)
+ // waitUntil events (countOf Canceled >> (=) 10)
waitUntil events (received Started)
@@ -442,6 +442,7 @@ let ``Cancel running jobs with the same key`` () =
Assert.Equal(0, events |> countOf Failed)
+ // All outdated jobs should have been canceled by now.
Assert.Equal(10, events |> countOf Canceled)
Assert.Equal(1, events |> countOf Finished)
diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputationExpressions/ComputationExpressions.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputationExpressions/ComputationExpressions.fs
index b6520a2f363..3fe71d27ac6 100644
--- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputationExpressions/ComputationExpressions.fs
+++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputationExpressions/ComputationExpressions.fs
@@ -73,3 +73,16 @@ module ComputationExpressions =
compilation
|> getCompilation
|> verifyCompilation
+
+ []
+ let ``CustomCollectionBuilderComputationExpr_fs_OptimizeOff`` compilation =
+ compilation
+ |> getCompilation
+ |> asExe
+ |> withReferences [
+ FsFromPath (Path.Combine (__SOURCE_DIRECTORY__, "CustomCollectionBuilderComputationExprLibrary.fs"))
+ |> withName "CustomCollectionBuilderComputationExprLibrary"
+ ]
+ |> withEmbeddedPdb
+ |> withEmbedAllSource
+ |> verifyILBaseline
diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputationExpressions/CustomCollectionBuilderComputationExpr.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputationExpressions/CustomCollectionBuilderComputationExpr.fs
new file mode 100644
index 00000000000..fd0522f6538
--- /dev/null
+++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputationExpressions/CustomCollectionBuilderComputationExpr.fs
@@ -0,0 +1,14 @@
+module ComputationExpressions.Program
+
+let f0 () =
+ let xs = ResizeArray ()
+ xs.Add 1
+ xs.Add 2
+ xs.Add 3
+ xs
+
+let xs = f0 ()
+
+let f1 () = resizeArray { 1; 2; 3 }
+let f2 () = resizeArray { yield! xs }
+let f3 () = resizeArray { for x in xs -> x * x }
diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputationExpressions/CustomCollectionBuilderComputationExpr.fs.Optimize.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputationExpressions/CustomCollectionBuilderComputationExpr.fs.Optimize.il.bsl
new file mode 100644
index 00000000000..706081806c7
--- /dev/null
+++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputationExpressions/CustomCollectionBuilderComputationExpr.fs.Optimize.il.bsl
@@ -0,0 +1,228 @@
+
+
+
+
+
+.assembly extern runtime { }
+.assembly extern FSharp.Core { }
+.assembly extern assemblyLibrary
+{
+ .ver 0:0:0:0
+}
+.assembly assembly
+{
+ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32,
+ int32,
+ int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 )
+
+
+
+
+ .hash algorithm 0x00008004
+ .ver 0:0:0:0
+}
+.module assembly.exe
+
+.imagebase {value}
+.file alignment 0x00000200
+.stackreserve 0x00100000
+.subsystem 0x0003
+.corflags 0x00000001
+
+
+
+
+
+.class public abstract auto ansi sealed ComputationExpressions.Program
+ extends [runtime]System.Object
+{
+ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 )
+ .field static assembly class [runtime]System.Collections.Generic.List`1 xs@10
+ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
+ .method public static class [runtime]System.Collections.Generic.List`1 f0() cil managed
+ {
+
+ .maxstack 4
+ .locals init (class [runtime]System.Collections.Generic.List`1 V_0)
+ IL_0000: newobj instance void class [runtime]System.Collections.Generic.List`1::.ctor()
+ IL_0005: stloc.0
+ IL_0006: ldloc.0
+ IL_0007: ldc.i4.1
+ IL_0008: callvirt instance void class [runtime]System.Collections.Generic.List`1::Add(!0)
+ IL_000d: ldloc.0
+ IL_000e: ldc.i4.2
+ IL_000f: callvirt instance void class [runtime]System.Collections.Generic.List`1::Add(!0)
+ IL_0014: ldloc.0
+ IL_0015: ldc.i4.3
+ IL_0016: callvirt instance void class [runtime]System.Collections.Generic.List`1::Add(!0)
+ IL_001b: ldloc.0
+ IL_001c: ret
+ }
+
+ .method public specialname static class [runtime]System.Collections.Generic.List`1 get_xs() cil managed
+ {
+
+ .maxstack 8
+ IL_0000: ldsfld class [runtime]System.Collections.Generic.List`1 ComputationExpressions.Program::xs@10
+ IL_0005: ret
+ }
+
+ .method public static class [runtime]System.Collections.Generic.List`1 f1() cil managed
+ {
+
+ .maxstack 4
+ .locals init (class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 V_0,
+ class [runtime]System.Collections.Generic.List`1 V_1,
+ class [runtime]System.Collections.Generic.List`1& V_2)
+ IL_0000: call class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1::get_Instance()
+ IL_0005: stloc.0
+ IL_0006: newobj instance void class [runtime]System.Collections.Generic.List`1::.ctor()
+ IL_000b: stloc.1
+ IL_000c: ldloca.s V_1
+ IL_000e: stloc.2
+ IL_000f: ldloc.2
+ IL_0010: ldobj class [runtime]System.Collections.Generic.List`1
+ IL_0015: ldc.i4.1
+ IL_0016: callvirt instance void class [runtime]System.Collections.Generic.List`1::Add(!0)
+ IL_001b: ldloca.s V_1
+ IL_001d: stloc.2
+ IL_001e: ldloc.2
+ IL_001f: ldobj class [runtime]System.Collections.Generic.List`1
+ IL_0024: ldc.i4.2
+ IL_0025: callvirt instance void class [runtime]System.Collections.Generic.List`1::Add(!0)
+ IL_002a: ldloca.s V_1
+ IL_002c: stloc.2
+ IL_002d: ldloc.2
+ IL_002e: ldobj class [runtime]System.Collections.Generic.List`1
+ IL_0033: ldc.i4.3
+ IL_0034: callvirt instance void class [runtime]System.Collections.Generic.List`1::Add(!0)
+ IL_0039: ldloc.1
+ IL_003a: ret
+ }
+
+ .method public static class [runtime]System.Collections.Generic.List`1 f2() cil managed
+ {
+
+ .maxstack 4
+ .locals init (class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 V_0,
+ class [runtime]System.Collections.Generic.List`1 V_1,
+ class [runtime]System.Collections.Generic.List`1& V_2)
+ IL_0000: call class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1::get_Instance()
+ IL_0005: stloc.0
+ IL_0006: newobj instance void class [runtime]System.Collections.Generic.List`1::.ctor()
+ IL_000b: stloc.1
+ IL_000c: ldloca.s V_1
+ IL_000e: stloc.2
+ IL_000f: ldloc.2
+ IL_0010: ldobj class [runtime]System.Collections.Generic.List`1
+ IL_0015: call class [runtime]System.Collections.Generic.List`1 ComputationExpressions.Program::get_xs()
+ IL_001a: callvirt instance void class [runtime]System.Collections.Generic.List`1::AddRange(class [runtime]System.Collections.Generic.IEnumerable`1)
+ IL_001f: ldloc.1
+ IL_0020: ret
+ }
+
+ .method public static class [runtime]System.Collections.Generic.List`1 f3() cil managed
+ {
+
+ .maxstack 5
+ .locals init (class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 V_0,
+ class [runtime]System.Collections.Generic.List`1 V_1,
+ int32 V_2,
+ int32 V_3,
+ int32 V_4,
+ int32 V_5,
+ class [runtime]System.Collections.Generic.List`1& V_6)
+ IL_0000: call class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1::get_Instance()
+ IL_0005: stloc.0
+ IL_0006: newobj instance void class [runtime]System.Collections.Generic.List`1::.ctor()
+ IL_000b: stloc.1
+ IL_000c: ldc.i4.0
+ IL_000d: stloc.3
+ IL_000e: call class [runtime]System.Collections.Generic.List`1 ComputationExpressions.Program::get_xs()
+ IL_0013: callvirt instance int32 class [runtime]System.Collections.Generic.List`1::get_Count()
+ IL_0018: ldc.i4.1
+ IL_0019: sub
+ IL_001a: stloc.2
+ IL_001b: ldloc.2
+ IL_001c: ldloc.3
+ IL_001d: blt.s IL_004f
+
+ IL_001f: call class [runtime]System.Collections.Generic.List`1 ComputationExpressions.Program::get_xs()
+ IL_0024: ldloc.3
+ IL_0025: callvirt instance !0 class [runtime]System.Collections.Generic.List`1::get_Item(int32)
+ IL_002a: stloc.s V_4
+ IL_002c: ldloc.s V_4
+ IL_002e: ldloc.s V_4
+ IL_0030: mul
+ IL_0031: stloc.s V_5
+ IL_0033: ldloca.s V_1
+ IL_0035: stloc.s V_6
+ IL_0037: ldloc.s V_6
+ IL_0039: ldobj class [runtime]System.Collections.Generic.List`1
+ IL_003e: ldloc.s V_5
+ IL_0040: callvirt instance void class [runtime]System.Collections.Generic.List`1::Add(!0)
+ IL_0045: ldloc.3
+ IL_0046: ldc.i4.1
+ IL_0047: add
+ IL_0048: stloc.3
+ IL_0049: ldloc.3
+ IL_004a: ldloc.2
+ IL_004b: ldc.i4.1
+ IL_004c: add
+ IL_004d: bne.un.s IL_001f
+
+ IL_004f: ldloc.1
+ IL_0050: ret
+ }
+
+ .method private specialname rtspecialname static void .cctor() cil managed
+ {
+
+ .maxstack 8
+ IL_0000: ldc.i4.0
+ IL_0001: stsfld int32 '.$ComputationExpressions'.Program::init@
+ IL_0006: ldsfld int32 '.$ComputationExpressions'.Program::init@
+ IL_000b: pop
+ IL_000c: ret
+ }
+
+ .method assembly specialname static void staticInitialization@() cil managed
+ {
+
+ .maxstack 8
+ IL_0000: call class [runtime]System.Collections.Generic.List`1 ComputationExpressions.Program::f0()
+ IL_0005: stsfld class [runtime]System.Collections.Generic.List`1 ComputationExpressions.Program::xs@10
+ IL_000a: ret
+ }
+
+ .property class [runtime]System.Collections.Generic.List`1
+ xs()
+ {
+ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 09 00 00 00 00 00 )
+ .get class [runtime]System.Collections.Generic.List`1 ComputationExpressions.Program::get_xs()
+ }
+}
+
+.class private abstract auto ansi sealed '.$ComputationExpressions'.Program
+ extends [runtime]System.Object
+{
+ .field static assembly int32 init@
+ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
+ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
+ .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
+ .method public static void main@() cil managed
+ {
+ .entrypoint
+
+ .maxstack 8
+ IL_0000: call void ComputationExpressions.Program::staticInitialization@()
+ IL_0005: ret
+ }
+
+}
+
+
+
+
+
+
diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputationExpressions/CustomCollectionBuilderComputationExpr.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputationExpressions/CustomCollectionBuilderComputationExpr.fs.OptimizeOff.il.bsl
new file mode 100644
index 00000000000..cd7c9b8430b
--- /dev/null
+++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputationExpressions/CustomCollectionBuilderComputationExpr.fs.OptimizeOff.il.bsl
@@ -0,0 +1,593 @@
+
+
+
+
+
+.assembly extern runtime { }
+.assembly extern FSharp.Core { }
+.assembly extern assemblyLibrary
+{
+ .ver 0:0:0:0
+}
+.assembly assembly
+{
+ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32,
+ int32,
+ int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 )
+
+
+
+
+ .hash algorithm 0x00008004
+ .ver 0:0:0:0
+}
+.module assembly.exe
+
+.imagebase {value}
+.file alignment 0x00000200
+.stackreserve 0x00100000
+.subsystem 0x0003
+.corflags 0x00000001
+
+
+
+
+
+.class public abstract auto ansi sealed ComputationExpressions.Program
+ extends [runtime]System.Object
+{
+ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 )
+ .class auto autochar serializable sealed nested assembly beforefieldinit specialname 'f1@12-1'
+ extends [runtime]System.Object
+ {
+ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 )
+ .field public int32 x
+ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
+ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
+ .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
+ .method public specialname rtspecialname instance void .ctor(int32 x) cil managed
+ {
+
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: ldarg.1
+ IL_0002: stfld int32 ComputationExpressions.Program/'f1@12-1'::x
+ IL_0007: ldarg.0
+ IL_0008: call instance void [runtime]System.Object::.ctor()
+ IL_000d: ret
+ }
+
+ .method assembly hidebysig instance void Invoke(class [runtime]System.Collections.Generic.List`1& sm) cil managed
+ {
+
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldobj class [runtime]System.Collections.Generic.List`1
+ IL_0006: ldarg.0
+ IL_0007: ldfld int32 ComputationExpressions.Program/'f1@12-1'::x
+ IL_000c: callvirt instance void class [runtime]System.Collections.Generic.List`1::Add(!0)
+ IL_0011: ret
+ }
+
+ }
+
+ .class auto autochar serializable sealed nested assembly beforefieldinit specialname 'f1@12-3'
+ extends [runtime]System.Object
+ {
+ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 )
+ .field public int32 x
+ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
+ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
+ .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
+ .method public specialname rtspecialname instance void .ctor(int32 x) cil managed
+ {
+
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: ldarg.1
+ IL_0002: stfld int32 ComputationExpressions.Program/'f1@12-3'::x
+ IL_0007: ldarg.0
+ IL_0008: call instance void [runtime]System.Object::.ctor()
+ IL_000d: ret
+ }
+
+ .method assembly hidebysig instance void Invoke(class [runtime]System.Collections.Generic.List`1& sm) cil managed
+ {
+
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldobj class [runtime]System.Collections.Generic.List`1
+ IL_0006: ldarg.0
+ IL_0007: ldfld int32 ComputationExpressions.Program/'f1@12-3'::x
+ IL_000c: callvirt instance void class [runtime]System.Collections.Generic.List`1::Add(!0)
+ IL_0011: ret
+ }
+
+ }
+
+ .class auto autochar serializable sealed nested assembly beforefieldinit specialname 'f1@12-4'
+ extends [runtime]System.Object
+ {
+ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 )
+ .field public class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 builder@
+ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
+ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
+ .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
+ .method public specialname rtspecialname instance void .ctor(class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 builder@) cil managed
+ {
+
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: ldarg.1
+ IL_0002: stfld class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 ComputationExpressions.Program/'f1@12-4'::builder@
+ IL_0007: ldarg.0
+ IL_0008: call instance void [runtime]System.Object::.ctor()
+ IL_000d: ret
+ }
+
+ .method assembly hidebysig instance void Invoke(class [runtime]System.Collections.Generic.List`1& sm) cil managed
+ {
+
+ .maxstack 6
+ .locals init (class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilder V_0,
+ int32 V_1,
+ class [runtime]System.Collections.Generic.List`1& V_2)
+ IL_0000: ldarg.0
+ IL_0001: ldfld class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 ComputationExpressions.Program/'f1@12-4'::builder@
+ IL_0006: stloc.0
+ IL_0007: ldc.i4.3
+ IL_0008: stloc.1
+ IL_0009: ldarg.1
+ IL_000a: stloc.2
+ IL_000b: ldloc.2
+ IL_000c: ldobj class [runtime]System.Collections.Generic.List`1
+ IL_0011: ldloc.1
+ IL_0012: callvirt instance void class [runtime]System.Collections.Generic.List`1::Add(!0)
+ IL_0017: ret
+ }
+
+ }
+
+ .class auto autochar serializable sealed nested assembly beforefieldinit specialname 'f1@12-2'
+ extends [runtime]System.Object
+ {
+ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 )
+ .field public class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 builder@
+ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
+ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
+ .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
+ .method public specialname rtspecialname instance void .ctor(class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 builder@) cil managed
+ {
+
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: ldarg.1
+ IL_0002: stfld class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 ComputationExpressions.Program/'f1@12-2'::builder@
+ IL_0007: ldarg.0
+ IL_0008: call instance void [runtime]System.Object::.ctor()
+ IL_000d: ret
+ }
+
+ .method assembly hidebysig instance void Invoke(class [runtime]System.Collections.Generic.List`1& sm) cil managed
+ {
+
+ .maxstack 6
+ .locals init (class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilder V_0,
+ class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilderCode`1> V_1,
+ class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilder V_2,
+ int32 V_3,
+ class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilderCode`1> V_4,
+ class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilder V_5,
+ class [runtime]System.Collections.Generic.List`1& V_6)
+ IL_0000: ldarg.0
+ IL_0001: ldfld class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 ComputationExpressions.Program/'f1@12-2'::builder@
+ IL_0006: stloc.0
+ IL_0007: ldarg.0
+ IL_0008: ldfld class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 ComputationExpressions.Program/'f1@12-2'::builder@
+ IL_000d: stloc.2
+ IL_000e: ldc.i4.2
+ IL_000f: stloc.3
+ IL_0010: ldloc.3
+ IL_0011: newobj instance void ComputationExpressions.Program/'f1@12-3'::.ctor(int32)
+ IL_0016: ldftn instance void ComputationExpressions.Program/'f1@12-3'::Invoke(class [runtime]System.Collections.Generic.List`1&)
+ IL_001c: newobj instance void class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilderCode`1>::.ctor(object,
+ native int)
+ IL_0021: stloc.1
+ IL_0022: ldarg.0
+ IL_0023: ldfld class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 ComputationExpressions.Program/'f1@12-2'::builder@
+ IL_0028: stloc.s V_5
+ IL_002a: ldarg.0
+ IL_002b: ldfld class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 ComputationExpressions.Program/'f1@12-2'::builder@
+ IL_0030: newobj instance void ComputationExpressions.Program/'f1@12-4'::.ctor(class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1)
+ IL_0035: ldftn instance void ComputationExpressions.Program/'f1@12-4'::Invoke(class [runtime]System.Collections.Generic.List`1&)
+ IL_003b: newobj instance void class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilderCode`1>::.ctor(object,
+ native int)
+ IL_0040: stloc.s V_4
+ IL_0042: ldarg.1
+ IL_0043: stloc.s V_6
+ IL_0045: ldloc.1
+ IL_0046: ldloc.s V_6
+ IL_0048: callvirt instance void class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilderCode`1>::Invoke(!0&)
+ IL_004d: nop
+ IL_004e: ldloc.s V_4
+ IL_0050: ldloc.s V_6
+ IL_0052: callvirt instance void class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilderCode`1>::Invoke(!0&)
+ IL_0057: nop
+ IL_0058: ret
+ }
+
+ }
+
+ .class auto autochar serializable sealed nested assembly beforefieldinit specialname f1@12
+ extends [runtime]System.Object
+ {
+ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 )
+ .field public class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 builder@
+ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
+ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
+ .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
+ .method public specialname rtspecialname instance void .ctor(class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 builder@) cil managed
+ {
+
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: ldarg.1
+ IL_0002: stfld class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 ComputationExpressions.Program/f1@12::builder@
+ IL_0007: ldarg.0
+ IL_0008: call instance void [runtime]System.Object::.ctor()
+ IL_000d: ret
+ }
+
+ .method assembly hidebysig instance void Invoke(class [runtime]System.Collections.Generic.List`1& sm) cil managed
+ {
+
+ .maxstack 6
+ .locals init (class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilder V_0,
+ class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilderCode`1> V_1,
+ class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilder V_2,
+ int32 V_3,
+ class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilderCode`1> V_4,
+ class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilder V_5,
+ class [runtime]System.Collections.Generic.List`1& V_6)
+ IL_0000: ldarg.0
+ IL_0001: ldfld class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 ComputationExpressions.Program/f1@12::builder@
+ IL_0006: stloc.0
+ IL_0007: ldarg.0
+ IL_0008: ldfld class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 ComputationExpressions.Program/f1@12::builder@
+ IL_000d: stloc.2
+ IL_000e: ldc.i4.1
+ IL_000f: stloc.3
+ IL_0010: ldloc.3
+ IL_0011: newobj instance void ComputationExpressions.Program/'f1@12-1'::.ctor(int32)
+ IL_0016: ldftn instance void ComputationExpressions.Program/'f1@12-1'::Invoke(class [runtime]System.Collections.Generic.List`1&)
+ IL_001c: newobj instance void class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilderCode`1>::.ctor(object,
+ native int)
+ IL_0021: stloc.1
+ IL_0022: ldarg.0
+ IL_0023: ldfld class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 ComputationExpressions.Program/f1@12::builder@
+ IL_0028: stloc.s V_5
+ IL_002a: ldarg.0
+ IL_002b: ldfld class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 ComputationExpressions.Program/f1@12::builder@
+ IL_0030: newobj instance void ComputationExpressions.Program/'f1@12-2'::.ctor(class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1)
+ IL_0035: ldftn instance void ComputationExpressions.Program/'f1@12-2'::Invoke(class [runtime]System.Collections.Generic.List`1&)
+ IL_003b: newobj instance void class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilderCode`1>::.ctor(object,
+ native int)
+ IL_0040: stloc.s V_4
+ IL_0042: ldarg.1
+ IL_0043: stloc.s V_6
+ IL_0045: ldloc.1
+ IL_0046: ldloc.s V_6
+ IL_0048: callvirt instance void class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilderCode`1>::Invoke(!0&)
+ IL_004d: nop
+ IL_004e: ldloc.s V_4
+ IL_0050: ldloc.s V_6
+ IL_0052: callvirt instance void class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilderCode`1>::Invoke(!0&)
+ IL_0057: nop
+ IL_0058: ret
+ }
+
+ }
+
+ .class auto autochar serializable sealed nested assembly beforefieldinit specialname f2@13
+ extends [runtime]System.Object
+ {
+ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 )
+ .field public class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 builder@
+ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
+ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
+ .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
+ .method public specialname rtspecialname instance void .ctor(class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 builder@) cil managed
+ {
+
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: ldarg.1
+ IL_0002: stfld class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 ComputationExpressions.Program/f2@13::builder@
+ IL_0007: ldarg.0
+ IL_0008: call instance void [runtime]System.Object::.ctor()
+ IL_000d: ret
+ }
+
+ .method assembly hidebysig instance void Invoke(class [runtime]System.Collections.Generic.List`1& sm) cil managed
+ {
+
+ .maxstack 6
+ .locals init (class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilder V_0,
+ class [runtime]System.Collections.Generic.List`1 V_1,
+ class [runtime]System.Collections.Generic.List`1& V_2)
+ IL_0000: ldarg.0
+ IL_0001: ldfld class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 ComputationExpressions.Program/f2@13::builder@
+ IL_0006: stloc.0
+ IL_0007: call class [runtime]System.Collections.Generic.List`1 ComputationExpressions.Program::get_xs()
+ IL_000c: stloc.1
+ IL_000d: ldarg.1
+ IL_000e: stloc.2
+ IL_000f: ldloc.2
+ IL_0010: ldobj class [runtime]System.Collections.Generic.List`1
+ IL_0015: ldloc.1
+ IL_0016: callvirt instance void class [runtime]System.Collections.Generic.List`1::AddRange(class [runtime]System.Collections.Generic.IEnumerable`1)
+ IL_001b: ret
+ }
+
+ }
+
+ .class auto autochar serializable sealed nested assembly beforefieldinit specialname f3@14
+ extends [runtime]System.Object
+ {
+ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 )
+ .field public class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 builder@
+ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
+ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
+ .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
+ .method public specialname rtspecialname instance void .ctor(class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 builder@) cil managed
+ {
+
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: ldarg.1
+ IL_0002: stfld class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 ComputationExpressions.Program/f3@14::builder@
+ IL_0007: ldarg.0
+ IL_0008: call instance void [runtime]System.Object::.ctor()
+ IL_000d: ret
+ }
+
+ .method assembly hidebysig instance void Invoke(class [runtime]System.Collections.Generic.List`1& sm) cil managed
+ {
+
+ .maxstack 7
+ .locals init (class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilder V_0,
+ class [runtime]System.Collections.Generic.List`1 V_1,
+ class [runtime]System.Collections.Generic.List`1& V_2,
+ int32 V_3,
+ int32 V_4,
+ int32 V_5,
+ int32 V_6,
+ class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilder V_7,
+ int32 V_8,
+ class [runtime]System.Collections.Generic.List`1& V_9)
+ IL_0000: ldarg.0
+ IL_0001: ldfld class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 ComputationExpressions.Program/f3@14::builder@
+ IL_0006: stloc.0
+ IL_0007: call class [runtime]System.Collections.Generic.List`1 ComputationExpressions.Program::get_xs()
+ IL_000c: stloc.1
+ IL_000d: ldarg.1
+ IL_000e: stloc.2
+ IL_000f: ldc.i4.0
+ IL_0010: stloc.s V_4
+ IL_0012: ldloc.1
+ IL_0013: callvirt instance int32 class [runtime]System.Collections.Generic.List`1::get_Count()
+ IL_0018: ldc.i4.1
+ IL_0019: sub
+ IL_001a: stloc.3
+ IL_001b: ldloc.3
+ IL_001c: ldloc.s V_4
+ IL_001e: blt.s IL_005b
+
+ IL_0020: ldloc.1
+ IL_0021: ldloc.s V_4
+ IL_0023: callvirt instance !0 class [runtime]System.Collections.Generic.List`1::get_Item(int32)
+ IL_0028: stloc.s V_5
+ IL_002a: ldloc.s V_5
+ IL_002c: stloc.s V_6
+ IL_002e: ldarg.0
+ IL_002f: ldfld class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 ComputationExpressions.Program/f3@14::builder@
+ IL_0034: stloc.s V_7
+ IL_0036: ldloc.s V_6
+ IL_0038: ldloc.s V_6
+ IL_003a: mul
+ IL_003b: stloc.s V_8
+ IL_003d: ldloc.2
+ IL_003e: stloc.s V_9
+ IL_0040: ldloc.s V_9
+ IL_0042: ldobj class [runtime]System.Collections.Generic.List`1
+ IL_0047: ldloc.s V_8
+ IL_0049: callvirt instance void class [runtime]System.Collections.Generic.List`1::Add(!0)
+ IL_004e: ldloc.s V_4
+ IL_0050: ldc.i4.1
+ IL_0051: add
+ IL_0052: stloc.s V_4
+ IL_0054: ldloc.s V_4
+ IL_0056: ldloc.3
+ IL_0057: ldc.i4.1
+ IL_0058: add
+ IL_0059: bne.un.s IL_0020
+
+ IL_005b: ret
+ }
+
+ }
+
+ .field static assembly class [runtime]System.Collections.Generic.List`1 xs@10
+ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
+ .method public static class [runtime]System.Collections.Generic.List`1 f0() cil managed
+ {
+
+ .maxstack 4
+ .locals init (class [runtime]System.Collections.Generic.List`1 V_0)
+ IL_0000: newobj instance void class [runtime]System.Collections.Generic.List`1::.ctor()
+ IL_0005: stloc.0
+ IL_0006: ldloc.0
+ IL_0007: ldc.i4.1
+ IL_0008: callvirt instance void class [runtime]System.Collections.Generic.List`1::Add(!0)
+ IL_000d: ldloc.0
+ IL_000e: ldc.i4.2
+ IL_000f: callvirt instance void class [runtime]System.Collections.Generic.List`1::Add(!0)
+ IL_0014: ldloc.0
+ IL_0015: ldc.i4.3
+ IL_0016: callvirt instance void class [runtime]System.Collections.Generic.List`1::Add(!0)
+ IL_001b: ldloc.0
+ IL_001c: ret
+ }
+
+ .method public specialname static class [runtime]System.Collections.Generic.List`1 get_xs() cil managed
+ {
+
+ .maxstack 8
+ IL_0000: ldsfld class [runtime]System.Collections.Generic.List`1 ComputationExpressions.Program::xs@10
+ IL_0005: ret
+ }
+
+ .method public static class [runtime]System.Collections.Generic.List`1 f1() cil managed
+ {
+
+ .maxstack 4
+ .locals init (class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 V_0,
+ class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 V_1,
+ class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilderCode`1> V_2,
+ class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilder V_3,
+ class [runtime]System.Collections.Generic.List`1 V_4)
+ IL_0000: call class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 [assemblyLibrary]ComputationExpressions.Library::resizeArray()
+ IL_0005: stloc.0
+ IL_0006: ldloc.0
+ IL_0007: stloc.1
+ IL_0008: ldloc.0
+ IL_0009: stloc.3
+ IL_000a: ldloc.0
+ IL_000b: newobj instance void ComputationExpressions.Program/f1@12::.ctor(class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1)
+ IL_0010: ldftn instance void ComputationExpressions.Program/f1@12::Invoke(class [runtime]System.Collections.Generic.List`1&)
+ IL_0016: newobj instance void class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilderCode`1>::.ctor(object,
+ native int)
+ IL_001b: stloc.2
+ IL_001c: newobj instance void class [runtime]System.Collections.Generic.List`1::.ctor()
+ IL_0021: stloc.s V_4
+ IL_0023: ldloc.2
+ IL_0024: ldloca.s V_4
+ IL_0026: callvirt instance void class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilderCode`1>::Invoke(!0&)
+ IL_002b: nop
+ IL_002c: ldloc.s V_4
+ IL_002e: ret
+ }
+
+ .method public static class [runtime]System.Collections.Generic.List`1 f2() cil managed
+ {
+
+ .maxstack 4
+ .locals init (class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 V_0,
+ class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 V_1,
+ class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilderCode`1> V_2,
+ class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilder V_3,
+ class [runtime]System.Collections.Generic.List`1 V_4)
+ IL_0000: call class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 [assemblyLibrary]ComputationExpressions.Library::resizeArray()
+ IL_0005: stloc.0
+ IL_0006: ldloc.0
+ IL_0007: stloc.1
+ IL_0008: ldloc.0
+ IL_0009: stloc.3
+ IL_000a: ldloc.0
+ IL_000b: newobj instance void ComputationExpressions.Program/f2@13::.ctor(class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1)
+ IL_0010: ldftn instance void ComputationExpressions.Program/f2@13::Invoke(class [runtime]System.Collections.Generic.List`1&)
+ IL_0016: newobj instance void class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilderCode`1>::.ctor(object,
+ native int)
+ IL_001b: stloc.2
+ IL_001c: newobj instance void class [runtime]System.Collections.Generic.List`1::.ctor()
+ IL_0021: stloc.s V_4
+ IL_0023: ldloc.2
+ IL_0024: ldloca.s V_4
+ IL_0026: callvirt instance void class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilderCode`1>::Invoke(!0&)
+ IL_002b: nop
+ IL_002c: ldloc.s V_4
+ IL_002e: ret
+ }
+
+ .method public static class [runtime]System.Collections.Generic.List`1 f3() cil managed
+ {
+
+ .maxstack 4
+ .locals init (class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 V_0,
+ class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 V_1,
+ class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilderCode`1> V_2,
+ class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilder V_3,
+ class [runtime]System.Collections.Generic.List`1 V_4)
+ IL_0000: call class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1 [assemblyLibrary]ComputationExpressions.Library::resizeArray()
+ IL_0005: stloc.0
+ IL_0006: ldloc.0
+ IL_0007: stloc.1
+ IL_0008: ldloc.0
+ IL_0009: stloc.3
+ IL_000a: ldloc.0
+ IL_000b: newobj instance void ComputationExpressions.Program/f3@14::.ctor(class [assemblyLibrary]ComputationExpressions.Library/ResizeArrayBuilder`1)
+ IL_0010: ldftn instance void ComputationExpressions.Program/f3@14::Invoke(class [runtime]System.Collections.Generic.List`1&)
+ IL_0016: newobj instance void class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilderCode`1>::.ctor(object,
+ native int)
+ IL_001b: stloc.2
+ IL_001c: newobj instance void class [runtime]System.Collections.Generic.List`1::.ctor()
+ IL_0021: stloc.s V_4
+ IL_0023: ldloc.2
+ IL_0024: ldloca.s V_4
+ IL_0026: callvirt instance void class [assemblyLibrary]ComputationExpressions.Library/CollectionBuilderCode`1>::Invoke(!0&)
+ IL_002b: nop
+ IL_002c: ldloc.s V_4
+ IL_002e: ret
+ }
+
+ .method private specialname rtspecialname static void .cctor() cil managed
+ {
+
+ .maxstack 8
+ IL_0000: ldc.i4.0
+ IL_0001: stsfld int32 '.$ComputationExpressions'.Program::init@
+ IL_0006: ldsfld int32 '.$ComputationExpressions'.Program::init@
+ IL_000b: pop
+ IL_000c: ret
+ }
+
+ .method assembly specialname static void staticInitialization@() cil managed
+ {
+
+ .maxstack 8
+ IL_0000: call class [runtime]System.Collections.Generic.List`1 ComputationExpressions.Program::f0()
+ IL_0005: stsfld class [runtime]System.Collections.Generic.List`1 ComputationExpressions.Program::xs@10
+ IL_000a: ret
+ }
+
+ .property class [runtime]System.Collections.Generic.List`1
+ xs()
+ {
+ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 09 00 00 00 00 00 )
+ .get class [runtime]System.Collections.Generic.List`1 ComputationExpressions.Program::get_xs()
+ }
+}
+
+.class private abstract auto ansi sealed '.$ComputationExpressions'.Program
+ extends [runtime]System.Object
+{
+ .field static assembly int32 init@
+ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 )
+ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
+ .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
+ .method public static void main@() cil managed
+ {
+ .entrypoint
+
+ .maxstack 8
+ IL_0000: call void ComputationExpressions.Program::staticInitialization@()
+ IL_0005: ret
+ }
+
+}
+
+
+
+
+
+
diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputationExpressions/CustomCollectionBuilderComputationExprLibrary.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputationExpressions/CustomCollectionBuilderComputationExprLibrary.fs
new file mode 100644
index 00000000000..5fa93736fb7
--- /dev/null
+++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputationExpressions/CustomCollectionBuilderComputationExprLibrary.fs
@@ -0,0 +1,59 @@
+namespace ComputationExpressions
+
+#nowarn 77
+
+open System
+
+[]
+module Library =
+ type CollectionBuilderCode<'T> = delegate of byref<'T> -> unit
+
+ type CollectionBuilder () =
+ member inline _.Combine ([] f1 : CollectionBuilderCode<_>, [] f2 : CollectionBuilderCode<_>) =
+ CollectionBuilderCode (fun sm -> f1.Invoke &sm; f2.Invoke &sm)
+
+ member inline _.Delay ([] f : unit -> CollectionBuilderCode<_>) =
+ CollectionBuilderCode (fun sm -> (f ()).Invoke &sm)
+
+ member inline _.Zero () = CollectionBuilderCode (fun _ -> ())
+
+ member inline _.While ([] condition : unit -> bool, [