-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Milestone
Description
Version Used:
VisualStudio.16.Release/16.4.2+29613.14
C# Tools 3.4.1-beta4-19610-02+c4e5d138903b899477649a17f197abd2bcb22f9e
Steps to Reproduce:
In the following program, s in never reassigned later in M2 so the compiler should know that it's never null when M1 is called, even though it's captured. Writing the equivalent code using if/else doesn't produce a warning.
#nullable enable
using System;
class C {
void M1(string s) { }
Action? M2(string? s) => s != null ? () => M1(s) : (Action?) null;
}Expected Behavior:
No warning.
Actual Behavior:
Warning CS8604: Possible null reference argument for parameter 's' in 'void C.M1(string s)'.
Reactions are currently unavailable