I wrote this code:
var (left, right) = A.FooWith(B);
where left, right, A and B are all Ts:
public class T {
// ...
public (T left, T right) FooWith(T other)
{
T left = new (GetInfoFrom(this, other));
T right = new (GetMoreInfoFrom(this, other));
return (left, right);
}
}
I know for sure that FooWith has to return a non null tuple with non null fields. But the compiler does not seem to see this, and it tells me that left is of type T?, and triggers warning down the code.
Is there a way to pass this information and prevent these warnings?
You need to specify type explicitly:
From the docs:
Note that as stated null state analysis can determine that variable is not actually null (at least in "simple" cases):