Skip to content
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

Add standard implicit array-to-Span conversions #73538

Conversation

jjonescz
Copy link
Member

Test plan: #73445

This adds only the first two conversions:

  • From any single-dimensional array_type with element type Ei to System.Span<Ei>
  • From any single-dimensional array_type with element type Ei to System.ReadOnlySpan<Ui>, provided that Ei is covariance-convertible to Ui

The others will be similar, so it will be easier to add them once these are fleshed out. Plus some of the other conversions will need new well-known members and I didn't want to blow up this PR unnecessarily with that.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels May 17, 2024
@@ -1241,7 +1241,7 @@ private void CheckRestrictedTypeReceiver(BoundExpression expression, CSharpCompi
ParameterSymbol receiverParameter = method.Parameters.First();

// we will have a different receiver if ReplaceTypeOrValueReceiver has unwrapped TypeOrValue
if ((object)receiver != receiverArgument)
if ((object)receiver != methodGroup.Receiver)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to avoid creating the conversion for the extension method receiver twice, avoiding duplicate "missing compiler-required member" diagnostics.

@jjonescz jjonescz force-pushed the FirstClassSpan-02-Conversion branch from e2ab501 to 3fb40ab Compare May 17, 2024 13:07
@jjonescz jjonescz deleted the branch dotnet:features/FirstClassSpan May 20, 2024 10:27
@jjonescz jjonescz closed this May 20, 2024
@jjonescz jjonescz deleted the FirstClassSpan-02-Conversion branch May 20, 2024 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Feature - First-class Span Types untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant