Skip to content

Commit

Permalink
Merge branch 'feature/nullness' into merges/main-to-feature/nullness
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinRansom authored Jan 31, 2024
2 parents 33e8be6 + 33e5e27 commit d70d1fe
Show file tree
Hide file tree
Showing 352 changed files with 17,946 additions and 2,446 deletions.
17 changes: 17 additions & 0 deletions .fantomasignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,23 @@ 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/sformat.fs
src/Compiler/Utilities/illib.fsi
src/Compiler/Utilities/illib.fs

# Fantomas limitations on implementation files (to investigate)

src/Compiler/AbstractIL/ilwrite.fs
Expand Down
1 change: 1 addition & 0 deletions FSharp.Benchmarks.sln
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Microsoft Visual Studio Solution File, Format Version 12.00

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
Expand Down
30 changes: 30 additions & 0 deletions FSharp.Profiles.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -->
<Project>
<PropertyGroup>
<!-- This turns on/off the use of the feature within the codebase -->
<!-- The default is off - it is selectively enabled -->
<CheckNulls Condition="'$(CheckNulls)' == ''">false</CheckNulls>
</PropertyGroup>

<PropertyGroup Condition="'$(FSHARPCORE_USE_PACKAGE)' == 'true'">
<!-- nullness checking isn't possible when using shipped FSharp.Core package until it's updated -->
<CheckNulls>false</CheckNulls>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Proto'">
<CheckNulls>false</CheckNulls>
<DefineConstants>NO_CHECKNULLS;BUILDING_WITH_LKG;NO_NULLCHECKING_LIB_SUPPORT;$(DefineConstants)</DefineConstants>
<NullCheckingSupportInLibrary>false</NullCheckingSupportInLibrary>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' != 'Proto'">
<OtherFlags>$(OtherFlags) /langversion:preview</OtherFlags>
</PropertyGroup>

<PropertyGroup Condition="'$(CheckNulls)' == 'true'">
<OtherFlags>$(OtherFlags) /checknulls</OtherFlags>
</PropertyGroup>

<PropertyGroup Condition="'$(CheckNulls)' == 'false'">
<!-- 3271: warning nullness annotations being ignored -->
<NoWarn>$(NoWarn);3271</NoWarn>
<DefineConstants>NO_CHECKNULLS;$(DefineConstants)</DefineConstants>
</PropertyGroup>

<Choose>
<When Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' ">
Expand Down
5 changes: 1 addition & 4 deletions FSharpBuild.Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,9 @@
</PropertyGroup>

