dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.82k stars 773 forks source link

Feature nullness :: apply nullness annotations to usages of 'obj' in Fsharp.Core #17284

Closed T-Gro closed 2 weeks ago

T-Gro commented 3 weeks ago

Apply nullness annotations to FSharp.Core everywhere where it deals with obj. This is by far the biggest user of potential nulls (reflection, queries, quotations, printing,..).

A separate follow up will be other types, apart from obj usages of arrays are the next bigger candidate.

The chosen approach is to use a conditional type alias objnull, which becomes part of the F#-visible API surface. It gets erased from IL code, but is kept in signature data and therefore users of FSharp.Core will see it. The reason is to keep the codebase sane and only have one conditional around obj | null and not to have it around every single usage.

T-Gro commented 3 weeks ago

(this builds upon the commits from https://github.com/dotnet/fsharp/pull/17269 )