Skip to content

Optimize deconstruction of default literal and expression #25831

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

Merged
merged 2 commits into from
Apr 3, 2018

Conversation

jcouv
Copy link
Member

@jcouv jcouv commented Mar 30, 2018

Customer scenario

(int i, string s) = default; doesn't need to instantiate default((int, string)) and then access its .Item1 and .Item2. The parts resulting from deconstruction are default(int) and default(string).

Bugs this fixes

Fixes #21232

Although we could technically apply this optimization in 15.8, I think it makes more sense to stack this on top of the "default deconstruction" feature (#25562).

@jcouv jcouv added this to the 16.0 milestone Mar 30, 2018
@jcouv jcouv self-assigned this Mar 30, 2018
@jcouv jcouv requested a review from a team as a code owner March 30, 2018 05:44
@jcouv jcouv added the Feature - Tuples Tuples label Mar 30, 2018
@jcouv
Copy link
Member Author

jcouv commented Mar 30, 2018

@dotnet/roslyn-compiler for review. Two-liner change. Thanks

@AlekseyTs
Copy link
Contributor

    (int i, string s) = default;

It would be good to have a test with default of non-tuple type here, or default of a tuple type of different cardinality.


Refers to: src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenDeconstructTests.cs:8351 in 465ef3d. [](commit_id = 465ef3d, deletion_comment = False)

Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

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

LGTM (iteration 1)

@alrz
Copy link
Member

alrz commented Apr 2, 2018

(perhaps test (x, y) = default; where x and y are existing locals/parameters)

@jcouv jcouv merged commit bd52e46 into dotnet:features/decon-default Apr 3, 2018
@jcouv jcouv deleted the optimize-decon branch April 3, 2018 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants