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
In Binder.CreateConversion, the bound method group node gets fixed to have a type (with oblivious annotations). During nullable analysis, we need to undo and re-do that with proper nullable annotation.
Note there is a parallel with lambda conversions. In NullableWalker.GetUnboundLambda() and NullableWalker.ApplyConversion we do this process for lambdas. I suspect we need something similar for method groups.
We should test all scenarios involving NullableWalker.RemoveConversion(). I suspect this logic of undoing effects of Binder.CreateConversion should be factored there. For example, new[] { new Func<string?>(...), () => "" };.
[Fact]publicvoidSuppressNullableWarning_LambdaInOverloadResolution(){varsource=@"class C{ static void Main(string? x) { var s = M(() => { return x; }); s /*T:string?*/ .ToString(); // 1 var s2 = M(() => { return x; }!); // suppressed s2 /*T:string?*/ .ToString(); // 2 var s3 = M(M2); s3 /*T:string*/ .ToString(); // 3 var s4 = M(M2!); // suppressed s4 /*T:string*/ .ToString(); // 4 } static T M<T>(System.Func<T> x) => throw null; static string? M2() => throw null;}";varcomp= CreateCompilation(source, options: WithNonNullTypesTrue());
comp.VerifyTypes();// TODO2// Missing warnings on s3 and s4
comp.VerifyDiagnostics(// (6,9): warning CS8602: Possible dereference of a null reference.// s /*T:string?*/ .ToString(); // 1
Diagnostic(ErrorCode.WRN_NullReferenceReceiver,"s").WithLocation(6,9),// (9,9): warning CS8602: Possible dereference of a null reference.// s2 /*T:string?*/ .ToString(); // 2
Diagnostic(ErrorCode.WRN_NullReferenceReceiver,"s2").WithLocation(9,9));
CompileAndVerify(comp);}
The text was updated successfully, but these errors were encountered:
In
Binder.CreateConversion
, the bound method group node gets fixed to have a type (with oblivious annotations). During nullable analysis, we need to undo and re-do that with proper nullable annotation.Note there is a parallel with lambda conversions. In
NullableWalker.GetUnboundLambda()
andNullableWalker.ApplyConversion
we do this process for lambdas. I suspect we need something similar for method groups.We should test all scenarios involving
NullableWalker.RemoveConversion()
. I suspect this logic of undoing effects ofBinder.CreateConversion
should be factored there. For example,new[] { new Func<string?>(...), () => "" };
.The text was updated successfully, but these errors were encountered: