// Some dependency
interface IOther {
K? Get<K>();
}
// The derived class which I want to annotate correctly
public class MyDictionary<T,K> : Dictionary<T, K> where T: notnull {
public void Foo(T key) {
IOther x = null!;
Add(key, x.Get<K>()); // This triggers a CS8604
}
}
// Usage of the class
var tmp = new MyDictionary<Guid, string>();
tmp.Add(Guid.NewGuid(), null);
tmp.Add(Guid.NewGuid(), "null");
// Some dependency
interface IOther {
K? Get<K>();
}
// The derived class which I want to annotate correctly
public class MyDictionary<T,K> : Dictionary<T, K> where T: notnull {
public void Foo(T key) {
IOther x = null!;
Add(key, x.Get<K>()); // This triggers a CS8604
}
}
// Usage of the class
var tmp = new MyDictionary<Guid, string>();
tmp.Add(Guid.NewGuid(), null);
tmp.Add(Guid.NewGuid(), "null");