diff --git a/src/Compiler/AbstractIL/ilnativeres.fs b/src/Compiler/AbstractIL/ilnativeres.fs index 070157f67fd..3a100e62bbd 100644 --- a/src/Compiler/AbstractIL/ilnativeres.fs +++ b/src/Compiler/AbstractIL/ilnativeres.fs @@ -27,7 +27,7 @@ type WORD = uint16 let inline WORD s = uint16 s -type ResourceException(name: string, ?inner: Exception MaybeNull) = +type ResourceException(name: string, ?inner: (Exception | null)) = inherit Exception(name, Option.toObj inner) type RESOURCE_STRING() = diff --git a/src/Compiler/AbstractIL/ilread.fs b/src/Compiler/AbstractIL/ilread.fs index 9aa2a2672ef..0a48f7c5a4f 100644 --- a/src/Compiler/AbstractIL/ilread.fs +++ b/src/Compiler/AbstractIL/ilread.fs @@ -226,7 +226,7 @@ type WeakByteFile(fileName: string, chunk: (int * int) option) = let fileStamp = FileSystem.GetLastWriteTimeShim fileName /// The weak handle to the bytes for the file - let weakBytes = WeakReference(null) + let weakBytes = WeakReference(null) member _.FileName = fileName diff --git a/src/Compiler/AbstractIL/ilreflect.fs b/src/Compiler/AbstractIL/ilreflect.fs index 03a6f829d64..eab257c1573 100644 --- a/src/Compiler/AbstractIL/ilreflect.fs +++ b/src/Compiler/AbstractIL/ilreflect.fs @@ -550,7 +550,7 @@ let emEnv0 = delayedFieldInits = [] } -let envBindTypeRef emEnv (tref: ILTypeRef) (typT: Type MaybeNull, typB, typeDef) = +let envBindTypeRef emEnv (tref: ILTypeRef) (typT: Type | null, typB, typeDef) = match typT with | Null -> failwithf "binding null type in envBindTypeRef: %s\n" tref.Name | NonNull typT -> @@ -697,7 +697,7 @@ let rec convTypeSpec cenv emEnv preferCreated (tspec: ILTypeSpec) = let typT = convTypeRef cenv emEnv preferCreated tspec.TypeRef let tyargs = List.map (convTypeAux cenv emEnv preferCreated) tspec.GenericArgs - let res: Type MaybeNull = + let res: Type | null = match isNil tyargs, typT.IsGenericType with | _, true -> typT.MakeGenericType(List.toArray tyargs) | true, false -> typT @@ -1013,7 +1013,7 @@ let queryableTypeGetMethod cenv emEnv parentT (mref: ILMethodRef) : MethodInfo = else queryableTypeGetMethodBySearch cenv emEnv parentT mref -let nonQueryableTypeGetMethod (parentTI: Type) (methInfo: MethodInfo) : MethodInfo MaybeNull = +let nonQueryableTypeGetMethod (parentTI: Type) (methInfo: MethodInfo) : MethodInfo | null = if (parentTI.IsGenericType && not (equalTypes parentTI (getTypeConstructor parentTI))) @@ -1102,7 +1102,7 @@ let queryableTypeGetConstructor cenv emEnv (parentT: Type) (mref: ILMethodRef) = ) | NonNull res -> res -let nonQueryableTypeGetConstructor (parentTI: Type) (consInfo: ConstructorInfo) : ConstructorInfo MaybeNull = +let nonQueryableTypeGetConstructor (parentTI: Type) (consInfo: ConstructorInfo) : ConstructorInfo | null = if parentTI.IsGenericType then TypeBuilder.GetConstructor(parentTI, consInfo) else diff --git a/src/Compiler/AbstractIL/ilsign.fs b/src/Compiler/AbstractIL/ilsign.fs index 53add630789..e03f614244c 100644 --- a/src/Compiler/AbstractIL/ilsign.fs +++ b/src/Compiler/AbstractIL/ilsign.fs @@ -171,7 +171,7 @@ let RSAParametersFromBlob blob keyType = key.D <- reader.ReadBigInteger byteLen key -let validateRSAField (field: byte array MaybeNull) expected (name: string) = +let validateRSAField (field: byte array | null) expected (name: string) = match field with | Null -> () | NonNull field -> @@ -237,7 +237,7 @@ let toCLRKeyBlob (rsaParameters: RSAParameters) (algId: int) : byte array = buffer - let safeArrayRev (buffer: _ MaybeNull) = + let safeArrayRev (buffer: _ | null) = match buffer with | Null -> Array.empty | NonNull buffer -> buffer |> Array.rev diff --git a/src/Compiler/Checking/AccessibilityLogic.fs b/src/Compiler/Checking/AccessibilityLogic.fs index 6aba2edcb4b..4995095a688 100644 --- a/src/Compiler/Checking/AccessibilityLogic.fs +++ b/src/Compiler/Checking/AccessibilityLogic.fs @@ -374,7 +374,7 @@ let IsPropInfoAccessible g amap m ad = function | ProvidedProp (amap, tppi, m) as pp-> let access = let a = tppi.PUntaint((fun ppi -> - let tryGetILAccessForProvidedMethodBase (mi : ProvidedMethodInfo MaybeNull) = + let tryGetILAccessForProvidedMethodBase (mi : (ProvidedMethodInfo | null)) = match mi with | Null -> None | NonNull mi -> diff --git a/src/Compiler/Checking/MethodCalls.fs b/src/Compiler/Checking/MethodCalls.fs index 0a7f7f353bb..667eed5efc1 100644 --- a/src/Compiler/Checking/MethodCalls.fs +++ b/src/Compiler/Checking/MethodCalls.fs @@ -1871,7 +1871,7 @@ module ProvidedMethodCalls = allArgs: Exprs, paramVars: Tainted[], g, amap, mut, isProp, isSuperInit, m, - expr: Tainted) = + expr: Tainted<(ProvidedExpr | null)>) = let varConv = // note: Assuming the size based on paramVars @@ -1881,8 +1881,8 @@ module ProvidedMethodCalls = dict.Add(v, (None, e)) dict - let rec exprToExprAndWitness top (ea: Tainted) = - let fail() = error(Error(FSComp.SR.etUnsupportedProvidedExpression(ea.PUntaint((fun etree -> etree.UnderlyingExpressionString), m)), m)) + let rec exprToExprAndWitness top (ea: Tainted<(ProvidedExpr | null)>) = + let fail() = error(Error(FSComp.SR.etUnsupportedProvidedExpression(ea.PUntaint((fun etree -> match etree with null -> "" | e -> e.UnderlyingExpressionString), m)), m)) match ea with | Tainted.Null -> error(Error(FSComp.SR.etNullProvidedExpression(ea.TypeProviderDesignation), m)) | Tainted.NonNull ea -> diff --git a/src/Compiler/Checking/import.fs b/src/Compiler/Checking/import.fs index 3b0faa7ebe2..644d7c2e8a5 100644 --- a/src/Compiler/Checking/import.fs +++ b/src/Compiler/Checking/import.fs @@ -38,7 +38,7 @@ type AssemblyLoader = /// Get a flag indicating if an assembly is a provided assembly, plus the /// table of information recording remappings from type names in the provided assembly to type /// names in the statically linked, embedded assembly. - abstract GetProvidedAssemblyInfo : CompilationThreadToken * range * Tainted -> bool * ProvidedAssemblyStaticLinkingMap option + abstract GetProvidedAssemblyInfo : CompilationThreadToken * range * Tainted<(ProvidedAssembly | null)> -> bool * ProvidedAssemblyStaticLinkingMap option /// Record a root for a [] type to help guide static linking & type relocation abstract RecordGeneratedTypeRoot : ProviderGeneratedType -> unit diff --git a/src/Compiler/Checking/import.fsi b/src/Compiler/Checking/import.fsi index fb1f191effc..f51f4d6208f 100644 --- a/src/Compiler/Checking/import.fsi +++ b/src/Compiler/Checking/import.fsi @@ -28,7 +28,7 @@ type AssemblyLoader = /// table of information recording remappings from type names in the provided assembly to type /// names in the statically linked, embedded assembly. abstract GetProvidedAssemblyInfo: - CompilationThreadToken * range * Tainted -> + CompilationThreadToken * range * Tainted<(ProvidedAssembly | null)> -> bool * ProvidedAssemblyStaticLinkingMap option /// Record a root for a [] type to help guide static linking & type relocation diff --git a/src/Compiler/Checking/infos.fs b/src/Compiler/Checking/infos.fs index 642e08d871c..746e23e57cb 100644 --- a/src/Compiler/Checking/infos.fs +++ b/src/Compiler/Checking/infos.fs @@ -341,7 +341,7 @@ let CrackParamAttribsInfo g (ty: TType, argInfo: ArgReprInfo) = type ILFieldInit with /// Compute the ILFieldInit for the given provided constant value for a provided enum type. - static member FromProvidedObj m (v: obj MaybeNull) = + static member FromProvidedObj m (v: obj | null) = match v with | Null -> ILFieldInit.Null | NonNull v -> @@ -393,8 +393,8 @@ let OptionalArgInfoOfProvidedParameter (amap: ImportMap) m (provParam : Tainted< NotOptional /// Compute the ILFieldInit for the given provided constant value for a provided enum type. -let GetAndSanityCheckProviderMethod m (mi: Tainted<'T :> ProvidedMemberInfo>) (get : 'T -> ProvidedMethodInfo MaybeNull) err = - match mi.PApply((fun mi -> (get mi :> ProvidedMethodBase MaybeNull)),m) with +let GetAndSanityCheckProviderMethod m (mi: Tainted<'T :> ProvidedMemberInfo>) (get : 'T -> (ProvidedMethodInfo | null)) err = + match mi.PApply((fun mi -> (get mi :> (ProvidedMethodBase | null))),m) with | Tainted.Null -> error(Error(err(mi.PUntaint((fun mi -> mi.Name),m),mi.PUntaint((fun mi -> (nonNull mi.DeclaringType).Name), m)), m)) | Tainted.NonNull meth -> meth diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index b4460b92e55..1e2f26b011e 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -12194,7 +12194,7 @@ let LookupGeneratedValue (cenv: cenv) (ctxt: ExecutionContext) eenv (v: Val) = if hasLiteralAttr then let staticTy = ctxt.LookupTypeRef fspec.DeclaringTypeRef // Checked: This FieldInfo (FieldBuilder) supports GetValue(). - (!!staticTy.GetField(fspec.Name)).GetValue(null: obj MaybeNull) + (!!staticTy.GetField(fspec.Name)).GetValue(null: obj | null) else let staticTy = ctxt.LookupTypeRef ilContainerTy.TypeRef // We can't call .Invoke on the ILMethodRef's MethodInfo, diff --git a/src/Compiler/DependencyManager/DependencyProvider.fsi b/src/Compiler/DependencyManager/DependencyProvider.fsi index e05c6d0b9b3..5ec344287df 100644 --- a/src/Compiler/DependencyManager/DependencyProvider.fsi +++ b/src/Compiler/DependencyManager/DependencyProvider.fsi @@ -106,11 +106,11 @@ type DependencyProvider = /// Returns a formatted help messages for registered dependencymanagers for the host to present member GetRegisteredDependencyManagerHelpText: - string seq * string MaybeNull * sdkDirOverride: string option * ResolvingErrorReport -> string[] + string seq * (string | null) * sdkDirOverride: string option * ResolvingErrorReport -> string[] /// Clear the DependencyManager results caches member ClearResultsCache: - string seq * string MaybeNull * sdkDirOverride: string option * ResolvingErrorReport -> unit + string seq * (string | null) * sdkDirOverride: string option * ResolvingErrorReport -> unit /// Returns a formatted error message for the host to present member CreatePackageManagerUnknownError: @@ -123,7 +123,7 @@ type DependencyProvider = packageManagerTextLines: (string * string) seq * reportError: ResolvingErrorReport * executionTfm: string * - [] executionRid: string MaybeNull * + [] executionRid: (string | null) * [] implicitIncludeDir: string * [] mainScriptName: string * [] fileName: string * diff --git a/src/Compiler/Driver/CompilerImports.fs b/src/Compiler/Driver/CompilerImports.fs index 4b25b38633b..dc6d346048b 100644 --- a/src/Compiler/Driver/CompilerImports.fs +++ b/src/Compiler/Driver/CompilerImports.fs @@ -1455,7 +1455,7 @@ and [] TcImports | _ -> None #if !NO_TYPEPROVIDERS - member tcImports.GetProvidedAssemblyInfo(ctok, m, assembly: Tainted) = + member tcImports.GetProvidedAssemblyInfo(ctok, m, assembly: Tainted<(ProvidedAssembly | null)>) = match assembly with | Tainted.Null -> false, None | Tainted.NonNull assembly -> diff --git a/src/Compiler/Driver/FxResolver.fs b/src/Compiler/Driver/FxResolver.fs index d98f002b184..f9d39d3ba53 100644 --- a/src/Compiler/Driver/FxResolver.fs +++ b/src/Compiler/Driver/FxResolver.fs @@ -58,12 +58,12 @@ type internal FxResolver let mutable errorslock = obj let mutable outputlock = obj - let outputDataReceived (message: string MaybeNull) = + let outputDataReceived (message: string | null) = match message with | Null -> () | NonNull message -> lock outputlock (fun () -> outputList.Add(message)) - let errorDataReceived (message: string MaybeNull) = + let errorDataReceived (message: string | null) = match message with | Null -> () | NonNull message -> lock errorslock (fun () -> errorsList.Add(message)) diff --git a/src/Compiler/FSharp.Compiler.Service.fsproj b/src/Compiler/FSharp.Compiler.Service.fsproj index a249c5d2bb1..2f389e3f8f7 100644 --- a/src/Compiler/FSharp.Compiler.Service.fsproj +++ b/src/Compiler/FSharp.Compiler.Service.fsproj @@ -101,7 +101,7 @@ - + FSComp.txt diff --git a/src/Compiler/Facilities/CompilerLocation.fs b/src/Compiler/Facilities/CompilerLocation.fs index f99f9d9d4ca..53e885ef075 100644 --- a/src/Compiler/Facilities/CompilerLocation.fs +++ b/src/Compiler/Facilities/CompilerLocation.fs @@ -22,7 +22,7 @@ module internal FSharpEnvironment = let FSharpProductName = UtilsStrings.SR.buildProductName (FSharpBannerVersion) - let versionOf<'t> : MaybeNull = + let versionOf<'t> : (string | null) = match typeof<'t>.Assembly.GetName().Version with | null -> null | v -> v.ToString() diff --git a/src/Compiler/Facilities/SimulatedMSBuildReferenceResolver.fs b/src/Compiler/Facilities/SimulatedMSBuildReferenceResolver.fs index 926a99efbb5..5dfcdbbc9c3 100644 --- a/src/Compiler/Facilities/SimulatedMSBuildReferenceResolver.fs +++ b/src/Compiler/Facilities/SimulatedMSBuildReferenceResolver.fs @@ -69,7 +69,7 @@ let private SimulatedMSBuildResolver = let isDesktop = typeof.Assembly.GetName().Name = "mscorlib" if isDesktop then - match (System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory(): string MaybeNull) with + match (System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory(): string | null) with | null -> [] | x -> [ x ] else diff --git a/src/Compiler/Interactive/fsi.fs b/src/Compiler/Interactive/fsi.fs index 33d7a7a04d1..5f4d9295bec 100644 --- a/src/Compiler/Interactive/fsi.fs +++ b/src/Compiler/Interactive/fsi.fs @@ -376,7 +376,7 @@ type ILMultiInMemoryAssemblyEmitEnv let typT = convTypeRef tref let tyargs = List.map convTypeAux tspec.GenericArgs - let res: Type MaybeNull = + let res: Type | null = match isNil tyargs, typT.IsGenericType with | _, true -> typT.MakeGenericType(List.toArray tyargs) | true, false -> typT @@ -974,11 +974,15 @@ type internal FsiCommandLineOptions(fsi: FsiEvaluationSessionHostConfig, argv: s let executableFileNameWithoutExtension = lazy let getFsiCommandLine () = - let fileNameWithoutExtension (path: string MaybeNull) = Path.GetFileNameWithoutExtension(path) + let fileNameWithoutExtension (path: string | null) = Path.GetFileNameWithoutExtension(path) let currentProcess = Process.GetCurrentProcess() let mainModule = currentProcess.MainModule - let processFileName = fileNameWithoutExtension (mainModule ^ _.FileName) + + let processFileName = + match mainModule with + | null -> null + | m -> fileNameWithoutExtension m.FileName let commandLineExecutableFileName = try @@ -2468,7 +2472,7 @@ type internal FsiDynamicCompiler member _.DynamicAssemblies = dynamicAssemblies.ToArray() member _.FindDynamicAssembly(name, useFullName: bool) = - let getName (assemblyName: AssemblyName) : string MaybeNull = + let getName (assemblyName: AssemblyName) : string | null = if useFullName then assemblyName.FullName else @@ -3316,7 +3320,7 @@ type internal MagicAssemblyResolution() = fsiDynamicCompiler: FsiDynamicCompiler, fsiConsoleOutput: FsiConsoleOutput, fullAssemName: string - ) : Assembly MaybeNull = + ) : Assembly | null = try // Grab the name of the assembly @@ -3472,7 +3476,7 @@ type internal MagicAssemblyResolution() = fsiDynamicCompiler: FsiDynamicCompiler, fsiConsoleOutput: FsiConsoleOutput, fullAssemName: string - ) : Assembly MaybeNull = + ) : Assembly | null = //Eliminate recursive calls to Resolve which can happen via our callout to msbuild resolution if MagicAssemblyResolution.resolving then @@ -3534,7 +3538,7 @@ type FsiStdinLexerProvider lexResourceManager: LexResourceManager ) = - let LexbufFromLineReader (fsiStdinSyphon: FsiStdinSyphon) (readF: unit -> string MaybeNull) = + let LexbufFromLineReader (fsiStdinSyphon: FsiStdinSyphon) (readF: unit -> string | null) = UnicodeLexing.FunctionAsLexbuf( true, tcConfigB.langVersion, @@ -3578,7 +3582,7 @@ type FsiStdinLexerProvider // Reading stdin as a lex stream //---------------------------------------------------------------------------- - let removeZeroCharsFromString (str: string MaybeNull) : string MaybeNull = + let removeZeroCharsFromString (str: string | null) : string | null = match str with | Null -> str | NonNull str -> diff --git a/src/Compiler/Service/QuickParse.fs b/src/Compiler/Service/QuickParse.fs index db377baf6bb..41345d0c415 100644 --- a/src/Compiler/Service/QuickParse.fs +++ b/src/Compiler/Service/QuickParse.fs @@ -180,7 +180,7 @@ module QuickParse = let pos = r + MagicalAdjustmentConstant Some(ident, pos, false)) - let GetCompleteIdentifierIslandImpl (lineStr: string MaybeNull) (index: int) : (string * int * bool) option = + let GetCompleteIdentifierIslandImpl (lineStr: string | null) (index: int) : (string * int * bool) option = match lineStr with | Null -> None | NonNull lineStr -> GetCompleteIdentifierIslandImplAux lineStr index @@ -208,7 +208,7 @@ module QuickParse = /// a call to `DeclItemsForNamesAtPosition` for intellisense. This will /// allow us to use find the correct qualified items rather than resorting /// to the more expensive and less accurate environment lookup. - let GetCompleteIdentifierIsland (tolerateJustAfter: bool) (lineStr: string MaybeNull) (index: int) : (string * int * bool) option = + let GetCompleteIdentifierIsland (tolerateJustAfter: bool) (lineStr: string | null) (index: int) : (string * int * bool) option = if String.IsNullOrEmpty lineStr then None else @@ -274,7 +274,7 @@ module QuickParse = let result = InResidue(index, index) result - let GetPartialLongName (lineStr: string MaybeNull, index: int) = + let GetPartialLongName (lineStr: string | null, index: int) = match lineStr with | Null -> defaultName | NonNull lineStr -> GetPartialLongNameAux(lineStr, index) @@ -429,7 +429,7 @@ module QuickParse = QualifyingIdents = plid } - let GetPartialLongNameEx (lineStr: string MaybeNull, index: int) : PartialLongName = + let GetPartialLongNameEx (lineStr: string | null, index: int) : PartialLongName = match lineStr with | Null -> PartialLongName.Empty(index) | NonNull lineStr -> GetPartialLongNameExAux(lineStr, index) diff --git a/src/Compiler/Service/QuickParse.fsi b/src/Compiler/Service/QuickParse.fsi index ad3d434ada7..df045c9f4ec 100644 --- a/src/Compiler/Service/QuickParse.fsi +++ b/src/Compiler/Service/QuickParse.fsi @@ -73,14 +73,14 @@ module public QuickParse = /// allow us to use find the correct qualified items rather than resorting /// to the more expensive and less accurate environment lookup. val GetCompleteIdentifierIsland: - tolerateJustAfter: bool -> lineStr: string MaybeNull -> index: int -> (string * int * bool) option + tolerateJustAfter: bool -> lineStr: (string | null) -> index: int -> (string * int * bool) option /// Get the partial long name of the identifier to the left of index. - val GetPartialLongName: lineStr: string MaybeNull * index: int -> string list * string + val GetPartialLongName: lineStr: (string | null) * index: int -> string list * string /// Get the partial long name of the identifier to the left of index. /// For example, for `System.DateTime.Now` it returns PartialLongName ([|"System"; "DateTime"|], "Now", Some 32), where "32" pos of the last dot. - val GetPartialLongNameEx: lineStr: string MaybeNull * index: int -> PartialLongName + val GetPartialLongNameEx: lineStr: (string | null) * index: int -> PartialLongName /// Tests whether the user is typing something like "member x." or "override (*comment*) x." val TestMemberOrOverrideDeclaration: tokens: FSharpTokenInfo[] -> bool diff --git a/src/Compiler/TypedTree/TypeProviders.fs b/src/Compiler/TypedTree/TypeProviders.fs index e20d683a121..cdc5e8e8b05 100644 --- a/src/Compiler/TypedTree/TypeProviders.fs +++ b/src/Compiler/TypedTree/TypeProviders.fs @@ -22,9 +22,9 @@ open FSharp.Compiler.Text open FSharp.Compiler.Text.Range type TypeProviderDesignation = TypeProviderDesignation of string -type 'a ProvidedArray= 'a[] MaybeNull -module ProvidedArray = - let map f (arr:_ ProvidedArray) : _ ProvidedArray = + +module NullableArray = + let map f (arr: ('a[] | null)) : ('b[] | null) = match arr with | null -> null | notNull -> notNull |> Array.map f @@ -242,7 +242,7 @@ let DisplayNameOfTypeProvider(resolver: Tainted, m: range) = resolver.PUntaint((fun tp -> tp.GetType().Name), m) /// Validate a provided namespace name -let ValidateNamespaceName(name, typeProvider: Tainted, m, nsp: string MaybeNull) = +let ValidateNamespaceName(name, typeProvider: Tainted, m, nsp: string | null) = match nsp with | Null -> () | NonNull nsp -> @@ -363,13 +363,13 @@ type ProvidedType (x: Type, ctxt: ProvidedTypeContext) = member _.IsGenericType = x.IsGenericType - member _.Namespace : string MaybeNull = x.Namespace + member _.Namespace : string | null = x.Namespace - member _.FullName : string MaybeNull = x.FullName + member _.FullName : string | null = x.FullName member _.IsArray = x.IsArray - member _.Assembly: ProvidedAssembly MaybeNull = x.Assembly |> ProvidedAssembly.Create + member _.Assembly: ProvidedAssembly | null = x.Assembly |> ProvidedAssembly.Create member _.GetInterfaces() = x.GetInterfaces() |> ProvidedType.CreateArray ctxt @@ -402,7 +402,7 @@ type ProvidedType (x: Type, ctxt: ProvidedTypeContext) = /// Type.BaseType can be null when Type is interface or object member _.BaseType = x.BaseType |> ProvidedType.Create ctxt - member _.GetStaticParameters(provider: ITypeProvider) : ProvidedParameterInfo ProvidedArray = provider.GetStaticParameters x |> ProvidedParameterInfo.CreateArray ctxt + member _.GetStaticParameters(provider: ITypeProvider) : ProvidedParameterInfo[] | null = provider.GetStaticParameters x |> ProvidedParameterInfo.CreateArray ctxt /// Type.GetElementType can be null if i.e. Type is not array\pointer\byref type member _.GetElementType() = x.GetElementType() |> ProvidedType.Create ctxt @@ -463,20 +463,20 @@ type ProvidedType (x: Type, ctxt: ProvidedTypeContext) = member _.AsProvidedVar name = ProvidedVar.CreateNonNull ctxt (Var(name, x)) - static member Create ctxt x : ProvidedType MaybeNull = + static member Create ctxt x : ProvidedType | null = match x with | Null -> null | NonNull t -> ProvidedType (t, ctxt) static member CreateNonNull ctxt x = ProvidedType (x, ctxt) - static member CreateWithNullCheck ctxt name (x:Type MaybeNull) = + static member CreateWithNullCheck ctxt name (x:Type | null) = match x with | null -> nullArg name | t -> ProvidedType (t, ctxt) - static member CreateArray ctxt (xs:_ ProvidedArray) = - xs |> ProvidedArray.map (ProvidedType.CreateNonNull ctxt) + static member CreateArray ctxt (xs: Type[] | null) = + xs |> NullableArray.map (ProvidedType.CreateNonNull ctxt) static member CreateNoContext (x:Type) = ProvidedType.CreateNonNull ProvidedTypeContext.Empty x @@ -500,7 +500,7 @@ type ProvidedType (x: Type, ctxt: ProvidedTypeContext) = Tainted.EqTainted (pt1.PApplyNoFailure(fun st -> st.Handle)) (pt2.PApplyNoFailure(fun st -> st.Handle)) type IProvidedCustomAttributeProvider = - abstract GetDefinitionLocationAttribute : provider: ITypeProvider -> (string MaybeNull * int * int) option + abstract GetDefinitionLocationAttribute : provider: ITypeProvider -> ((string | null) * int * int) option abstract GetXmlDocAttributes : provider: ITypeProvider -> string[] @@ -542,7 +542,7 @@ type ProvidedCustomAttributeProvider (attributes :ITypeProvider -> seq Seq.tryFind (findAttrib typeof) |> Option.map (fun a -> - let filePath : string MaybeNull = defaultArg (a.NamedArguments |> Seq.tryPick (function Member "FilePath" (Arg (:? string as v)) -> Some v | _ -> None)) null + let filePath : string | null = a.NamedArguments |> Seq.tryPick (function Member "FilePath" (Arg (:? string as v)) -> Some v | _ -> None) |> Option.toObj let line = defaultArg (a.NamedArguments |> Seq.tryPick (function Member "Line" (Arg (:? int as v)) -> Some v | _ -> None)) 0 let column = defaultArg (a.NamedArguments |> Seq.tryPick (function Member "Column" (Arg (:? int as v)) -> Some v | _ -> None)) 0 (filePath, line, column)) @@ -599,15 +599,15 @@ type ProvidedParameterInfo (x: ParameterInfo, ctxt) = /// ParameterInfo.ParameterType cannot be null member _.ParameterType = ProvidedType.CreateWithNullCheck ctxt "ParameterType" x.ParameterType - static member Create ctxt (x: ParameterInfo MaybeNull) : ProvidedParameterInfo MaybeNull = + static member Create ctxt (x: ParameterInfo | null) : ProvidedParameterInfo | null = match x with | Null -> null | NonNull x -> ProvidedParameterInfo (x, ctxt) static member CreateNonNull ctxt x = ProvidedParameterInfo (x, ctxt) - - static member CreateArray ctxt (xs: ParameterInfo ProvidedArray) : ProvidedParameterInfo ProvidedArray = - xs |> ProvidedArray.map (ProvidedParameterInfo.CreateNonNull ctxt) + + static member CreateArray ctxt (xs: ParameterInfo[] | null) : ProvidedParameterInfo[] | null = + xs |> NullableArray.map (ProvidedParameterInfo.CreateNonNull ctxt) interface IProvidedCustomAttributeProvider with member _.GetHasTypeProviderEditorHideMethodsAttribute provider = @@ -637,7 +637,7 @@ type ProvidedAssembly (x: Assembly) = member _.GetManifestModuleContents(provider: ITypeProvider) = provider.GetGeneratedAssemblyContents x - static member Create (x: Assembly MaybeNull) : ProvidedAssembly MaybeNull = match x with null -> null | t -> ProvidedAssembly t + static member Create (x: Assembly | null) : ProvidedAssembly | null = match x with null -> null | t -> ProvidedAssembly t member _.Handle = x @@ -687,7 +687,7 @@ type ProvidedMethodBase (x: MethodBase, ctxt) = static member TaintedEquals (pt1: Tainted, pt2: Tainted) = Tainted.EqTainted (pt1.PApplyNoFailure(fun st -> st.Handle)) (pt2.PApplyNoFailure(fun st -> st.Handle)) - member _.GetStaticParametersForMethod(provider: ITypeProvider) : ProvidedParameterInfo ProvidedArray = + member _.GetStaticParametersForMethod(provider: ITypeProvider) : ProvidedParameterInfo[] | null = let bindingFlags = BindingFlags.Instance ||| BindingFlags.NonPublic ||| BindingFlags.Public let staticParams = @@ -745,13 +745,13 @@ type ProvidedFieldInfo (x: FieldInfo, ctxt) = static member CreateNonNull ctxt x = ProvidedFieldInfo (x, ctxt) - static member Create ctxt x : ProvidedFieldInfo MaybeNull = + static member Create ctxt x : ProvidedFieldInfo | null = match x with | Null -> null | NonNull x -> ProvidedFieldInfo (x, ctxt) - static member CreateArray ctxt (xs: FieldInfo ProvidedArray) : ProvidedFieldInfo ProvidedArray = - xs |> ProvidedArray.map (ProvidedFieldInfo.CreateNonNull ctxt) + static member CreateArray ctxt (xs: FieldInfo[] | null) : ProvidedFieldInfo[] | null = + xs |> NullableArray.map (ProvidedFieldInfo.CreateNonNull ctxt) member _.IsInitOnly = x.IsInitOnly @@ -795,14 +795,14 @@ type ProvidedMethodInfo (x: MethodInfo, ctxt) = static member CreateNonNull ctxt (x: MethodInfo) : ProvidedMethodInfo = ProvidedMethodInfo (x, ctxt) - static member Create ctxt (x: MethodInfo MaybeNull) : ProvidedMethodInfo MaybeNull = + static member Create ctxt (x: MethodInfo | null) : ProvidedMethodInfo | null = match x with | Null -> null | NonNull x -> ProvidedMethodInfo (x, ctxt) - static member CreateArray ctxt (xs: MethodInfo ProvidedArray) : ProvidedMethodInfo ProvidedArray = - xs |> ProvidedArray.map (ProvidedMethodInfo.CreateNonNull ctxt) + static member CreateArray ctxt (xs: MethodInfo[] | null) : ProvidedMethodInfo[] | null = + xs |> NullableArray.map (ProvidedMethodInfo.CreateNonNull ctxt) member _.Handle = x @@ -831,13 +831,13 @@ type ProvidedPropertyInfo (x: PropertyInfo, ctxt) = static member CreateNonNull ctxt x = ProvidedPropertyInfo (x, ctxt) - static member Create ctxt x : ProvidedPropertyInfo MaybeNull = + static member Create ctxt x : ProvidedPropertyInfo | null = match x with | Null -> null | NonNull x -> ProvidedPropertyInfo (x, ctxt) - static member CreateArray ctxt (xs: PropertyInfo ProvidedArray) : ProvidedPropertyInfo ProvidedArray = - xs |> ProvidedArray.map (ProvidedPropertyInfo.CreateNonNull ctxt) + static member CreateArray ctxt (xs: PropertyInfo[] | null) : ProvidedPropertyInfo[] | null = + xs |> NullableArray.map (ProvidedPropertyInfo.CreateNonNull ctxt) member _.Handle = x @@ -866,13 +866,13 @@ type ProvidedEventInfo (x: EventInfo, ctxt) = static member CreateNonNull ctxt x = ProvidedEventInfo (x, ctxt) - static member Create ctxt x : ProvidedEventInfo MaybeNull = + static member Create ctxt x : ProvidedEventInfo | null = match x with | Null -> null | NonNull x -> ProvidedEventInfo (x, ctxt) - static member CreateArray ctxt (xs: EventInfo ProvidedArray) : ProvidedEventInfo ProvidedArray = - xs |> ProvidedArray.map (ProvidedEventInfo.CreateNonNull ctxt) + static member CreateArray ctxt (xs: EventInfo[] | null) : ProvidedEventInfo[] | null = + xs |> NullableArray.map (ProvidedEventInfo.CreateNonNull ctxt) member _.Handle = x @@ -894,13 +894,13 @@ type ProvidedConstructorInfo (x: ConstructorInfo, ctxt) = static member CreateNonNull ctxt x = ProvidedConstructorInfo (x, ctxt) - static member Create ctxt (x: ConstructorInfo MaybeNull) : ProvidedConstructorInfo MaybeNull = + static member Create ctxt (x: ConstructorInfo | null) : ProvidedConstructorInfo | null = match x with | Null -> null | NonNull x -> ProvidedConstructorInfo (x, ctxt) - static member CreateArray ctxt (xs: ConstructorInfo ProvidedArray) : ProvidedConstructorInfo ProvidedArray = - xs |> ProvidedArray.map (ProvidedConstructorInfo.CreateNonNull ctxt) + static member CreateArray ctxt (xs: ConstructorInfo[] | null) : ProvidedConstructorInfo[] | null = + xs |> NullableArray.map (ProvidedConstructorInfo.CreateNonNull ctxt) member _.Handle = x @@ -909,19 +909,19 @@ type ProvidedConstructorInfo (x: ConstructorInfo, ctxt) = override _.GetHashCode() = assert false; x.GetHashCode() type ProvidedExprType = - | ProvidedNewArrayExpr of ProvidedType * ProvidedExpr ProvidedArray - | ProvidedNewObjectExpr of ProvidedConstructorInfo * ProvidedExpr ProvidedArray + | ProvidedNewArrayExpr of ProvidedType * (ProvidedExpr[] | null) + | ProvidedNewObjectExpr of ProvidedConstructorInfo * (ProvidedExpr[] | null) | ProvidedWhileLoopExpr of ProvidedExpr * ProvidedExpr - | ProvidedNewDelegateExpr of ProvidedType * ProvidedVar ProvidedArray * ProvidedExpr + | ProvidedNewDelegateExpr of ProvidedType * (ProvidedVar[] | null) * ProvidedExpr | ProvidedForIntegerRangeLoopExpr of ProvidedVar * ProvidedExpr * ProvidedExpr * ProvidedExpr | ProvidedSequentialExpr of ProvidedExpr * ProvidedExpr | ProvidedTryWithExpr of ProvidedExpr * ProvidedVar * ProvidedExpr * ProvidedVar * ProvidedExpr | ProvidedTryFinallyExpr of ProvidedExpr * ProvidedExpr | ProvidedLambdaExpr of ProvidedVar * ProvidedExpr - | ProvidedCallExpr of ProvidedExpr option * ProvidedMethodInfo * ProvidedExpr ProvidedArray + | ProvidedCallExpr of ProvidedExpr option * ProvidedMethodInfo * (ProvidedExpr[] | null) | ProvidedConstantExpr of objnull * ProvidedType | ProvidedDefaultExpr of ProvidedType - | ProvidedNewTupleExpr of ProvidedExpr ProvidedArray + | ProvidedNewTupleExpr of (ProvidedExpr[] | null) | ProvidedTupleGetExpr of ProvidedExpr * int | ProvidedTypeAsExpr of ProvidedExpr * ProvidedType | ProvidedTypeTestExpr of ProvidedExpr * ProvidedType @@ -986,7 +986,7 @@ type ProvidedExpr (x: Expr, ctxt) = | Patterns.Var v -> Some (ProvidedVarExpr (ProvidedVar.CreateNonNull ctxt v)) | _ -> None - static member Create ctxt t : ProvidedExpr MaybeNull = + static member Create ctxt t : ProvidedExpr | null = match box t with | Null -> null | _ -> ProvidedExpr (t, ctxt) @@ -1029,7 +1029,7 @@ let GetInvokerExpression (provider: ITypeProvider, methodBase: ProvidedMethodBas /// Compute the Name or FullName property of a provided type, reporting appropriate errors let CheckAndComputeProvidedNameProperty(m, st: Tainted, proj, propertyString) = - let name : string MaybeNull = + let name : string | null = try st.PUntaint(proj, m) with :? TypeProviderError as tpe -> let newError = tpe.MapText((fun msg -> FSComp.SR.etProvidedTypeWithNameException(propertyString, msg)), st.TypeProviderDesignation, m) @@ -1202,7 +1202,7 @@ let ValidateProvidedTypeDefinition(m, st: Tainted, expectedPath: s /// Resolve a (non-nested) provided type given a full namespace name and a type name. /// May throw an exception which will be turned into an error message by one of the 'Try' function below. /// If resolution is successful the type is then validated. -let ResolveProvidedType (resolver: Tainted, m, moduleOrNamespace: string[], typeName) : Tainted = +let ResolveProvidedType (resolver: Tainted, m, moduleOrNamespace: string[], typeName) : Tainted<(ProvidedType | null)> = let displayName = String.Join(".", moduleOrNamespace) // Try to find the type in the given provided namespace @@ -1386,7 +1386,7 @@ let TryLinkProvidedType(resolver: Tainted, moduleOrNamespace: str | None -> None /// Get the parts of a .NET namespace. Special rules: null means global, empty is not allowed. -let GetPartsOfNamespaceRecover(namespaceName: string MaybeNull) = +let GetPartsOfNamespaceRecover(namespaceName: string | null) = match namespaceName with | Null -> [] | NonNull namespaceName -> @@ -1394,7 +1394,7 @@ let GetPartsOfNamespaceRecover(namespaceName: string MaybeNull) = else splitNamespace namespaceName /// Get the parts of a .NET namespace. Special rules: null means global, empty is not allowed. -let GetProvidedNamespaceAsPath (m, resolver: Tainted, namespaceName:string MaybeNull) = +let GetProvidedNamespaceAsPath (m, resolver: Tainted, namespaceName: string | null) = match namespaceName with | Null -> [] | NonNull namespaceName -> @@ -1407,7 +1407,7 @@ let GetFSharpPathToProvidedType (st: Tainted, range) = // Can't use st.Fullname because it may be like IEnumerable // We want [System;Collections;Generic] let namespaceParts = GetPartsOfNamespaceRecover(st.PUntaint((fun st -> st.Namespace), range)) - let rec walkUpNestedClasses(st: Tainted, soFar) = + let rec walkUpNestedClasses(st: Tainted<(ProvidedType | null)>, soFar) = match st with | Tainted.Null -> soFar | Tainted.NonNull st -> walkUpNestedClasses(st.PApply((fun st ->st.DeclaringType), range), soFar) @ [st.PUntaint((fun st -> st.Name), range)] diff --git a/src/Compiler/TypedTree/TypeProviders.fsi b/src/Compiler/TypedTree/TypeProviders.fsi index a6ec5807198..a687c831053 100755 --- a/src/Compiler/TypedTree/TypeProviders.fsi +++ b/src/Compiler/TypedTree/TypeProviders.fsi @@ -15,7 +15,6 @@ open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler.Text type TypeProviderDesignation = TypeProviderDesignation of string -type 'a ProvidedArray = 'a[] MaybeNull /// Raised when a type provider has thrown an exception. exception ProvidedTypeResolution of range * exn @@ -102,41 +101,41 @@ type ProvidedType = member IsGenericType: bool - member Namespace: string MaybeNull + member Namespace: (string | null) - member FullName: string MaybeNull + member FullName: (string | null) member IsArray: bool - member GetInterfaces: unit -> ProvidedType ProvidedArray + member GetInterfaces: unit -> (ProvidedType[] | null) - member Assembly: ProvidedAssembly MaybeNull + member Assembly: (ProvidedAssembly | null) - member BaseType: ProvidedType MaybeNull + member BaseType: (ProvidedType | null) - member GetNestedType: string -> ProvidedType MaybeNull + member GetNestedType: string -> (ProvidedType | null) - member GetNestedTypes: unit -> ProvidedType ProvidedArray + member GetNestedTypes: unit -> (ProvidedType[] | null) - member GetAllNestedTypes: unit -> ProvidedType ProvidedArray + member GetAllNestedTypes: unit -> (ProvidedType[] | null) - member GetMethods: unit -> ProvidedMethodInfo ProvidedArray + member GetMethods: unit -> (ProvidedMethodInfo[] | null) - member GetFields: unit -> ProvidedFieldInfo ProvidedArray + member GetFields: unit -> (ProvidedFieldInfo[] | null) - member GetField: string -> ProvidedFieldInfo MaybeNull + member GetField: string -> (ProvidedFieldInfo | null) - member GetProperties: unit -> ProvidedPropertyInfo ProvidedArray + member GetProperties: unit -> (ProvidedPropertyInfo[] | null) - member GetProperty: string -> ProvidedPropertyInfo MaybeNull + member GetProperty: string -> (ProvidedPropertyInfo | null) - member GetEvents: unit -> ProvidedEventInfo ProvidedArray + member GetEvents: unit -> (ProvidedEventInfo[] | null) - member GetEvent: string -> ProvidedEventInfo MaybeNull + member GetEvent: string -> (ProvidedEventInfo | null) - member GetConstructors: unit -> ProvidedConstructorInfo ProvidedArray + member GetConstructors: unit -> (ProvidedConstructorInfo[] | null) - member GetStaticParameters: ITypeProvider -> ProvidedParameterInfo ProvidedArray + member GetStaticParameters: ITypeProvider -> (ProvidedParameterInfo[] | null) member GetGenericTypeDefinition: unit -> ProvidedType @@ -168,9 +167,9 @@ type ProvidedType = member GenericParameterPosition: int - member GetElementType: unit -> ProvidedType MaybeNull + member GetElementType: unit -> (ProvidedType | null) - member GetGenericArguments: unit -> ProvidedType ProvidedArray + member GetGenericArguments: unit -> (ProvidedType[] | null) member GetArrayRank: unit -> int @@ -209,7 +208,7 @@ type ProvidedType = type IProvidedCustomAttributeProvider = abstract GetHasTypeProviderEditorHideMethodsAttribute: provider: ITypeProvider -> bool - abstract GetDefinitionLocationAttribute: provider: ITypeProvider -> (string MaybeNull * int * int) option + abstract GetDefinitionLocationAttribute: provider: ITypeProvider -> ((string | null) * int * int) option abstract GetXmlDocAttributes: provider: ITypeProvider -> string[] @@ -231,7 +230,7 @@ type ProvidedMemberInfo = member Name: string - member DeclaringType: ProvidedType MaybeNull + member DeclaringType: (ProvidedType | null) interface IProvidedCustomAttributeProvider @@ -261,11 +260,11 @@ type ProvidedMethodBase = member IsConstructor: bool - member GetParameters: unit -> ProvidedParameterInfo ProvidedArray + member GetParameters: unit -> (ProvidedParameterInfo[] | null) - member GetGenericArguments: unit -> ProvidedType ProvidedArray + member GetGenericArguments: unit -> (ProvidedType[] | null) - member GetStaticParametersForMethod: ITypeProvider -> ProvidedParameterInfo ProvidedArray + member GetStaticParametersForMethod: ITypeProvider -> (ProvidedParameterInfo[] | null) static member TaintedGetHashCode: Tainted -> int @@ -333,11 +332,11 @@ type ProvidedPropertyInfo = inherit ProvidedMemberInfo - member GetGetMethod: unit -> ProvidedMethodInfo MaybeNull + member GetGetMethod: unit -> (ProvidedMethodInfo | null) - member GetSetMethod: unit -> ProvidedMethodInfo MaybeNull + member GetSetMethod: unit -> (ProvidedMethodInfo | null) - member GetIndexParameters: unit -> ProvidedParameterInfo ProvidedArray + member GetIndexParameters: unit -> (ProvidedParameterInfo[] | null) member CanRead: bool @@ -354,9 +353,9 @@ type ProvidedEventInfo = inherit ProvidedMemberInfo - member GetAddMethod: unit -> ProvidedMethodInfo MaybeNull + member GetAddMethod: unit -> (ProvidedMethodInfo | null) - member GetRemoveMethod: unit -> ProvidedMethodInfo MaybeNull + member GetRemoveMethod: unit -> (ProvidedMethodInfo | null) member EventHandlerType: ProvidedType @@ -370,13 +369,13 @@ type ProvidedConstructorInfo = type ProvidedExprType = - | ProvidedNewArrayExpr of ProvidedType * ProvidedExpr ProvidedArray + | ProvidedNewArrayExpr of ProvidedType * (ProvidedExpr[] | null) - | ProvidedNewObjectExpr of ProvidedConstructorInfo * ProvidedExpr ProvidedArray + | ProvidedNewObjectExpr of ProvidedConstructorInfo * (ProvidedExpr[] | null) | ProvidedWhileLoopExpr of ProvidedExpr * ProvidedExpr - | ProvidedNewDelegateExpr of ProvidedType * ProvidedVar ProvidedArray * ProvidedExpr + | ProvidedNewDelegateExpr of ProvidedType * (ProvidedVar[] | null) * ProvidedExpr | ProvidedForIntegerRangeLoopExpr of ProvidedVar * ProvidedExpr * ProvidedExpr * ProvidedExpr @@ -388,13 +387,13 @@ type ProvidedExprType = | ProvidedLambdaExpr of ProvidedVar * ProvidedExpr - | ProvidedCallExpr of ProvidedExpr option * ProvidedMethodInfo * ProvidedExpr ProvidedArray + | ProvidedCallExpr of ProvidedExpr option * ProvidedMethodInfo * (ProvidedExpr[] | null) | ProvidedConstantExpr of objnull * ProvidedType | ProvidedDefaultExpr of ProvidedType - | ProvidedNewTupleExpr of ProvidedExpr ProvidedArray + | ProvidedNewTupleExpr of (ProvidedExpr[] | null) | ProvidedTupleGetExpr of ProvidedExpr * int @@ -432,7 +431,7 @@ type ProvidedVar = override GetHashCode: unit -> int /// Get the provided expression for a particular use of a method. -val GetInvokerExpression: ITypeProvider * ProvidedMethodBase * ProvidedVar[] -> ProvidedExpr MaybeNull +val GetInvokerExpression: ITypeProvider * ProvidedMethodBase * ProvidedVar[] -> (ProvidedExpr | null) /// Validate that the given provided type meets some of the rules for F# provided types val ValidateProvidedTypeAfterStaticInstantiation: @@ -460,7 +459,7 @@ val TryLinkProvidedType: Tainted * string[] * typeLogicalName: string * range: range -> Tainted option /// Get the parts of a .NET namespace. Special rules: null means global, empty is not allowed. -val GetProvidedNamespaceAsPath: range * Tainted * string MaybeNull -> string list +val GetProvidedNamespaceAsPath: range * Tainted * (string | null) -> string list /// Decompose the enclosing name of a type (including any class nestings) into a list of parts. /// e.g. System.Object -> ["System"; "Object"] diff --git a/src/Compiler/TypedTree/TypedTreeOps.fs b/src/Compiler/TypedTree/TypedTreeOps.fs index 89c039379e5..89985c45ce5 100644 --- a/src/Compiler/TypedTree/TypedTreeOps.fs +++ b/src/Compiler/TypedTree/TypedTreeOps.fs @@ -34,7 +34,7 @@ open FSharp.Compiler.TypedTreeBasics open FSharp.Compiler.TypeProviders #endif -let inline compareBy (x: 'T MaybeNull) (y: 'T MaybeNull) ([]func: 'T -> 'K) = +let inline compareBy (x: 'T | null) (y: 'T | null) ([]func: 'T -> 'K) = match x,y with | null,null -> 0 | null,_ -> -1 @@ -8292,7 +8292,7 @@ let mkCompilationMappingAttrForQuotationResource (g: TcGlobals) (nm, tys: ILType let isTypeProviderAssemblyAttr (cattr: ILAttribute) = cattr.Method.DeclaringType.BasicQualifiedName = !! typeof.FullName -let TryDecodeTypeProviderAssemblyAttr (cattr: ILAttribute) : string MaybeNull option = +let TryDecodeTypeProviderAssemblyAttr (cattr: ILAttribute) : (string | null) option = if isTypeProviderAssemblyAttr cattr then let params_, _args = decodeILAttribData cattr match params_ with // The first parameter to the attribute is the name of the assembly with the compiler extensions. diff --git a/src/Compiler/TypedTree/TypedTreeOps.fsi b/src/Compiler/TypedTree/TypedTreeOps.fsi index cb7f0e2bb6f..e5bff312024 100755 --- a/src/Compiler/TypedTree/TypedTreeOps.fsi +++ b/src/Compiler/TypedTree/TypedTreeOps.fsi @@ -2405,7 +2405,7 @@ val TryFindAttributeUsageAttribute: TcGlobals -> range -> TyconRef -> bool optio #if !NO_TYPEPROVIDERS /// returns Some(assemblyName) for success -val TryDecodeTypeProviderAssemblyAttr: ILAttribute -> string MaybeNull option +val TryDecodeTypeProviderAssemblyAttr: ILAttribute -> (string | null) option #endif val IsSignatureDataVersionAttr: ILAttribute -> bool diff --git a/src/Compiler/TypedTree/tainted.fs b/src/Compiler/TypedTree/tainted.fs index 8b3561aaaa3..1017d62ef62 100644 --- a/src/Compiler/TypedTree/tainted.fs +++ b/src/Compiler/TypedTree/tainted.fs @@ -133,13 +133,13 @@ type internal Tainted<'T> (context: TaintedContext, value: 'T) = Tainted(context, u) member this.PApplyArray(f, methodName, range:range) = - let a : 'U[] MaybeNull = this.Protect f range + let a : 'U[] | null = this.Protect f range match a with | Null -> raise <| TypeProviderError(FSComp.SR.etProviderReturnedNull(methodName), this.TypeProviderDesignation, range) | NonNull a -> a |> Array.map (fun u -> Tainted(context,u)) member this.PApplyFilteredArray(factory, filter, methodName, range:range) = - let a : 'U[] MaybeNull = this.Protect factory range + let a : 'U[] | null = this.Protect factory range match a with | Null -> raise <| TypeProviderError(FSComp.SR.etProviderReturnedNull(methodName), this.TypeProviderDesignation, range) | NonNull a -> a |> Array.filter filter |> Array.map (fun u -> Tainted(context,u)) diff --git a/src/Compiler/TypedTree/tainted.fsi b/src/Compiler/TypedTree/tainted.fsi index b75c8c43a5b..2d3e5baa465 100644 --- a/src/Compiler/TypedTree/tainted.fsi +++ b/src/Compiler/TypedTree/tainted.fsi @@ -78,10 +78,10 @@ type internal Tainted<'T> = member PApplyWithProvider: ('T * ITypeProvider -> 'U) * range: range -> Tainted<'U> /// Apply an operation that returns an 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 PApplyArray: ('T -> 'U[] MaybeNull) * string * range: range -> Tainted<'U>[] + member PApplyArray: ('T -> ('U[] | null)) * 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[] | null)) * ('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,7 +104,7 @@ type internal Tainted<'T> = module internal Tainted = /// Test whether the tainted value is null - val (|Null|NonNull|): Tainted<'T MaybeNull> -> Choice> when 'T: not null and 'T: not struct + val (|Null|NonNull|): Tainted<('T | null)> -> 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 6ceaaa51eab..ad4f9118118 100644 --- a/src/Compiler/Utilities/Activity.fs +++ b/src/Compiler/Utilities/Activity.fs @@ -253,7 +253,7 @@ module internal Activity = module CsvExport = - let private escapeStringForCsv (o: obj MaybeNull) = + let private escapeStringForCsv (o: (obj | null)) = match o with | null -> "" | o -> @@ -276,7 +276,7 @@ module internal Activity = let private createCsvRow (a: Activity) = let sb = StringBuilder(128) - let appendWithLeadingComma (s: string MaybeNull) = + let appendWithLeadingComma (s: (string | null)) = sb.Append(',') |> ignore sb.Append(s) |> ignore diff --git a/src/Compiler/Utilities/Cancellable.fs b/src/Compiler/Utilities/Cancellable.fs index bae9c6f8299..af7d99548f3 100644 --- a/src/Compiler/Utilities/Cancellable.fs +++ b/src/Compiler/Utilities/Cancellable.fs @@ -167,12 +167,12 @@ type CancellableBuilder() = | Choice2Of2 err -> Cancellable.run ct (handler err) | ValueOrCancelled.Cancelled err1 -> ValueOrCancelled.Cancelled err1) - member inline _.Using(resource: _ MaybeNull, [] comp) = + member inline _.Using(resource: (_ | null), [] comp) = Cancellable(fun ct -> __debugPoint "" - let body = comp resource + let body = comp (!!resource) let compRes = try diff --git a/src/Compiler/Utilities/Cancellable.fsi b/src/Compiler/Utilities/Cancellable.fsi index 0d82faa68cb..530445c0e02 100644 --- a/src/Compiler/Utilities/Cancellable.fsi +++ b/src/Compiler/Utilities/Cancellable.fsi @@ -68,8 +68,7 @@ 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> + resource: ('Resource | null) * [] comp: ('Resource -> 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/FileSystem.fs b/src/Compiler/Utilities/FileSystem.fs index a19df26aad1..5ff6b6e180e 100644 --- a/src/Compiler/Utilities/FileSystem.fs +++ b/src/Compiler/Utilities/FileSystem.fs @@ -615,19 +615,25 @@ type DefaultFileSystem() as this = abstract IsInvalidPathShim: path: string -> bool default _.IsInvalidPathShim(path: string) = - let isInvalidPath (p: string MaybeNull) = - if String.IsNullOrEmpty(p) then - true - else - p.IndexOfAny(Path.GetInvalidPathChars()) <> -1 + let isInvalidPath (p: (string | null)) = + match p with + | Null -> true + | NonNull p -> + if String.IsNullOrEmpty(p) then + true + else + p.IndexOfAny(Path.GetInvalidPathChars()) <> -1 - let isInvalidFilename (p: string MaybeNull) = - if String.IsNullOrEmpty(p) then - true - else - p.IndexOfAny(Path.GetInvalidFileNameChars()) <> -1 + let isInvalidFilename (p: (string | null)) = + match p with + | Null -> true + | NonNull p -> + if String.IsNullOrEmpty(p) then + true + else + p.IndexOfAny(Path.GetInvalidFileNameChars()) <> -1 - let isInvalidDirectory (d: string MaybeNull) = + let isInvalidDirectory (d: (string | null)) = match d with | Null -> true | NonNull d -> d.IndexOfAny(Path.GetInvalidPathChars()) <> -1 diff --git a/src/Compiler/Utilities/LruCache.fs b/src/Compiler/Utilities/LruCache.fs index 210c5d403f2..7ebd5576158 100644 --- a/src/Compiler/Utilities/LruCache.fs +++ b/src/Compiler/Utilities/LruCache.fs @@ -36,7 +36,7 @@ type internal LruCache<'TKey, 'TVersion, 'TValue let strongList = LinkedList<'TKey * 'TVersion * string * ValueLink<'TValue>>() let weakList = LinkedList<'TKey * 'TVersion * string * ValueLink<'TValue>>() - let rec removeCollected (possiblyNullNode: LinkedListNode<_> MaybeNull) = + let rec removeCollected (possiblyNullNode: (LinkedListNode<_> | null)) = match possiblyNullNode with | null -> () | node -> diff --git a/src/Compiler/Utilities/NullnessShims.fs b/src/Compiler/Utilities/NullHelpers.fs similarity index 61% rename from src/Compiler/Utilities/NullnessShims.fs rename to src/Compiler/Utilities/NullHelpers.fs index 7e96db2f495..fcc79601309 100644 --- a/src/Compiler/Utilities/NullnessShims.fs +++ b/src/Compiler/Utilities/NullHelpers.fs @@ -3,20 +3,13 @@ namespace Internal.Utilities.Library open System [] -module internal NullnessShims = +module internal NullHelpers = let inline isNotNull (x: 'T) = not (isNull x) - type 'T MaybeNull when 'T: not null and 'T: not struct = 'T | null - - let inline (^) (a: 'a | null) ([] b: 'a -> 'b) : ('b | null) = - match a with - | Null -> null - | NonNull v -> b v - 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: 'T | null) (y: 'T | null) ([] nonNullEqualityFunc: 'T -> 'T -> bool) = match x, y with | null, null -> true | null, _ @@ -32,7 +25,7 @@ module internal NullnessShims = #endif [] - let inline (|NonEmptyString|_|) (x: string MaybeNull) = + let inline (|NonEmptyString|_|) (x: string | null) = match x with | null -> ValueNone | "" -> ValueNone diff --git a/src/Compiler/Utilities/illib.fs b/src/Compiler/Utilities/illib.fs index ee33e444803..e58e4e2b756 100644 --- a/src/Compiler/Utilities/illib.fs +++ b/src/Compiler/Utilities/illib.fs @@ -121,11 +121,11 @@ module internal PervasiveAutoOpens = | Some x -> x let reportTime = - let mutable tPrev: IDisposable MaybeNull = null + let mutable tPrev: (IDisposable | null) = null fun descr -> if isNotNull tPrev then - tPrev.Dispose() + (!!tPrev).Dispose() tPrev <- null if descr <> "Finish" then @@ -155,8 +155,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 | null) = null + let mutable dictStore: (_ | null) = null let mutable func = f diff --git a/src/Compiler/Utilities/lib.fs b/src/Compiler/Utilities/lib.fs index a05bf5d20bc..25eac01e63b 100755 --- a/src/Compiler/Utilities/lib.fs +++ b/src/Compiler/Utilities/lib.fs @@ -25,7 +25,7 @@ let isEnvVarSet s = let GetEnvInteger e dflt = match Environment.GetEnvironmentVariable(e) with null -> dflt | t -> try int t with _ -> dflt -let dispose (x: IDisposable MaybeNull) = +let dispose (x: IDisposable | null) = match x with | Null -> () | NonNull x -> x.Dispose() @@ -403,7 +403,7 @@ type DisposablesTracker() = let items = Stack() /// Register some items to dispose - member _.Register (i:#IDisposable MaybeNull) = + member _.Register (i:#IDisposable | null) = match box i with | null -> () | _ -> items.Push (!!i) diff --git a/src/Compiler/Utilities/lib.fsi b/src/Compiler/Utilities/lib.fsi index c2147208ef9..86e8eca1405 100644 --- a/src/Compiler/Utilities/lib.fsi +++ b/src/Compiler/Utilities/lib.fsi @@ -19,7 +19,7 @@ val isEnvVarSet: s: string -> bool val GetEnvInteger: e: string -> dflt: int -> int -val dispose: x: System.IDisposable MaybeNull -> unit +val dispose: x: (System.IDisposable | null) -> unit module Bits = /// Get the least significant byte of a 32-bit integer @@ -263,7 +263,7 @@ type DisposablesTracker = new: unit -> DisposablesTracker /// Register some items to dispose - member Register: i: 'a MaybeNull -> unit when 'a :> System.IDisposable and 'a: not struct and 'a: not null + member Register: i: ('a | null) -> unit when 'a :> System.IDisposable and 'a: not struct and 'a: not null interface System.IDisposable diff --git a/src/FSharp.Build/FSharp.Build.fsproj b/src/FSharp.Build/FSharp.Build.fsproj index b38e2981b7b..e249e4e0f1a 100644 --- a/src/FSharp.Build/FSharp.Build.fsproj +++ b/src/FSharp.Build/FSharp.Build.fsproj @@ -33,7 +33,7 @@ - + diff --git a/src/FSharp.Build/FSharpCommandLineBuilder.fs b/src/FSharp.Build/FSharpCommandLineBuilder.fs index a708f94fe87..d0b072354ca 100644 --- a/src/FSharp.Build/FSharpCommandLineBuilder.fs +++ b/src/FSharp.Build/FSharpCommandLineBuilder.fs @@ -12,14 +12,6 @@ open Internal.Utilities [] do () -// Shim to match nullness checking library support in preview -[] -module Utils = - - /// 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 - type FSharpCommandLineBuilder() = // In addition to generating a command-line that will be handed to cmd.exe, we also generate @@ -60,7 +52,7 @@ type FSharpCommandLineBuilder() = if s <> String.Empty then args <- s :: args - member _.AppendSwitchIfNotNull(switch: string, value: string MaybeNull, ?metadataNames: string[]) = + member _.AppendSwitchIfNotNull(switch: string, value: string | null, ?metadataNames: string[]) = let metadataNames = defaultArg metadataNames [||] builder.AppendSwitchIfNotNull(switch, value) let tmp = new CommandLineBuilder() @@ -84,7 +76,7 @@ type FSharpCommandLineBuilder() = | Some false -> this.AppendSwitch($"{switch}-") | None -> () - member _.AppendSwitchUnquotedIfNotNull(switch: string, value: string MaybeNull) = + member _.AppendSwitchUnquotedIfNotNull(switch: string, value: string | null) = assert (switch = "") // we only call this method for "OtherFlags" // Unfortunately we still need to mimic what cmd.exe does, but only for "OtherFlags". let ParseCommandLineArgs (commandLine: string) = // returns list in reverse order diff --git a/src/FSharp.Build/FSharpEmbedResourceText.fs b/src/FSharp.Build/FSharpEmbedResourceText.fs index 1c5ffbfb68b..416c09e392e 100644 --- a/src/FSharp.Build/FSharpEmbedResourceText.fs +++ b/src/FSharp.Build/FSharpEmbedResourceText.fs @@ -270,9 +270,6 @@ 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 = diff --git a/src/FSharp.Build/Fsc.fs b/src/FSharp.Build/Fsc.fs index 62934bfe85f..90793f3e430 100644 --- a/src/FSharp.Build/Fsc.fs +++ b/src/FSharp.Build/Fsc.fs @@ -20,56 +20,56 @@ type public Fsc() as this = inherit ToolTask() - let mutable baseAddress: string MaybeNull = null + let mutable baseAddress: string | null = null let mutable capturedArguments: string list = [] // list of individual args, to pass to HostObject Compile() let mutable capturedFilenames: string list = [] // list of individual source filenames, to pass to HostObject Compile() - let mutable checksumAlgorithm: string MaybeNull = null - let mutable codePage: string MaybeNull = null + let mutable checksumAlgorithm: string | null = null + let mutable codePage: string | null = null let mutable commandLineArgs: ITaskItem list = [] let mutable compilerTools: ITaskItem[] = [||] let mutable compressmetadata: bool option = None let mutable debugSymbols = false - let mutable debugType: string MaybeNull = null + let mutable debugType: string | null = null let mutable defineConstants: ITaskItem[] = [||] let mutable delaySign: bool = false let mutable deterministic: bool = false - let mutable disabledWarnings: string MaybeNull = null - let mutable documentationFile: string MaybeNull = null - let mutable dotnetFscCompilerPath: string MaybeNull = null + let mutable disabledWarnings: string | null = null + let mutable documentationFile: string | null = null + let mutable dotnetFscCompilerPath: string | null = null let mutable embedAllSources = false let mutable embeddedFiles: ITaskItem[] = [||] - let mutable generateInterfaceFile: string MaybeNull = null + let mutable generateInterfaceFile: string | null = null let mutable highEntropyVA: bool = false - let mutable keyFile: string MaybeNull = null - let mutable langVersion: string MaybeNull = null + let mutable keyFile: string | null = null + let mutable langVersion: string | null = null let mutable disabledLanguageFeatures: ITaskItem[] = [||] let mutable noFramework = false let mutable noInterfaceData = false let mutable noOptimizationData = false let mutable optimize: bool = true - let mutable otherFlags: string MaybeNull = null - let mutable outputAssembly: string MaybeNull = null - let mutable outputRefAssembly: string MaybeNull = null + let mutable otherFlags: string | null = null + let mutable outputAssembly: string | null = null + let mutable outputRefAssembly: string | null = null let mutable parallelCompilation: bool option = None - let mutable pathMap: string MaybeNull = null - let mutable pdbFile: string MaybeNull = null - let mutable platform: string MaybeNull = null + let mutable pathMap: string | null = null + let mutable pdbFile: string | null = null + let mutable platform: string | null = null let mutable prefer32bit: bool = false - let mutable preferredUILang: string MaybeNull = null + let mutable preferredUILang: string | null = null let mutable publicSign: bool = false let mutable provideCommandLineArgs: bool = false let mutable realsig: bool option = None let mutable references: ITaskItem[] = [||] - let mutable referencePath: string MaybeNull = null + let mutable referencePath: string | null = null let mutable refOnly: bool = false let mutable resources: ITaskItem[] = [||] let mutable skipCompilerExecution: bool = false let mutable sources: ITaskItem[] = [||] - let mutable sourceLink: string MaybeNull = null - let mutable subsystemVersion: string MaybeNull = null + let mutable sourceLink: string | null = null + let mutable subsystemVersion: string | null = null let mutable tailcalls: bool = true - let mutable targetProfile: string MaybeNull = null - let mutable targetType: string MaybeNull = null + let mutable targetProfile: string | null = null + let mutable targetType: string | null = null let defaultToolPath = let locationOfThisDll = @@ -84,16 +84,16 @@ type public Fsc() as this = let mutable treatWarningsAsErrors: bool = false let mutable useStandardResourceNames: bool = false - let mutable warningsAsErrors: string MaybeNull = null - let mutable warningsNotAsErrors: string MaybeNull = null - let mutable versionFile: string MaybeNull = null - let mutable warningLevel: string MaybeNull = null - let mutable warnOn: string MaybeNull = null - let mutable win32icon: string MaybeNull = null - let mutable win32res: string MaybeNull = null - let mutable win32manifest: string MaybeNull = null + let mutable warningsAsErrors: string | null = null + let mutable warningsNotAsErrors: string | null = null + let mutable versionFile: string | null = null + let mutable warningLevel: string | null = null + let mutable warnOn: string | null = null + let mutable win32icon: string | null = null + let mutable win32res: string | null = null + let mutable win32manifest: string | null = null let mutable vserrors: bool = false - let mutable vslcid: string MaybeNull = null + let mutable vslcid: string | null = null let mutable utf8output: bool = false let mutable useReflectionFreeCodeGen: bool = false let mutable nullable: bool option = None @@ -101,7 +101,7 @@ type public Fsc() as this = /// Trim whitespace ... spaces, tabs, newlines,returns, Double quotes and single quotes let wsCharsToTrim = [| ' '; '\t'; '\"'; '\'' |] - let splitAndWsTrim (s: string MaybeNull) = + let splitAndWsTrim (s: string | null) = match s with | Null -> [||] | NonNull s -> @@ -131,16 +131,17 @@ type public Fsc() as this = // DebugType builder.AppendSwitchIfNotNull( "--debug:", - match debugType with - | Null -> null - | NonNull debugType -> - match debugType.ToUpperInvariant() with - | "NONE" -> null - | "PORTABLE" -> "portable" - | "PDBONLY" -> "pdbonly" - | "EMBEDDED" -> "embedded" - | "FULL" -> "full" - | _ -> null + (match debugType with + | Null -> null + | NonNull debugType -> + match debugType.ToUpperInvariant() with + | "NONE" -> null + | "PORTABLE" -> "portable" + | "PDBONLY" -> "pdbonly" + | "EMBEDDED" -> "embedded" + | "FULL" -> "full" + | _ -> null + : string | null) ) if embedAllSources then @@ -220,32 +221,34 @@ type public Fsc() as this = builder.AppendSwitchIfNotNull( "--platform:", - let ToUpperInvariant (s: string MaybeNull) = + let ToUpperInvariant (s: string | null) = match s with | Null -> null | NonNull s -> s.ToUpperInvariant() - match ToUpperInvariant(platform), prefer32bit, ToUpperInvariant(targetType) with - | "ANYCPU", true, "EXE" - | "ANYCPU", true, "WINEXE" -> "anycpu32bitpreferred" - | "ANYCPU", _, _ -> "anycpu" - | "X86", _, _ -> "x86" - | "X64", _, _ -> "x64" - | "ARM", _, _ -> "arm" - | "ARM64", _, _ -> "arm64" - | _ -> null + (match ToUpperInvariant(platform), prefer32bit, ToUpperInvariant(targetType) with + | "ANYCPU", true, "EXE" + | "ANYCPU", true, "WINEXE" -> "anycpu32bitpreferred" + | "ANYCPU", _, _ -> "anycpu" + | "X86", _, _ -> "x86" + | "X64", _, _ -> "x64" + | "ARM", _, _ -> "arm" + | "ARM64", _, _ -> "arm64" + | _ -> null + : string | null) ) // checksumAlgorithm builder.AppendSwitchIfNotNull( "--checksumalgorithm:", - match checksumAlgorithm with - | Null -> null - | NonNull checksumAlgorithm -> - match checksumAlgorithm.ToUpperInvariant() with - | "SHA1" -> "Sha1" - | "SHA256" -> "Sha256" - | _ -> null + (match checksumAlgorithm with + | Null -> null + | NonNull checksumAlgorithm -> + match checksumAlgorithm.ToUpperInvariant() with + | "SHA1" -> "Sha1" + | "SHA256" -> "Sha256" + | _ -> null + : string | null) ) // Resources @@ -275,15 +278,16 @@ type public Fsc() as this = // TargetType builder.AppendSwitchIfNotNull( "--target:", - match targetType with - | Null -> null - | NonNull targetType -> - match targetType.ToUpperInvariant() with - | "LIBRARY" -> "library" - | "EXE" -> "exe" - | "WINEXE" -> "winexe" - | "MODULE" -> "module" - | _ -> null + (match targetType with + | Null -> null + | NonNull targetType -> + match targetType.ToUpperInvariant() with + | "LIBRARY" -> "library" + | "EXE" -> "exe" + | "WINEXE" -> "winexe" + | "MODULE" -> "module" + | _ -> null + : string | null) ) // NoWarn diff --git a/src/FSharp.Build/Fsi.fs b/src/FSharp.Build/Fsi.fs index 88a6dbf3adb..312c1f31a9f 100644 --- a/src/FSharp.Build/Fsi.fs +++ b/src/FSharp.Build/Fsi.fs @@ -23,26 +23,26 @@ type public Fsi() as this = let mutable capturedArguments: string list = [] // list of individual args, to pass to HostObject Compile() let mutable capturedFilenames: string list = [] // list of individual source filenames, to pass to HostObject Compile() - let mutable codePage: string MaybeNull = null + let mutable codePage: string | null = null let mutable commandLineArgs: ITaskItem list = [] let mutable defineConstants: ITaskItem[] = [||] - let mutable disabledWarnings: string MaybeNull = null - let mutable dotnetFsiCompilerPath: string MaybeNull = null + let mutable disabledWarnings: string | null = null + let mutable dotnetFsiCompilerPath: string | null = null let mutable fsiExec = false - let mutable langVersion: string MaybeNull = null + let mutable langVersion: string | null = null let mutable noFramework = false let mutable optimize = true - let mutable otherFlags: string MaybeNull = null + let mutable otherFlags: string | null = null let mutable preferredUILang = null let mutable provideCommandLineArgs = false let mutable references: ITaskItem[] = [||] - let mutable referencePath: string MaybeNull = null + let mutable referencePath: string | null = null 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 targetProfile: string | null = null let mutable toolPath: string = let locationOfThisDll = @@ -56,10 +56,10 @@ type public Fsi() as this = | None -> "" let mutable treatWarningsAsErrors: bool = false - let mutable warningsAsErrors: string MaybeNull = null - let mutable warningsNotAsErrors: string MaybeNull = null - let mutable warningLevel: string MaybeNull = null - let mutable vslcid: string MaybeNull = null + let mutable warningsAsErrors: string | null = null + let mutable warningsNotAsErrors: string | null = null + let mutable warningLevel: string | null = null + let mutable vslcid: string | null = null let mutable utf8output: bool = false let mutable useReflectionFreeCodeGen: bool = false diff --git a/src/FSharp.Build/WriteCodeFragment.fs b/src/FSharp.Build/WriteCodeFragment.fs index 0e5b0457649..2e0d96b7f3e 100644 --- a/src/FSharp.Build/WriteCodeFragment.fs +++ b/src/FSharp.Build/WriteCodeFragment.fs @@ -14,8 +14,8 @@ type EscapedValue = { Escaped: string; Raw: string } type WriteCodeFragment() as this = inherit Task() - let mutable _outputDirectory: ITaskItem MaybeNull = null - let mutable _outputFile: ITaskItem MaybeNull = null + let mutable _outputDirectory: ITaskItem | null = null + let mutable _outputFile: ITaskItem | null = null let mutable _language: string = "" let mutable _assemblyAttributes: ITaskItem[] = [||] diff --git a/src/FSharp.Core/event.fs b/src/FSharp.Core/event.fs index d815918aa08..155918143fe 100644 --- a/src/FSharp.Core/event.fs +++ b/src/FSharp.Core/event.fs @@ -25,11 +25,7 @@ module private Atomic = exchanged <- true [] -#if BUILDING_WITH_LKG || BUILD_FROM_SOURCE -type DelegateEvent<'Delegate when 'Delegate :> Delegate>() = -#else type DelegateEvent<'Delegate when 'Delegate :> Delegate and 'Delegate: not null>() = -#endif let mutable multicast: Delegate = null member x.Trigger(args: objnull array) = @@ -81,12 +77,8 @@ type EventDelegee<'Args>(observer: IObserver<'Args>) = type EventWrapper<'Delegate, 'Args> = delegate of 'Delegate * objnull * 'Args -> unit [] -#if BUILDING_WITH_LKG || BUILD_FROM_SOURCE -type Event<'Delegate, 'Args when 'Delegate: delegate<'Args, unit> and 'Delegate :> Delegate and 'Delegate: not struct>() -#else type Event<'Delegate, 'Args when 'Delegate: delegate<'Args, unit> and 'Delegate :> Delegate and 'Delegate: not struct and 'Delegate: not null>() -#endif = let mutable multicast: 'Delegate = Unchecked.defaultof<_> diff --git a/src/FSharp.Core/event.fsi b/src/FSharp.Core/event.fsi index 826420c2b5f..ec52057f174 100644 --- a/src/FSharp.Core/event.fsi +++ b/src/FSharp.Core/event.fsi @@ -10,11 +10,7 @@ open Microsoft.FSharp.Control /// /// Events and Observables [] -#if BUILDING_WITH_LKG || BUILD_FROM_SOURCE -type DelegateEvent<'Delegate when 'Delegate :> Delegate> = -#else type DelegateEvent<'Delegate when 'Delegate :> Delegate and 'Delegate: not null> = -#endif /// Creates an event object suitable for implementing an arbitrary type of delegate. /// The event object. /// @@ -36,12 +32,8 @@ type DelegateEvent<'Delegate when 'Delegate :> Delegate and 'Delegate: not null> /// /// Events and Observables [] -#if BUILDING_WITH_LKG || BUILD_FROM_SOURCE -type Event<'Delegate, 'Args when 'Delegate: delegate<'Args, unit> and 'Delegate :> Delegate and 'Delegate: not struct> = -#else type Event<'Delegate, 'Args when 'Delegate: delegate<'Args, unit> and 'Delegate :> Delegate and 'Delegate: not struct and 'Delegate: not null> = -#endif /// Creates an event object suitable for delegate types following the standard .NET Framework convention of a first 'sender' argument. /// The created event. diff --git a/src/FSharp.Core/prim-types.fs b/src/FSharp.Core/prim-types.fs index 253f2dfa655..7b954ab8674 100644 --- a/src/FSharp.Core/prim-types.fs +++ b/src/FSharp.Core/prim-types.fs @@ -7339,19 +7339,11 @@ namespace Microsoft.FSharp.Control open System open Microsoft.FSharp.Core -#if BUILDING_WITH_LKG || BUILD_FROM_SOURCE - type IDelegateEvent<'Delegate when 'Delegate :> Delegate > = -#else type IDelegateEvent<'Delegate when 'Delegate :> Delegate and 'Delegate : not null > = -#endif abstract AddHandler: handler:'Delegate -> unit abstract RemoveHandler: handler:'Delegate -> unit -#if BUILDING_WITH_LKG || BUILD_FROM_SOURCE - type IEvent<'Delegate,'Args when 'Delegate : delegate<'Args,unit> and 'Delegate :> Delegate > = -#else type IEvent<'Delegate,'Args when 'Delegate : delegate<'Args,unit> and 'Delegate :> Delegate and 'Delegate : not null > = -#endif inherit IDelegateEvent<'Delegate> inherit IObservable<'Args> diff --git a/src/FSharp.Core/prim-types.fsi b/src/FSharp.Core/prim-types.fsi index cbbee78773a..6794788be59 100644 --- a/src/FSharp.Core/prim-types.fsi +++ b/src/FSharp.Core/prim-types.fsi @@ -1219,11 +1219,7 @@ namespace Microsoft.FSharp.Core /// Represents a managed pointer in F# code. /// ByRef and Pointer Types -#if BUILDING_WITH_LKG || BUILD_FROM_SOURCE - [] -#else [] -#endif type byref<'T, 'Kind> = (# "!0&" #) /// Represents a managed pointer in F# code. For F# 4.5+ this is considered equivalent to byref<'T, ByRefKinds.InOut> @@ -1232,35 +1228,19 @@ namespace Microsoft.FSharp.Core /// Represents the types of byrefs in F# 4.5+ /// ByRef and Pointer Types -#if BUILDING_WITH_LKG || BUILD_FROM_SOURCE - [] -#else [] -#endif module ByRefKinds = /// Represents a byref that can be written -#if BUILDING_WITH_LKG || BUILD_FROM_SOURCE - [] -#else [] -#endif type Out /// Represents a byref that can be read -#if BUILDING_WITH_LKG || BUILD_FROM_SOURCE - [] -#else [] -#endif type In /// Represents a byref that can be both read and written -#if BUILDING_WITH_LKG || BUILD_FROM_SOURCE - [] -#else [] -#endif type InOut /// Represents a in-argument or readonly managed pointer in F# code. This type should only be used with F# 4.5+. @@ -6205,11 +6185,7 @@ namespace Microsoft.FSharp.Control /// CLI metadata to make the member appear to other CLI languages as a CLI event. /// /// Events and Observables -#if BUILDING_WITH_LKG || BUILD_FROM_SOURCE - type IDelegateEvent<'Delegate when 'Delegate :> Delegate > = -#else type IDelegateEvent<'Delegate when 'Delegate :> Delegate and 'Delegate : not null > = -#endif /// Connect a handler delegate object to the event. A handler can /// be later removed using RemoveHandler. The listener will @@ -6231,11 +6207,7 @@ namespace Microsoft.FSharp.Control /// /// Events and Observables [] -#if BUILDING_WITH_LKG || BUILD_FROM_SOURCE - type IEvent<'Delegate,'Args when 'Delegate: delegate<'Args,unit> and 'Delegate :> Delegate > = -#else type IEvent<'Delegate,'Args when 'Delegate: delegate<'Args,unit> and 'Delegate :> Delegate and 'Delegate : not null > = -#endif inherit IDelegateEvent<'Delegate> inherit IObservable<'Args> diff --git a/src/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.Nuget.fsproj b/src/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.Nuget.fsproj index 96e318d282c..500f3b32208 100644 --- a/src/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.Nuget.fsproj +++ b/src/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.Nuget.fsproj @@ -31,7 +31,7 @@ - + diff --git a/vsintegration/src/FSharp.VS.FSI/FSharp.VS.FSI.fsproj b/vsintegration/src/FSharp.VS.FSI/FSharp.VS.FSI.fsproj index 2478700de2d..62a4e7377c2 100644 --- a/vsintegration/src/FSharp.VS.FSI/FSharp.VS.FSI.fsproj +++ b/vsintegration/src/FSharp.VS.FSI/FSharp.VS.FSI.fsproj @@ -19,7 +19,7 @@ - + diff --git a/vsintegration/tests/Salsa/VisualFSharp.Salsa.fsproj b/vsintegration/tests/Salsa/VisualFSharp.Salsa.fsproj index d41b116c21e..1738441bc4b 100644 --- a/vsintegration/tests/Salsa/VisualFSharp.Salsa.fsproj +++ b/vsintegration/tests/Salsa/VisualFSharp.Salsa.fsproj @@ -16,7 +16,7 @@ - + CompilerLocation.fs diff --git a/vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj b/vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj index d5167d28820..1ce8c8f2d9a 100644 --- a/vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj +++ b/vsintegration/tests/UnitTests/VisualFSharp.UnitTests.fsproj @@ -20,7 +20,7 @@ XunitSetup.fs - + Internal.Utilities.Collections.fsi