-
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
Collection expression arguments: initial binding and lowering #76903
Merged
cston
merged 32 commits into
dotnet:features/dictionary-expressions
from
cston:collection-args
Feb 4, 2025
Merged
Changes from 23 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
3402e2b
Collection expression arguments
cston 0e8e4d9
Initial binding and lowering
cston 0ff7500
with()
cston 6346611
Add CollectionExpressionArgumentTests
cston b70034e
Merge remote-tracking branch 'upstream/features/dictionary-expression…
cston 41f8519
Merge remote-tracking branch 'upstream/features/dictionary-expression…
cston 3059939
Update check for List<T> optimization
cston cb99c24
Collection arguments must be first
cston fa26da0
Fix build
cston a79ab2d
Fix tests
cston ac60002
Fix build
cston 26ee8e2
Update error text
cston a9a8efa
Not supported diagnostic; additional tests
cston 094a719
More tests
cston 69ca245
Add support for CollectionBuilder types
cston b41f88f
Remove arg support for CollectionBuilder types
cston f545d69
Remove arg support for dictionary interface types
cston 64782d4
More tests
cston e75432b
Remove arg support for CollectionBuilder types
cston 909bd6d
PROTOTYPE comments
cston e84cfcf
Fix test
cston 19d5fa0
PROTOTYPE comments
cston 16860b2
Params cycles
cston 3546bef
Rename to BoundWithElement
cston 92a09f6
Rename to BoundWithElement
cston 4d2fab1
Test __arglist
cston cbfcf55
Update test
cston c492c1d
Rename
cston ee5a786
Rename to BoundCollectionExpressionWithElement
cston a92872b
Rename local function
cston 2d4294e
Add PROTOTYPE comment
cston 6cf1511
Rename
cston File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It looks like we're converting the arguments in the with-element even when the with-element is not in the right position, or there are multiple. Feels like we should only convert the one that is in the right position, and do some error binding (bind to natural type?) for the error ones (but not updating
collectionCreation
) #ByDesignThere 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.
It seems useful to me to bind
with(...)
as arguments to the best candidate method regardless of whether the arguments are in the first position, since presumably that is the intent.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.
Binding more than one
with
element still makes me uncomfortable. I could be convinced to bind a singlewith
in the wrong position.Two reasons:
with
might show different constructors...with
elements, any diagnostics reported on those in the wrong position are guaranteed to be cascading diagnostics. Do we have a test for that?It may be good to get a second opinion and/or discuss after standup.
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.
Overload resolution for the constructor is independent of the position of the
with()
, so one does not affect the other.Yes,
CollectionExpressionArguments.LanguageVersion_03()
testsList<int> l = [with(x: 1), with(y: 2)];
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.
I agree with Julien. I'm not comfortable binding multiple constructors for collection expressions. I'm fine with out of position
with
elements, but multiple constructors will have potential cascading effects, not just in diagnostics, but also in other IDE features, as well as forcing handling of multiple constructors elsewhere in our code. I think we should just turn secondary withs intoBoundBadExpressions
, bind the expressions for error recovery, and be done with it.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.
Added a PROTOTYPE comment to revisit this later, likely when implementing
IOperation
support.