Skip to content

[Runtime] Check for @objc existentials conforming to @objc protocols. #20217

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

Conversation

DougGregor
Copy link
Member

When checking conformance requirements against an @objc protocol, also
check for an @objc existential using protocol_conformsToProtocol().
Fixes rdar://problem/45685649.

When checking conformance requirements against an @objc protocol, also
check for an @objc existential using protocol_conformsToProtocol().
Fixes rdar://problem/45685649.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

case MetadataKind::Existential: {
#if SWIFT_OBJC_INTEROP
// If all protocols are @objc and at least one of them conforms to the
// protocol, succeed.
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm. What about non-@objc protocols that inherit from @objc protocols?

Copy link
Member Author

Choose a reason for hiding this comment

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

Only @objc existentials can conform to protocols. A non-@objc protocol does not, even if it inherits from an @objc protocol. For example, the type checker rightly rejects this:

@objc protocol P { }
protocol Q: P { }
struct X<T:P> { }
typealias Y = X<Q>

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, right, we aren't unboxing anything in this cast.

@DougGregor DougGregor merged commit 8552af0 into swiftlang:master Nov 1, 2018
@DougGregor DougGregor deleted the runtime-objc-existential-conforms-to-protocol branch November 1, 2018 16:33
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