I have this simple code and it generates a warning:
private void MyMethod()
{
IDictionary<string, object> notNullable = new Dictionary<string, object>();
Test(notNullable);
}
private void Test(IDictionary<string, object?> nullable)
{
}
I get this warning when I try to compile (it does work with ! though):
Argument of type 'Dictionary< string, object>' cannot be used for parameter 'nullable' of type 'IDictionary' in '...' due to differences in the nullability of reference types
Now I can see the problem doing it the other way around, but how is it a problem that I send a not nullable to a nullable parameter? Just a limitation of C# compiler, or perhaps a bug?