Skip to content

Runtime-async: invalid program when awaiting generic Task upcasted to Task. #135215

Closed

Description

@majocha

Description

Awaiting generic Task upcasted to Task fails at runtime with runtime-async on.

Related: dotnet/fsharp#20686

Reproduction Steps

Execute with runtime-async=on

async Task Invoke()
{
    await (Task) Task.FromResult(1);
}

await Invoke();

Expected behavior

Works.

Actual behavior

Fails at runtime with System.InvalidProgramException: Common Language Runtime detected an invalid program.

Regression?

No response

Known Workarounds

Force the generic overload of AsyncHelpers.Await.

Configuration

dotnet version 11.0.100-rc.1.26425.128

Other information

No response

Activity

  1. added
    untriaged
    on Oct 5, 2026
  2. dotnet-policy-service commented on Oct 5, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/area-system-threading-tasks
    See info in area-owners.md if you want to be subscribed.

  3. added
    area-CodeGen-coreclr
    and removed
    untriaged
    on Oct 5, 2026
  4. added this to the 12.0.0 milestone on Oct 5, 2026
  5. dotnet-policy-service commented on Oct 5, 2026

    @dotnet-policy-service
    Contributor

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

  6. AndyAyersMS commented on Nov 5, 2026

    @AndyAyersMS
    Member
  7. self-assigned this
    on Nov 6, 2026
  8. added 2 commits that reference this issue on Nov 10, 2026
    329b994
    238e191
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclr

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions