Why is generic type argument non-nullable (causing warning) when null is passed to params T[]? #5269
-
This is counterintuitive behavior which makes it necessary to explicitly specify the type argument with #nullable enable
// ⚠ CS8625 Cannot convert null literal to non-nullable reference type.
M(null, "test");
void M<T>(params T[] values) { } |
Beta Was this translation helpful? Give feedback.
Answered by
RikkiGibson
Oct 11, 2021
Replies: 1 comment
-
This looks like a scenario that was fixed by dotnet/roslyn#56022. No warning is given when using the "main" branch in SharpLab. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
RikkiGibson
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This looks like a scenario that was fixed by dotnet/roslyn#56022. No warning is given when using the "main" branch in SharpLab.