Skip to content

Conversation

slavapestov
Copy link
Contributor

@slavapestov slavapestov requested a review from jckarter January 11, 2019 03:16
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

Copy link
Contributor

@jckarter jckarter left a comment

Choose a reason for hiding this comment

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

LGTM, thanks Slava!

@slavapestov
Copy link
Contributor Author

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.
@slavapestov slavapestov force-pushed the dynamic-self-is-so-broken branch from b5f2062 to 5ade432 Compare January 11, 2019 21:00
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov slavapestov merged commit 2c2f8a3 into swiftlang:master Jan 11, 2019
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.

2 participants