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

Ignore user-defined Span conversions #74002

Merged

Conversation

jjonescz
Copy link
Member

  • Ignores span UDCs
  • Adds new "explicit span conversion"
  • Fixes nullability analysis of span conversions

Test plan: #73445
Corresponding speclet update: dotnet/csharplang#8167

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Jun 14, 2024
@jjonescz jjonescz force-pushed the FirstClassSpan-05-IgnoreUdc branch 2 times, most recently from 7b3888d to c9d1a8c Compare June 17, 2024 08:36
@jjonescz jjonescz force-pushed the FirstClassSpan-05-IgnoreUdc branch from c9d1a8c to 0a3b139 Compare June 17, 2024 09:27
@jjonescz jjonescz marked this pull request as ready for review June 17, 2024 10:53
@jjonescz jjonescz requested review from a team as code owners June 17, 2024 10:53
@jjonescz jjonescz requested review from 333fred and cston June 17, 2024 11:01
@jjonescz
Copy link
Member Author

@cston @333fred for reviews, thanks

@jjonescz
Copy link
Member Author

@cston @333fred for reviews, thanks. Switching the conversions to be "from type" can be done in a follow up PR, I believe.

@jjonescz jjonescz requested a review from 333fred June 26, 2024 11:31
@jjonescz
Copy link
Member Author

@cston for the second review, thanks

@@ -70,5 +70,6 @@ internal enum ConversionKind : byte
InlineArray, // A conversion from an inline array to Span/ReadOnlySpan

ImplicitSpan, // A conversion between array, (ReadOnly)Span, string - part of the "first-class Span types" feature
Copy link
Member

@cston cston Jun 28, 2024

Choose a reason for hiding this comment

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

// A conversion between array, (ReadOnly)Span, string

Consider making the comment for ImplicitSpan more specific, to match the comment for ExplicitSpan. And I think the reference to the feature can be dropped. Perhaps:

// A conversion from array to (ReadOnly)Span, or from string or (ReadOnly)Span to ReadOnlySpan

@@ -497,7 +509,7 @@ class C<T, U>

var op = (IConversionOperation)model.GetOperation(cast)!;
var conv = op.GetConversion();
Assert.Equal(ConversionKind.ImplicitSpan, conv.Kind);
Assert.Equal(ConversionKind.ExplicitSpan, conv.Kind);
Copy link
Member

Choose a reason for hiding this comment

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

ExplicitSpan

Should the test be renamed ..._Explicit_...?

}

[Fact]
public void Conversion_Array_ReadOnlySpan_Interface_Cast()
Copy link
Member

Choose a reason for hiding this comment

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

ReadOnlySpan

Consider adding a corresponding pair of tests (corresponding to this test and the one above) for Span<T>.

@@ -2426,6 +2577,19 @@ .maxstack 1
IL_000b: ret
}
""");

// Note: although a breaking change, the previous would fail with a runtime exception
// (Span's constructor checks that the element types are identical).
Copy link
Member

Choose a reason for hiding this comment

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

This definition of Span<T> does not contain a constructor.

@jjonescz jjonescz merged commit ab1b532 into dotnet:features/FirstClassSpan Jul 2, 2024
25 of 28 checks passed
@jjonescz jjonescz deleted the FirstClassSpan-05-IgnoreUdc branch July 2, 2024 07:22
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.

3 participants