-
Notifications
You must be signed in to change notification settings - Fork 4k
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 SpecialType
entry for ReadOnlySpan
#72102
Comments
I'm happy to bring this to next API review. But i'm curious prior to that if there's a core design reason at the compiler level to not do this. I'm not an expert here, but i thought there were some aspects/rules around when SpecialType was appropriate or not, and i'm curious if that was already considered here. @AlekseyTs @333fred for thoughts. Or, we can just discuss at the API meeting. Note: if this was offered, IDE would use it immediately :) |
This is incorrect and this is not a motivation for the compiler to add the API for At the moment compiler doesn't need to have the same support for
This is likely undesirable. Compiler supports special handling of span types that are not declared in the core library. So, it will be appropriate to use the new |
SGTM. If the current setup properly encapsulates required semantics, that's good to know. |
Removing from api-review based on Aleksey's explanation for why this is working as intended. |
I tried to write motivation both for compiler and IDE use. This quote is about how I would use it in IDE/generators scenarios. This doesn't repeal the fact, that compiler needs it for different purposes with different reasoning. I just want to show both sides of the question. After all, if this type was only for compiler use it wouldn't be public, right? |
IDE usage is also why I included regular |
This doesn't feel like the right way to approach the problem. Certainly any consumer is free to use a public API and benefit from it. However, usage of any API is appropriate only under specific conditions. The usage that was "advertised" as appropriate for IDE features is actually inappropriate. That doesn't mean IDE cannot use the API, it can, but only when it would be in line with the goal. The "advertised" usage is not in line with IDE goals. |
|
SpecialType
entry for Span
and ReadOnlySpan
SpecialType
entry for ReadOnlySpan
@AlekseyTs Updated issue based on your feedback. |
Looks ready for review. |
API Review
Conclusion: Needs work. Let's investigate a SpecialTypeInternal API instead of adding to SpecialType |
…ed in special types to the SpecialMember set. Closes dotnet#72102. Closes dotnet#72280.
Background and Motivation
In order to implement this codegen optimization compiler needs to have
ReadOnlySpan
as a special type in order to be able to recognize other members of special types, in this case, span-basedConcat
members ofstring
type. For more info see last paragraph of #71793 (comment).The new special type can then be used to recognize other special members for compiler optimizations.
Proposed API
Usage Examples
See #71793
Alternative Designs
None
Risks
SpecialType
is only gonna be set for types from the corlib, meaning, that in this particular case checking forSpecialType.System_ReadOnlySpan_T
is not an easy check for a canonical definition ofReadOnlySpan
, since the type can come from other places, e.g.System.Memory
NuGet package. We will document it as such in code, but this doesn't mean that there won't be any misuses of this new APIThe text was updated successfully, but these errors were encountered: