Skip to content

[SILGen] Emit default arg generator for stored property kind #23648

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 6 commits into from
Apr 2, 2019

Conversation

Azoy
Copy link
Contributor

@Azoy Azoy commented Mar 29, 2019

In order to properly serialize stored property default arguments, we need to emit a default arg generator.

I chose to emit the parent initializer expression instead of the apply to the variable initializer because SIL would eventually just inline the function definition anyway (or at least in most cases from my findings) and this was a lot cleaner and cheaper implementation wise. I've updated the SILGen tests and added a serialization test.

cc: @slavapestov @jrose-apple

@jrose-apple
Copy link
Contributor

The approach looks good to me but I think Slava should check the details. Thank you, Alejandro!

@Azoy
Copy link
Contributor Author

Azoy commented Mar 29, 2019

I'm questioning whether we need a special default arg kind anymore with this implementation. Also, I feel like I explored this route in the initial patch, but just couldn't make it work then.

Copy link
Contributor

@slavapestov slavapestov left a comment

Choose a reason for hiding this comment

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

I’m a bit nervous about this because now we will emit some expressions twice, once for the property initializer and once for the default argument. In the past we’ve had bugs with multiple emission of expressions; that’s why we introduced property initializers in the first place, so that each constructor doesn’t re-emit these expressions. I would suggest therefore changing the default argument generators to call the property initializers instead of re-emitting them, even though it’s slightly more complicated.

@Azoy
Copy link
Contributor Author

Azoy commented Mar 29, 2019

Oh I didn't know this was the case for expressions. 👍

@Azoy
Copy link
Contributor Author

Azoy commented Mar 30, 2019

@slavapestov I believe I did this correctly, but would love feedback. I've added some more tests to exercise indirect results.

Copy link
Contributor

@slavapestov slavapestov left a comment

Choose a reason for hiding this comment

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

Looks good!

@slavapestov
Copy link
Contributor

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor

@swift-ci Please test source compatibility

@slavapestov slavapestov self-assigned this Mar 31, 2019
@Azoy Azoy force-pushed the maybe-add-default-arg-generator branch from f0b33f8 to edcab95 Compare March 31, 2019 23:32
@Azoy
Copy link
Contributor Author

Azoy commented Mar 31, 2019

@slavapestov okay, I believe I have fixed the TBD test, as well as pull in your test changes as well.

@slavapestov
Copy link
Contributor

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor

@swift-ci Please test source compatibility

@jrose-apple
Copy link
Contributor

Release is usually a whole-module build; maybe you have a default arg generator being emitted from one file that references an initial value in another file, or something like that?

@Azoy
Copy link
Contributor Author

Azoy commented Apr 1, 2019

Thanks Jordan! I think I see the issue, will work on this when I get home.

@Azoy
Copy link
Contributor Author

Azoy commented Apr 1, 2019

@slavapestov I hate to ping you again, but I believe this is the one!

@jrose-apple
Copy link
Contributor

@swift-ci Please test source compatibility

@jrose-apple
Copy link
Contributor

@swift-ci Please test

@swift-ci

This comment has been minimized.

@jrose-apple
Copy link
Contributor

@swift-ci Please test macOS

@jrose-apple
Copy link
Contributor

@swift-ci Please test source compatibility

@swift-ci

This comment has been minimized.

@slavapestov
Copy link
Contributor

Thanks @Azoy!

@tkremenek tkremenek merged commit 00955c1 into swiftlang:master Apr 2, 2019
Azoy pushed a commit to Azoy/swift that referenced this pull request Apr 2, 2019
…nerator

[SILGen] Emit default arg generator for stored property kind

fix tests
@Azoy Azoy deleted the maybe-add-default-arg-generator branch April 3, 2019 04:28
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.

5 participants