-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Ignore user-defined Span conversions #74002
Conversation
7b3888d
to
c9d1a8c
Compare
c9d1a8c
to
0a3b139
Compare
src/Compilers/CSharp/Portable/Binder/Semantics/Conversions/ConversionsBase.cs
Show resolved
Hide resolved
@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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
[Fact] | ||
public void Conversion_Array_ReadOnlySpan_Interface_Cast() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -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). |
There was a problem hiding this comment.
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.
ab1b532
into
dotnet:features/FirstClassSpan
Test plan: #73445
Corresponding speclet update: dotnet/csharplang#8167