<!-- use this to enable good debugging in the Proto bootstrap compiler -->
<!-- You'll have to remove it to get the actual compiler bo build because optimization is needed for some large methods -->
<!--
<PropertyGroup Condition="'$(Configuration)' == 'Proto'">
<PropertyGroup Condition="'$(ProtoDebug)' == 'true'">
<DebugSymbols>true</DebugSymbols>
<Optimize>false</Optimize>
<Tailcalls>true</Tailcalls>
</PropertyGroup>
-->
</Project>
14 changes: 14 additions & 0 deletions VisualFSharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Editor.Tests", "vsin
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FSharp.Editor.IntegrationTests", "vsintegration\tests\FSharp.Editor.IntegrationTests\FSharp.Editor.IntegrationTests.csproj", "{E31F9B59-FCF1-4D04-8762-C7BB60285A7B}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "nullness", "tests\adhoc\nullness\nullness.fsproj", "{6992D926-AB1C-4CD4-94D5-0319D14DB54B}"
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Benchmarks.Common", "tests\benchmarks\FSharp.Benchmarks.Common\FSharp.Benchmarks.Common.fsproj", "{6734FC6F-B5F3-45E1-9A72-720378BB49C9}"
EndProject
Global
Expand Down Expand Up @@ -1021,6 +1022,18 @@ Global
{E31F9B59-FCF1-4D04-8762-C7BB60285A7B}.Release|Any CPU.Build.0 = Release|Any CPU
{E31F9B59-FCF1-4D04-8762-C7BB60285A7B}.Release|x86.ActiveCfg = Release|Any CPU
{E31F9B59-FCF1-4D04-8762-C7BB60285A7B}.Release|x86.Build.0 = Release|Any CPU
{6992D926-AB1C-4CD4-94D5-0319D14DB54B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6992D926-AB1C-4CD4-94D5-0319D14DB54B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6992D926-AB1C-4CD4-94D5-0319D14DB54B}.Debug|x86.ActiveCfg = Debug|Any CPU
{6992D926-AB1C-4CD4-94D5-0319D14DB54B}.Debug|x86.Build.0 = Debug|Any CPU
{6992D926-AB1C-4CD4-94D5-0319D14DB54B}.Proto|Any CPU.ActiveCfg = Debug|Any CPU
{6992D926-AB1C-4CD4-94D5-0319D14DB54B}.Proto|Any CPU.Build.0 = Debug|Any CPU
{6992D926-AB1C-4CD4-94D5-0319D14DB54B}.Proto|x86.ActiveCfg = Debug|Any CPU
{6992D926-AB1C-4CD4-94D5-0319D14DB54B}.Proto|x86.Build.0 = Debug|Any CPU
{6992D926-AB1C-4CD4-94D5-0319D14DB54B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6992D926-AB1C-4CD4-94D5-0319D14DB54B}.Release|Any CPU.Build.0 = Release|Any CPU
{6992D926-AB1C-4CD4-94D5-0319D14DB54B}.Release|x86.ActiveCfg = Release|Any CPU
{6992D926-AB1C-4CD4-94D5-0319D14DB54B}.Release|x86.Build.0 = Release|Any CPU
{6734FC6F-B5F3-45E1-9A72-720378BB49C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6734FC6F-B5F3-45E1-9A72-720378BB49C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6734FC6F-B5F3-45E1-9A72-720378BB49C9}.Debug|x86.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -1113,6 +1126,7 @@ Global
{39CDF34B-FB23-49AE-AB27-0975DA379BB5} = {DFB6ADD7-3149-43D9-AFA0-FC4A818B472B}
{CBC96CC7-65AB-46EA-A82E-F6A788DABF80} = {F7876C9B-FB6A-4EFB-B058-D6967DB75FB2}
{E31F9B59-FCF1-4D04-8762-C7BB60285A7B} = {F7876C9B-FB6A-4EFB-B058-D6967DB75FB2}
{6992D926-AB1C-4CD4-94D5-0319D14DB54B} = {CFE3259A-2D30-4EB0-80D5-E8B5F3D01449}
{6734FC6F-B5F3-45E1-9A72-720378BB49C9} = {DFB6ADD7-3149-43D9-AFA0-FC4A818B472B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Expand Down
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/8.0.300.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

### Added

* Support for nullable reference types ([PR #15181](https://github.com/dotnet/fsharp/pull/15181))
* The stackguard depth for ILPdbWriter.unshadowScopes can be modified via the environment variable `FSHARP_ILPdb_UnshadowScopes_StackGuardDepth`([PR #16583](https://github.com/dotnet/fsharp/pull/16583))
* Parser recovers on complex primary constructor patterns, better tree representation for primary constructor patterns. ([PR #16425](https://github.com/dotnet/fsharp/pull/16425))
* Name resolution: keep type vars in subsequent checks ([PR #16456](https://github.com/dotnet/fsharp/pull/16456))
Expand Down
1 change: 1 addition & 0 deletions docs/release-notes/.Language/preview.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Added

* Support for nullable reference types ([PR #15181](https://github.com/dotnet/fsharp/pull/15181))
* Better generic unmanaged structs handling. ([Language suggestion #692](https://github.com/fsharp/fslang-suggestions/issues/692), [PR #12154](https://github.com/dotnet/fsharp/pull/12154))
* Bidirectional F#/C# interop for 'unmanaged' constraint. ([PR #12154](https://github.com/dotnet/fsharp/pull/12154))
* Make `.Is*` discriminated union properties visible. ([Language suggestion #222](https://github.com/fsharp/fslang-suggestions/issues/222), [PR #16341](https://github.com/dotnet/fsharp/pull/16341))
Expand Down
Binary file added micro.exe
Binary file not shown.
24 changes: 21 additions & 3 deletions src/Compiler/AbstractIL/il.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2612,6 +2612,7 @@ type ILTypeDef
attributes: TypeAttributes,
layout: ILTypeDefLayout,
implements: ILTypes,
implementsCustomAttrs: (ILAttributesStored * int) list option,
genericParams: ILGenericParameterDefs,
extends: ILType option,
methods: ILMethodDefs,
Expand All @@ -2632,6 +2633,7 @@ type ILTypeDef
attributes,
layout,
implements,
implementsCustomAttrs,
genericParams,
extends,
methods,
Expand All @@ -2648,6 +2650,7 @@ type ILTypeDef
attributes,
layout,
implements,
implementsCustomAttrs,
genericParams,
extends,
methods,
Expand All @@ -2674,6 +2677,8 @@ type ILTypeDef

member _.Implements = implements

member _.ImplementsCustomAttrs = implementsCustomAttrs

member _.Extends = extends

member _.Methods = methods
Expand Down Expand Up @@ -2710,7 +2715,8 @@ type ILTypeDef
?properties,
?isKnownToBeAttribute,
?customAttrs,
?securityDecls
?securityDecls,
?implementsCustomAttrs
) =
ILTypeDef(
name = defaultArg name x.Name,
Expand All @@ -2719,6 +2725,7 @@ type ILTypeDef
genericParams = defaultArg genericParams x.GenericParams,
nestedTypes = defaultArg nestedTypes x.NestedTypes,
implements = defaultArg implements x.Implements,
implementsCustomAttrs = defaultArg implementsCustomAttrs x.ImplementsCustomAttrs,
extends = defaultArg extends x.Extends,
methods = defaultArg methods x.Methods,
securityDecls = defaultArg securityDecls x.SecurityDecls,
Expand Down Expand Up @@ -3417,6 +3424,11 @@ type ILGlobals(primaryScopeRef: ILScopeRef, equivPrimaryAssemblyRefs: ILAssembly

let mkSysILTypeRef nm = mkILTyRef (primaryScopeRef, nm)

let byteIlType = ILType.Value(mkILNonGenericTySpec (mkSysILTypeRef tname_Byte))

let stringIlType =
mkILBoxedType (mkILNonGenericTySpec (mkSysILTypeRef tname_String))

member _.primaryAssemblyScopeRef = primaryScopeRef

member x.primaryAssemblyRef =
Expand All @@ -3434,7 +3446,7 @@ type ILGlobals(primaryScopeRef: ILScopeRef, equivPrimaryAssemblyRefs: ILAssembly

member val typ_Object = mkILBoxedType (mkILNonGenericTySpec (mkSysILTypeRef tname_Object))

member val typ_String = mkILBoxedType (mkILNonGenericTySpec (mkSysILTypeRef tname_String))
member val typ_String = stringIlType

member val typ_Array = mkILBoxedType (mkILNonGenericTySpec (mkSysILTypeRef tname_Array))

Expand All @@ -3448,7 +3460,11 @@ type ILGlobals(primaryScopeRef: ILScopeRef, equivPrimaryAssemblyRefs: ILAssembly

member val typ_Int64 = ILType.Value(mkILNonGenericTySpec (mkSysILTypeRef tname_Int64))

member val typ_Byte = ILType.Value(mkILNonGenericTySpec (mkSysILTypeRef tname_Byte))
member val typ_Byte = byteIlType

member val typ_ByteArray = ILType.Array(ILArrayShape.SingleDimensional, byteIlType)

member val typ_StringArray = ILType.Array(ILArrayShape.SingleDimensional, stringIlType)

member val typ_UInt16 = ILType.Value(mkILNonGenericTySpec (mkSysILTypeRef tname_UInt16))

Expand Down Expand Up @@ -4183,6 +4199,7 @@ let mkILGenericClass (nm, access, genparams, extends, impl, methods, fields, nes
attributes = attributes,
genericParams = genparams,
implements = impl,
implementsCustomAttrs = None,
layout = ILTypeDefLayout.Auto,
extends = Some extends,
methods = methods,
Expand All @@ -4207,6 +4224,7 @@ let mkRawDataValueTypeDef (iltyp_ValueType: ILType) (nm, size, pack) =
||| TypeAttributes.BeforeFieldInit
||| TypeAttributes.AnsiClass),
implements = [],
implementsCustomAttrs = None,
extends = Some iltyp_ValueType,
layout = ILTypeDefLayout.Explicit { Size = Some size; Pack = Some pack },
methods = emptyILMethods,
Expand Down
28 changes: 26 additions & 2 deletions src/Compiler/AbstractIL/il.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,13 @@ type ILAttributes =

/// Represents the efficiency-oriented storage of ILAttributes in another item.
[<NoEquality; NoComparison>]
type ILAttributesStored
type ILAttributesStored =
/// Computed by ilread.fs based on metadata index
| Reader of (int32 -> ILAttribute[])
/// Already computed
| Given of ILAttributes

member GetCustomAttrs: int32 -> ILAttributes

/// Method parameters and return values.
[<RequireQualifiedAccess; NoEquality; NoComparison>]
Expand Down Expand Up @@ -1069,6 +1075,8 @@ type ILMethodDef =
member IsEntryPoint: bool
member GenericParams: ILGenericParameterDefs
member CustomAttrs: ILAttributes
member MetadataIndex: int32
member CustomAttrsStored: ILAttributesStored
member ParameterTypes: ILTypes
member IsIL: bool
member Code: ILCode option
Expand Down Expand Up @@ -1242,6 +1250,10 @@ type ILFieldDef =

member CustomAttrs: ILAttributes

member MetadataIndex: int32

member CustomAttrsStored: ILAttributesStored

member IsStatic: bool

member IsSpecialName: bool
Expand Down Expand Up @@ -1325,6 +1337,8 @@ type ILEventDef =
member FireMethod: ILMethodRef option
member OtherMethods: ILMethodRef list
member CustomAttrs: ILAttributes
member MetadataIndex: int32
member CustomAttrsStored: ILAttributesStored
member IsSpecialName: bool
member IsRTSpecialName: bool

Expand Down Expand Up @@ -1387,6 +1401,8 @@ type ILPropertyDef =
member Init: ILFieldInit option
member Args: ILTypes
member CustomAttrs: ILAttributes
member MetadataIndex: int32
member CustomAttrsStored: ILAttributesStored
member IsSpecialName: bool
member IsRTSpecialName: bool

Expand Down Expand Up @@ -1491,6 +1507,7 @@ type ILTypeDef =
attributes: TypeAttributes *
layout: ILTypeDefLayout *
implements: ILTypes *
implementsCustomAttrs: (ILAttributesStored * int) list option *
genericParams: ILGenericParameterDefs *
extends: ILType option *
methods: ILMethodDefs *
Expand All @@ -1511,6 +1528,7 @@ type ILTypeDef =
attributes: TypeAttributes *
layout: ILTypeDefLayout *
implements: ILTypes *
implementsCustomAttrs: (ILAttributesStored * int) list option *
genericParams: ILGenericParameterDefs *
extends: ILType option *
methods: ILMethodDefs *
Expand All @@ -1530,6 +1548,7 @@ type ILTypeDef =
member Layout: ILTypeDefLayout
member NestedTypes: ILTypeDefs
member Implements: ILTypes
member ImplementsCustomAttrs: (ILAttributesStored * int) list option
member Extends: ILType option
member Methods: ILMethodDefs
member SecurityDecls: ILSecurityDecls
Expand All @@ -1538,6 +1557,8 @@ type ILTypeDef =
member Events: ILEventDefs
member Properties: ILPropertyDefs
member CustomAttrs: ILAttributes
member MetadataIndex: int32
member CustomAttrsStored: ILAttributesStored
member IsClass: bool
member IsStruct: bool
member IsInterface: bool
Expand Down Expand Up @@ -1586,7 +1607,8 @@ type ILTypeDef =
?properties: ILPropertyDefs *
?isKnownToBeAttribute: bool *
?customAttrs: ILAttributes *
?securityDecls: ILSecurityDecls ->
?securityDecls: ILSecurityDecls *
?implementsCustomAttrs: (ILAttributesStored * int) list option ->
ILTypeDef

/// Represents a prefix of information for ILTypeDef.
Expand Down Expand Up @@ -1882,11 +1904,13 @@ type internal ILGlobals =
member typ_Enum: ILType
member typ_Object: ILType
member typ_String: ILType
member typ_StringArray: ILType
member typ_Type: ILType
member typ_Array: ILType
member typ_IntPtr: ILType
member typ_UIntPtr: ILType
member typ_Byte: ILType
member typ_ByteArray: ILType
member typ_Int16: ILType
member typ_Int32: ILType
member typ_Int64: ILType
Expand Down
Loading

0 comments on commit d70d1fe

Please sign in to comment.