-
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
Params Collections: Implement "Better function member" section of the proposal #71271
Params Collections: Implement "Better function member" section of the proposal #71271
Conversation
@RikkiGibson, @333fred, @dotnet/roslyn-compiler Please review |
// Ambiguous for inline collection expression, but 'int' is a better conversion target than 'short' in params case (exact target) | ||
[InlineData("System.ReadOnlySpan<T>", "short[]", "System.ReadOnlySpan<System.Int32>")] // cannot convert int to short | ||
// Ambiguous for inline collection expression, but 'int' is a better conversion target than 'long' in params case | ||
[InlineData("System.ReadOnlySpan<long>", "T[]", "System.Int32[]")] // cannot convert long to int |
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 one is particularly surprising. Is part of the open question you have for LDM? #Resolved
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 one is particularly surprising. Is part of the open question you have for LDM?
I do not find this surprising for this scenario at all. The better conversion rule can, of course, have a different effect and that is explicitly called out in the specification. Directly in the relevant section, with examples, rather than as an open question.
@RikkiGibson, @dotnet/roslyn-compiler For the second review |
@@ -2653,6 +2701,14 @@ private bool IsBetterCollectionExpressionConversion(TypeSymbol t1, Conversion co | |||
Conversions.ClassifyImplicitConversionFromType(source, destination, ref useSiteInfo).IsImplicit; | |||
} | |||
|
|||
private bool IsBetterParamsCollectionType(TypeSymbol t1, TypeSymbol t2, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo) | |||
{ | |||
CollectionExpressionTypeKind kind1 = ConversionsBase.GetCollectionExpressionTypeKind(Compilation, t1, out TypeWithAnnotations type1); |
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 naming type1
and type2
something like elementType1
and elementType2
to better distinguish them from t1
and t2
#Resolved
88c8859
into
dotnet:features/ParamsCollections
dotnet/csharplang#7768