-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
Task<T>
nullability covariance
- Proposed
- Prototype: Not Started
- Implementation: Not Started
- Specification: Not Started
Summary
Task<T>
nullability covariance (LDM tentatively approved, needs design proposal for task-like types)
It should be possible to return a Task<string!>
for a Task<string?>
.
using System.Threading.Tasks;
#nullable enable
public class C
{
public Task<(bool Result, string? Extras)> M()
{
return Task.FromResult((true, "")); // currently produces a warning
}
}
Motivation
See some examples of this problem: dotnet/roslyn#40759, dotnet/roslyn#40757
Unresolved questions
- needs design proposal for task-like types
Design meetings
Split issue from #3868
https://github.com/dotnet/csharplang/blob/main/meetings/2022/LDM-2022-09-28.md#nullability-improvements
https://github.com/dotnet/csharplang/blob/main/meetings/2024/LDM-2024-09-06.md#taskt-nullability-covariance
jnm2, Unknown6656, NN---, omariom, lindexi and 47 more