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

Collection literals: update type inference #7284

Merged
merged 9 commits into from
Jun 21, 2023

Conversation

cston
Copy link
Member

@cston cston commented Jun 16, 2023

No description provided.

@cston cston marked this pull request as ready for review June 16, 2023 22:40
@cston cston requested a review from a team as a code owner June 16, 2023 22:40
A *collection element type inference* is made *from* a expression `E` *to* a type `T` as follows:
- If `E` is a collection literal with elements `Eᵢ`, and `T` is a *single-dimensional array type* `Tₑ[]` or `T` is [*collection type*](https://github.com/dotnet/csharpstandard/blob/standard-v6/standard/statements.md#1295-the-foreach-statement) with an [*iteration type*](https://github.com/dotnet/csharpstandard/blob/standard-v6/standard/statements.md#1295-the-foreach-statement) `Tₑ`, then for each `Eᵢ`:
- If `Eᵢ` is a *collection literal*, a *collection element type inference* is made *from* `Eᵢ` *to* `Tₑ`.
- Otherwise, if `Eᵢ` has type `Uᵢ` then a *lower-bound inference* is made *from* `Uᵢ` *to* `Tₑ`.
Copy link
Contributor

Choose a reason for hiding this comment

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

should this say something like "for each Ei.."?

Copy link
Member Author

Choose a reason for hiding this comment

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

"for each Ei" is included two lines above.

Copy link
Contributor

@RikkiGibson RikkiGibson Jun 21, 2023

Choose a reason for hiding this comment

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

Oops, I was thrown off by the mis-formatting from GitHub.

@cston cston merged commit 34ea735 into dotnet:main Jun 21, 2023
@cston cston deleted the collections-inference branch June 21, 2023 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants