Skip to content

Breaking change in overload resolution around string literals #60612

@tannergooding

Description

@tannergooding

Using Microsoft.Net.Compilers.Toolset v4.3.0-1.22206.2 or later, attempt to compile:

class C
{
    static void M(ReadOnlySpan<char> x, ReadOnlySpan<byte> y) { }

    static void M(ReadOnlySpan<char> x, ReadOnlySpan<char> y) { }

    static void T() => M("test", "string");
}

Expected behavior:

Everything succeeds and the M(ROSpan<char>, ROSpan<char>) overload is called

Actual behavior:

CS0121: The call is ambiguous between the following methods or properties: 'C.M(ReadOnlySpan<char>, ReadOnlySpan<byte>)' and 'C.M(ReadOnlySpan<char>, ReadOnlySpan<char>)'

This is a breaking change and impacts System.Security.Cryptography.RSAWrapper.ImportFromEncryptedPem: dotnet/runtime#67440 (comment)

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions