Skip to content

[ClangImporter] Don't transform NSObject<...> when there's no NSObject protocol #27409

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 1 commit into from
Sep 30, 2019

Conversation

xymus
Copy link
Contributor

@xymus xymus commented Sep 27, 2019

If there is no NSObject protocol skip a special case when importing types like NSObject <NSCopying> that converts them to id <NSObject, NSCopying>.

Fix rdar://problem/34597302

@xymus xymus requested a review from jrose-apple September 27, 2019 21:23
// Skip if there is no NSObject protocol.
auto nsObjectProtoType =
Impl.getNSObjectProtocolType();
if (nsObjectProtoType) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens in the else case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will be treated like the other non NSObject<...> types, except if it hits another special case it is imported as a protocol composition of the class and the protocols.

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, so far we've just tested that "we have protocols" and "the class is NSObject". Okay.

@xymus
Copy link
Contributor Author

xymus commented Sep 27, 2019

@swift-ci Please smoke test

@xymus
Copy link
Contributor Author

xymus commented Sep 28, 2019

@swift-ci Please smoke test


// RUN: %target-swift-frontend -typecheck %s -import-objc-header %S/Inputs/no-nsobject-protocol.h

// REQUIRES: objc_interop
Copy link
Contributor

Choose a reason for hiding this comment

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

I think since there are no external dependencies you can use -enable-objc-interop instead.

… protocol

If there is no NSObject protocol, skip a special case when importing
types like `NSObject <NSCopying>` that converts them to
`id <NSObject, NSCopying>`.

Fix rdar://problem/34597302
@xymus
Copy link
Contributor Author

xymus commented Sep 28, 2019

@swift-ci Please smoke test

@xymus xymus merged commit 91e4c0e into swiftlang:master Sep 30, 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