Skip to content
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

[SR-2935] It is possible to "hide" methods imported from Obj-C via NS_SWIFT_NAME in extensions #45529

Open
swift-ci opened this issue Oct 13, 2016 · 4 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-2935
Radar None
Original Reporter cezarywojcik (JIRA User)
Type Bug
Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 632cfe1083a0b8240852665f12f1a275

is duplicated by:

  • SR-3228 Compiler allows overriding functionality of classes included from frameworks via extensions

Issue Description:

Here's a quick example:

@belkadan
Copy link
Contributor

"Override" is the wrong word (since existing calls to -dismissViewControllerAnimated:completion: won't start calling your new method), but I would expect overload checking to complain here. Maybe it's because it's in a different module that it doesn't.

@swift-ci
Copy link
Collaborator Author

Comment by Cezary Wojcik (JIRA)

Yeah, my bad on poor word choice, I updated it.

I agree that I would expect the same kind of error that you get when you try to do the same thing with "func viewDidLoad() { }" - otherwise, you can sneak a file like this into a module and break all dismiss calls.

@belkadan
Copy link
Contributor

You can do this with viewDidLoad() too if you add @nonobjc. :-/

@swift-ci
Copy link
Collaborator Author

Comment by Cezary Wojcik (JIRA)

True, but the @nonobjc is a bit easier to spot as a potential issue. For context, this is an issue I saw in a migration from Swift 2.3 to Swift 3. There was a helper method on a UIViewController extension that was named this way pre-migration, which caused all dismiss calls to stop working after the Swift 3 migration until this issue was identified. Might be an issue that is harder to detect for less obvious use cases.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

2 participants