diff --git a/src/Compiler/AbstractIL/il.fs b/src/Compiler/AbstractIL/il.fs index 82faea51c5..0017bdc651 100644 --- a/src/Compiler/AbstractIL/il.fs +++ b/src/Compiler/AbstractIL/il.fs @@ -481,11 +481,11 @@ type ILAssemblyRef(data) = override x.GetHashCode() = uniqueStamp override x.Equals yobj = - ((yobj :?> ILAssemblyRef).UniqueStamp = uniqueStamp) + ((!!yobj :?> ILAssemblyRef).UniqueStamp = uniqueStamp) interface IComparable with override x.CompareTo yobj = - compare (yobj :?> ILAssemblyRef).UniqueStamp uniqueStamp + compare (!!yobj :?> ILAssemblyRef).UniqueStamp uniqueStamp static member Create(name, hash, publicKey, retargetable, version, locale) = ILAssemblyRef @@ -750,7 +750,7 @@ type ILTypeRef = override x.GetHashCode() = x.hashCode override x.Equals yobj = - let y = (yobj :?> ILTypeRef) + let y = (!!yobj :?> ILTypeRef) (x.ApproxId = y.ApproxId) && (x.Scope = y.Scope) @@ -793,7 +793,7 @@ type ILTypeRef = interface IComparable with override x.CompareTo yobj = - let y = (yobj :?> ILTypeRef) + let y = (!!yobj :?> ILTypeRef) let c = compare x.ApproxId y.ApproxId if c <> 0 then diff --git a/src/Compiler/AbstractIL/ilreflect.fs b/src/Compiler/AbstractIL/ilreflect.fs index 5a52ddc017..c6c5e5ab99 100644 --- a/src/Compiler/AbstractIL/ilreflect.fs +++ b/src/Compiler/AbstractIL/ilreflect.fs @@ -1834,7 +1834,7 @@ let rec buildMethodPass2 cenv tref (typB: TypeBuilder) emEnv (mdef: ILMethodDef) let methB = System.Diagnostics.Debug.Assert(not (isNull definePInvokeMethod), "Runtime does not have DefinePInvokeMethod") // Absolutely can't happen - (!!definePInvokeMethod) + !!(!!definePInvokeMethod) .Invoke( typB, [| diff --git a/src/Compiler/Checking/MethodCalls.fs b/src/Compiler/Checking/MethodCalls.fs index ac4d92141d..3343f7dbac 100644 --- a/src/Compiler/Checking/MethodCalls.fs +++ b/src/Compiler/Checking/MethodCalls.fs @@ -1771,7 +1771,7 @@ module ProvidedMethodCalls = | _ when typeEquiv g normTy g.float32_ty -> Const.Single(v :?> float32) | _ when typeEquiv g normTy g.float_ty -> Const.Double(v :?> float) | _ when typeEquiv g normTy g.char_ty -> Const.Char(v :?> char) - | _ when typeEquiv g normTy g.string_ty -> Const.String(v :?> string) + | _ when typeEquiv g normTy g.string_ty -> Const.String(!!v :?> string) | _ when typeEquiv g normTy g.decimal_ty -> Const.Decimal(v :?> decimal) | _ when typeEquiv g normTy g.unit_ty -> Const.Unit | _ -> fail() diff --git a/src/Compiler/DependencyManager/AssemblyResolveHandler.fs b/src/Compiler/DependencyManager/AssemblyResolveHandler.fs index a511f39bdb..0c87130608 100644 --- a/src/Compiler/DependencyManager/AssemblyResolveHandler.fs +++ b/src/Compiler/DependencyManager/AssemblyResolveHandler.fs @@ -41,7 +41,7 @@ type AssemblyResolveHandlerCoreclr(assemblyProbingPaths: AssemblyResolutionProbe member _.ResolveAssemblyNetStandard (ctxt: 'T) (assemblyName: AssemblyName) : Assembly = let loadAssembly path = - loadFromAssemblyPathMethod.Invoke(ctxt, [| path |]) :?> Assembly + !! loadFromAssemblyPathMethod.Invoke(ctxt, [| path |]) :?> Assembly let assemblyPaths = match assemblyProbingPaths with diff --git a/src/Compiler/DependencyManager/DependencyProvider.fs b/src/Compiler/DependencyManager/DependencyProvider.fs index a241880e62..cc1b47de2e 100644 --- a/src/Compiler/DependencyManager/DependencyProvider.fs +++ b/src/Compiler/DependencyManager/DependencyProvider.fs @@ -168,7 +168,7 @@ type ReflectionDependencyManagerProvider let keyProperty (x: objnull) = x |> keyProperty.GetValue |> string let helpMessagesProperty (x: objnull) = - let toStringArray (o: objnull) = o :?> string[] + let toStringArray (o: objnull) = !!o :?> string[] match helpMessagesProperty with | Some helpMessagesProperty -> x |> helpMessagesProperty.GetValue |> toStringArray @@ -334,31 +334,31 @@ 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 @@ -473,8 +473,8 @@ type ReflectionDependencyManagerProvider match tupleFields |> Array.length with | 3 -> tupleFields[0] :?> bool, - tupleFields[1] :?> string list |> List.toSeq, - tupleFields[2] :?> string list |> List.distinct |> List.toSeq + !!tupleFields[1] :?> string list |> List.toSeq, + !!tupleFields[2] :?> string list |> List.distinct |> List.toSeq | _ -> false, seqEmpty, seqEmpty ReflectionDependencyManagerProvider.MakeResultFromFields(success, [||], [||], Seq.empty, sourceFiles, packageRoots) diff --git a/src/Compiler/Interactive/fsi.fs b/src/Compiler/Interactive/fsi.fs index 02dbb98e2d..f6f3aa627b 100644 --- a/src/Compiler/Interactive/fsi.fs +++ b/src/Compiler/Interactive/fsi.fs @@ -122,7 +122,7 @@ module internal Utilities = } else let specialized = typedefof>.MakeGenericType [| ty |] - Activator.CreateInstance(specialized) :?> IAnyToLayoutCall + !!Activator.CreateInstance(specialized) :?> IAnyToLayoutCall let callStaticMethod (ty: Type) name args = ty.InvokeMember( @@ -4762,7 +4762,7 @@ type FsiEvaluationSession let makeNestedException (userExn: #Exception) = // clone userExn -- make userExn the inner exception, to retain the stacktrace on raise let arguments = [| userExn.Message :> obj; userExn :> obj |] - Activator.CreateInstance(userExn.GetType(), arguments) :?> Exception + !!Activator.CreateInstance(userExn.GetType(), arguments) :?> Exception let commitResult res = match res with diff --git a/src/Compiler/TypedTree/TypeProviders.fs b/src/Compiler/TypedTree/TypeProviders.fs index 5c81312e13..be22209a27 100644 --- a/src/Compiler/TypedTree/TypeProviders.fs +++ b/src/Compiler/TypedTree/TypeProviders.fs @@ -141,10 +141,10 @@ let CreateTypeProvider ( IsHostedExecution= isInteractive, SystemRuntimeAssemblyVersion = systemRuntimeAssemblyVersion) #endif - protect (fun () -> Activator.CreateInstance(typeProviderImplementationType, [| box e|]) :?> ITypeProvider ) + protect (fun () -> !!(Activator.CreateInstance(typeProviderImplementationType, [| box e|])) :?> ITypeProvider ) elif not(isNull(typeProviderImplementationType.GetConstructor [| |])) then - protect (fun () -> Activator.CreateInstance typeProviderImplementationType :?> ITypeProvider ) + protect (fun () -> !!(Activator.CreateInstance typeProviderImplementationType) :?> ITypeProvider ) else // No appropriate constructor found @@ -739,7 +739,7 @@ type ProvidedMethodBase (x: MethodBase, ctxt) = let paramsAsObj = try (!!meth).Invoke(provider, bindingFlags ||| BindingFlags.InvokeMethod, null, [| box x |], null) with err -> raise (StripException (StripException err)) - paramsAsObj :?> ParameterInfo[] + !!paramsAsObj :?> ParameterInfo[] staticParams |> ProvidedParameterInfo.CreateArrayNonNull ctxt diff --git a/src/Compiler/Utilities/TaggedCollections.fs b/src/Compiler/Utilities/TaggedCollections.fs index 4676c2673a..253b38a196 100644 --- a/src/Compiler/Utilities/TaggedCollections.fs +++ b/src/Compiler/Utilities/TaggedCollections.fs @@ -667,8 +667,8 @@ type internal Set<'T, 'ComparerTag> when 'ComparerTag :> IComparer<'T>(comparer: interface System.IComparable with // Cast s2 to the exact same type as s1, see 4884. // It is not OK to cast s2 to seq<'T>, since different compares could permute the elements. - member s1.CompareTo(s2: obj) = - SetTree.compare s1.Comparer s1.Tree (s2 :?> Set<'T, 'ComparerTag>).Tree + member s1.CompareTo(s2: objnull) = + SetTree.compare s1.Comparer s1.Tree (!!s2 :?> Set<'T, 'ComparerTag>).Tree member this.ComputeHashCode() = let combineHash x y = (x <<< 1) + y + 631 @@ -1239,7 +1239,7 @@ type internal Map<'Key, 'T, 'ComparerTag> when 'ComparerTag :> IComparer<'Key>(c | _ -> false interface System.IComparable with - member m1.CompareTo(m2: obj) = + member m1.CompareTo(m2: objnull) = Seq.compareWith (fun (kvp1: KeyValuePair<_, _>) (kvp2: KeyValuePair<_, _>) -> let c = m1.Comparer.Compare(kvp1.Key, kvp2.Key) in @@ -1251,7 +1251,7 @@ type internal Map<'Key, 'T, 'ComparerTag> when 'ComparerTag :> IComparer<'Key>(c // Cast m2 to the exact same type as m1, see 4884. // It is not OK to cast m2 to seq>, since different compares could permute the KVPs. m1 - (m2 :?> Map<'Key, 'T, 'ComparerTag>) + (!!m2 :?> Map<'Key, 'T, 'ComparerTag>) member this.ComputeHashCode() = let combineHash x y = (x <<< 1) + y + 631