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.
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
Feature/initialize list side branch #6058
base: master
Are you sure you want to change the base?
Feature/initialize list side branch #6058
Changes from 32 commits
e0378c6
0f295da
9c40cba
ee7bdf8
907a50f
56047da
8f89551
7684104
4035b7f
acc3830
6c013a3
e4dbe41
87523c8
799bc43
b3405b5
73e7950
4a91a67
6146fea
bce3bf8
c0bc16e
950b071
593270a
46351bd
fdb52c8
989b104
cffa13c
4ee436e
c8f667f
65a6474
2f41cd4
99acef4
adec731
db3063a
de53b13
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 wonder what this is used for, and I am guessing it is used to prevent synthesis of a ctor if there is already one provided via an extension.
I think the decision on whether or not to synthesize a ctor should be solely based on the struct type itself, and not any extensions.
We also need to make sure in the presence of an extension, the ctor provided in the extension should take precedence over the implicitly synthesized method during overload resolution.
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.
Well, this seems like a corner case we haven't discussed before.
I thought extension will be part of the struct, so it can also determine whether we should define the ctor.
The thing is that if the syntheized ctor is exactly the same as the explicit ctor in extension, won't that be a compile error?
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.
Yes, this what I was saying that during overload resolution, if we see a user defined ctor that is as good as the synthesized one, it should always be preferred over implicitly generated ones.
The one reason that ctor synthesis shouldn't depend on extensions is if a module defines public X and an internal extension on X that adds a ctor, should we synthesize ctor for X or not? When this decision is affected by extensions, we will say we don't. But then from the user of the module's perspective this is weird because they don't get to see the extension and yet X for some reason doesn't have the expected ctor.
If we say the decision is not dependent on extensions, then we will always synthesize the ctor. But inside the module that sees both the extension and X itself, the user defined ctor will be preferred over the synthesized one if it is applicable, so we will have no issues. From the outside of the module, they still can use the synthesized ctor without surprises.