-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Some fixes for DynamicSelfType #21786
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
slavapestov
merged 6 commits into
swiftlang:master
from
slavapestov:dynamic-self-is-so-broken
Jan 11, 2019
Merged
Some fixes for DynamicSelfType #21786
slavapestov
merged 6 commits into
swiftlang:master
from
slavapestov:dynamic-self-is-so-broken
Jan 11, 2019
Conversation
This file contains hidden or 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
Contributor
slavapestov
commented
Jan 11, 2019
- https://bugs.swift.org/browse/SR-9429
- https://bugs.swift.org/browse/SR-9430
- rdar://problem/32288771
- rdar://problem/46982573
@swift-ci Please smoke test |
@swift-ci Please test source compatibility |
jckarter
approved these changes
Jan 11, 2019
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.
LGTM, thanks Slava!
Thanks for taking a look. There’s one test failure but I don’t expect the fix to require radical changes. |
We need to propagate some bits from the field types, at least the 'has dynamic self' bit, for some SIL verifier assertions to not fire.
…wift 5 mode In Swift 5 mode, 'self' in a convenience init has a DynamicSelfType, so the value_metatype instruction returns a DynamicSelfType metatype. However, the metatype argument to the constructor is a plain class metatype because it's an interface type, so we have to "open" it by bitcasting it to a DynamicSelfType. Fixes <https://bugs.swift.org/browse/SR-9430>, <rdar://problem/46982573>.
…le capture If a closure uses DynamicSelfType but doesn't capture the 'self' value itself, we would add a dummy metatype capture so that IRGen can recover metadata. Also do this if we do capture a value of DynamicSelfType, but mutably, that is by address or by box, since IRGen doesn't know how to recover the metadata in that case. Fixes <rdar://problem/32288771>.
We lower away a top-level DynamicSelfType, so let's just strip them off before trying the other conversions. For now this is NFC, but we can end up here after the next patch. Even then we shouldn't end up here except when emitting protocol witnesses. The relevant case is when a base class method (return @dynamic_self Base) is used by a derived class to witness a requirement on a protocol (which returns @dynamic_self Derived since its a derived class conformance). In this case, we know both values have the same type, but the lowered types are $Base and $Derived, respectively, so we must emit an unchecked downcast.
Get rid of some randomly-placed calls to eraseDynamicSelfType() and refactors things in preparation for the next change.
b5f2062
to
5ade432
Compare
@swift-ci Please smoke test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.