-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New nullable warnings when building runtime #46577
Comments
The new warnings are for cases such as the following. The warning looks correct, although it was not reported with earlier builds. #nullable enable
interface I { }
class Program
{
static void F0<T>(ref T x, ref T y)
{
}
static void F<T>(ref T x, ref T y) where T : I
{
if (x == null) { }
F0(ref x, ref y); // warning: x may be null
}
} |
Oh, interesting, so is it because one of the Ts is constrained to non-nullable interface? Would it make sense to send a patch to the runtime with a suggested fix, or just find a code owner and give a heads up? |
It looks like the new warnings are reported from #46405. |
Resolved in dotnet/runtime#41046. |
@cston it seems that |
Thanks @charsleysa. It looks like the issue has been fixed in the release/5.0-rc2 branch in dotnet/runtime@4690f4e |
Version Used: 81c5d71
Steps to Reproduce:
Build the Roslyn packages and set up your dotnet/runtime enlistment similar to #46575. Then run
.\Build.cmd
in your dotnet/runtime enlistment. You might also be able to use a method like https://github.com/dotnet/runtime/pull/40197/files#diff-8b8f08ffbf7b863fb3700c1718eeb4cbR20 using a recent build like3.8.0-2.20404.11
to simply reference the most recently build release packages.Expected Behavior:
Builds without nullable warnings
Actual Behavior:
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ArraySortHelper.cs(476,57): error CS8601: Possible null reference assignment. [src\coreclr\src\System.Private.CoreLib\System.Private.CoreLib.csproj]
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ArraySortHelper.cs(477,60): error CS8601: Possible null reference assignment. [src\coreclr\src\System.Private.CoreLib\System.Private.CoreLib.csproj]
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ArraySortHelper.cs(555,75): error CS8601: Possible null reference assignment. [src\coreclr\src\System.Private.CoreLib\System.Private.CoreLib.csproj]
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ArraySortHelper.cs(1057,31): error CS8601: Possible null reference assignment. [src\coreclr\src\System.Private.CoreLib\System.Private.CoreLib.csproj]
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventCounter.cs(45,32): error CS8601: Possible null reference assignment. [src\coreclr\src\System.Private.CoreLib\System.Private.CoreLib.csproj]
The warnings seem to involve generic substitution or taking a ref to an unconstrained type parameter. @cston do you have any idea what could be happening here?
The text was updated successfully, but these errors were encountered: