Skip to content

[RuntimeAsync] Handle covariant returns scenarios in combination with task-returning methods. #124238

Description

@VSadov

Re: #124062 . The PR was a mitigation, but we need actual fixes.

There are two loosely related issues, which may require separate fixes:

  • Task<T> inherits from Task.
    As an example, when a covariant override returns Task<Guid> vs. base method returning Task we may need two async variants for the overriding method - a real one (returns Guid) and a one that matches/overrides the base (calls the real variant, drops the return and returns void).

  • both Task and Task<T> are not sealed, so a covariant override may return something derived that is not a task at all.
    At least in a case where the base was MethodImpl.Async we may need to emit an async variant (thunk) for the overriding method that matches the base, even though the overriding method is not technically task-returning.

Other solutions may exist.

Activity

  1. added this to the 11.0.0 milestone on Feb 10, 2026
  2. dotnet-policy-service commented on Feb 10, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @agocke
    See info in area-owners.md if you want to be subscribed.

  3. self-assigned this
    on Feb 10, 2026
  4. modified the milestones: 11.0.0, 12.0.0 on Aug 17, 2026
  5. agocke commented on Aug 17, 2026

    @agocke
    Member

    @VSadov Is this done? Or are custom tasks inheriting from Task still a problem?

  6. VSadov commented on Aug 17, 2026

    @VSadov
    MemberAuthor

    Looking at custom tasks + covariant overriding + async.
    It is an extreme corner case, likely noone does it, but we need a closure on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

  • Status
    No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions