When programming today the following situation arose. A generic method accepts a non-nullable generic parameter. The method basically just inserts the generic value into a collection. However, this gives rise to a compiler warning indicating that the generic parameter might be null. At the face of it, it seems to be a bug in the compiler and contradict the design of nullable values. However, I am sure that there is some good explanation that I am not seeing.
Consider the following simplified example of the situation:
public void M1<T>(T t, List<object> l) => l.Add(t);
The compiler warns that t might be null in l.Add(t).
Also just for completness the following method gives the same error (as expected):
public void M1<T>(T? t, List<object> l) => l.Add(t);
Anyone has some good insights into this?