未验证 提交 7dad16ec 编写于 作者: R Rikki Gibson 提交者: GitHub

Add regression test (#47851)

上级 7a36f748
......@@ -113,6 +113,40 @@ public void M<T>(bool condition, T t)
comp.VerifyDiagnostics();
}
[Fact, WorkItem(46461, "https://github.com/dotnet/roslyn/issues/46461")]
public void DefaultLiteralInConditional_02()
{
var comp = CreateNullableCompilation(@"
using System;
public class C
{
public void M()
{
M1(true, b => b ? """" : default);
M1<bool, string?>(true, b => b ? """" : default);
M1<bool, string>(true, b => b ? """" : default); // 1
M1(true, b => b ? """" : null);
M1<bool, string?>(true, b => b ? """" : null);
M1<bool, string>(true, b => b ? """" : null); // 2
}
public void M1<T,U>(T t, Func<T, U> fn)
{
fn(t);
}
}");
comp.VerifyDiagnostics(
// (10,37): warning CS8603: Possible null reference return.
// M1<bool, string>(true, b => b ? "" : default); // 1
Diagnostic(ErrorCode.WRN_NullReferenceReturn, @"b ? """" : default", isSuppressed: false).WithLocation(10, 37),
// (14,37): warning CS8603: Possible null reference return.
// M1<bool, string>(true, b => b ? "" : null); // 2
Diagnostic(ErrorCode.WRN_NullReferenceReturn, @"b ? """" : null", isSuppressed: false).WithLocation(14, 37));
}
[Fact, WorkItem(33982, "https://github.com/dotnet/roslyn/issues/33982")]
public void AssigningNullToRefLocalIsSafetyWarning()
{
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册