Skip to content

Fix overload resolution break #5356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions proposals/utf8-string-literals.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,16 @@ The second example is hard to make work because it requires conversions in both

### Overload resolution breaks

The following API would become ambiguous:
The following API would change meaning if we did not have a suffix:

```c#
M("");
static void M1(char[] charArray) => ...;
static void M1(ReadOnlySpan<char> charSpan) => ...;
static void M1(byte[] charArray) => ...;
```

What should we do to address this?
Today this calls the `ReadOnlySpan` overload, because there is an implicit user-defined conversion from `string`. If we introduced a conversion-from-expression for all string
literals, then overload resolution would instead prefer the `byte[]` overload.

## Examples today
Examples of where runtime has manually encoded the UTF8 bytes today
Expand Down