Skip to content

Regression from first-class spans with overload picking #76443

Open
@colejohnson66

Description

Version Used: 9.0.200.preview

Steps to Reproduce:

  1. Use MemoryMarshal.Cast with an array
  2. Expect Span<T> overload, but get ReadOnlySpan<T> overload

https://sharplab.io/#v2:EYLgtghglgdgNAExAagD4AEBMBGAsAKHQAYACdbAOgCUBXGAFyjAFMKBJB5gJwHsAHAMrcAblADGzAM4BuAgXQBmMphIBhADYRJkggG8CJQ2SXoALCQCyzegAseCABQBKA0f34jnkgh41g65gBtAF0Segh/ZhIAXhIYGnV1AEJZDy9DAT4IGAAeBJ4YAHMAPm8pehjLZjAeLgBPCwguSRsIdQpVLXocnz8AuBJ8ouKHcMinVM8AXwIpoA===

using System;
using System.Runtime.InteropServices;

public class Class
{
    public void Method()
    {
        double[] table = null!;
        Span<ulong> dest = MemoryMarshal.Cast<double, ulong>(table);
    }
}

Diagnostic Id:

error CS0029: Cannot implicitly convert type 'System.ReadOnlySpan' to 'System.Span'

Expected Behavior:

The Span<T> overload is used, as it was on .NET 8 and .NET 9 RC2.

Actual Behavior:

The ReadOnlySpan<T> overload is used instead.

Activity

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions