Skip to content

[stdlib] _SwiftNativeNS*.init(): Add @nonobjc attribute #14126

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
Jan 26, 2018

Conversation

lorentey
Copy link
Member

@lorentey lorentey commented Jan 24, 2018

This fixes an @objc inference warning for _SwiftNativeNSArray.init during stdlib builds.

@lorentey lorentey requested a review from lancep January 24, 2018 15:21
@lorentey
Copy link
Member Author

@swift-ci please smoke test

@jrose-apple
Copy link
Contributor

You probably want this to be @nonobjc, though, because there's no reason to expose this to Objective-C. Right?

@lorentey
Copy link
Member Author

Hm, I chose @objc because it is overriding NSArray.init() in an underhanded way -- but it shouldn't ever be called from Objective-C. Do you think it's safe to flip it to @nonobjc?

If so, we can also change some additional cases below this one.

@jrose-apple
Copy link
Contributor

Do you get a valid _SwiftNativeNSArray out if [[_SwiftNativeNSArray alloc] init] actually gets called? If not, I don't think it's interesting.

…ve-C

These aren't supposed to be called from Objective-C, and having them @nonobjc does not preclude subclasses from re-exposing their own initializers.

This fixes a build-time warning for @objc inference on _SwiftNativeNSArray.init.
@lorentey
Copy link
Member Author

It all works out; alloc gets the SwiftObject implementation, and init is empty anyway. 🎉
I switched _SwiftNativeNSArray.init and three similar initializers to @nonobjc.

@lorentey
Copy link
Member Author

@swift-ci please smoke test

@lorentey lorentey changed the title [stdlib] _SwiftNativeNSArray.init(): Add @objc attribute [stdlib] _SwiftNativeNS*.init(): Add @nonobjc attribute Jan 25, 2018
@lancep
Copy link
Contributor

lancep commented Jan 26, 2018

LGTM!

@lorentey lorentey merged commit 7a6d14f into swiftlang:master Jan 26, 2018
@lorentey lorentey deleted the warnings1 branch January 26, 2018 11:46
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.

3 participants