The following generic functions using nullable references worked fine until I installed VS community 16.5.0 preview 2.0 (before this I used preview 1.0, I'm using .NET Core 3.0/3.1):
static async Task<C> Test<C>(MyClass a, MyClass b, Func<MyClass, Task<C>> extract) where C : class? =>
await extract(a) ?? (b is {} ? await extract(b) : null);
static T MinOrDefault<T>(this IEnumerable<T> enumerable) =>
enumerable.Any() ? enumerable.Min() : default;
But now both give the error CS8603 Possible null reference return.
Does anyone know if this behavior is intentional? And is there a nice way to fix this?
A similar question was asked here, but it does not really have a satisfying answer; especially since it does not work well with Task
s as mentioned in a comment.