You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Version Used: 3.8.0-3.20452.3 (.NET SDK 5.0.100-rc.1.20454.5)
Steps to Reproduce:
using System;
using System.Runtime.CompilerServices;
using System.Diagnostics.CodeAnalysis;
class C
{
#nullable enable
static void X<T>([NotNullIfNotNull("value")] ref T location, T value) where T : class?
{ }
private readonly double[] foo;
C()
{
if (Environment.CommandLine.Length > 0) foo = new double[5];
double[] bar = new double[3];
X(ref foo, bar); // gives CS8601, with `ref foo!`, the warning disappears.
}
}
Expected Behavior: No nullable warning
Actual Behavior: Nullable warning
The text was updated successfully, but these errors were encountered:
The proposal under discussion is to have ref foo contribute type double[]? to method type inference (because the value of foo is maybe-null in the invocation) rather than double[] as it does currently.
FYI, I updated the OP example with where T : class?.
Note to self: I'm working on this in branch ref-inference
Fixed in 16.8p4. Note that there was a bit of impact on the runtime repo. It is due to a known issue with inference with null literal (does not properly contribute its nullability) which we're hoping to address in 16.9.
See dotnet/runtime#42174 (comment) for full context.
Version Used: 3.8.0-3.20452.3 (.NET SDK 5.0.100-rc.1.20454.5)
Steps to Reproduce:
Expected Behavior: No nullable warning
Actual Behavior: Nullable warning
The text was updated successfully, but these errors were encountered: