Hi I've got the following code:
public Task<object?> Do()
{
object x = new object();
return Task.FromResult(x);
}
This code gives me following warning CS8602 Nullability of reference types in value of type Task doesn't match target type Task<object?>
What's even more interesting is the fact that
public Task<object?> Do()
{
object? x = new object();
return Task.FromResult(x);
}
would yield the same error.
The question is why is code analysis complaining about attempting to pass a Task with a stronger constraint as weaker one - I can't figure a scenario where it could go wrong.