Open swift-ci opened 4 years ago
Comment by Ondrej Hanslik (JIRA)
You are misusing the language. Such a thing wouldn't be safe to do even in Objective-C. Use a subclass instead. The fact that some StackOverflow answers recommend such a thing is not a valid reason.
Comment by Marc Etcheverry (JIRA)
As I said on the ticket, I know this. Doing this with a category in ObjC is wrong, and Swift possibly implements this through categories if extending ObjC classes. The issue is about the regression, either in Swift 5.2 or iOS 13.4, and the lack of a warning. The fact that everybody does this without being warned at compile time or runtime is a bug.
@swift-ci create
marcetcheverry (JIRA User) I can't seem to make this fail to compile. Could you attach a sample project, or at least give the text of the error you're getting so I can look into this change?
Environment
Swift 5.2, Xcode 11.4 MASAdditional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | | |Labels | Improvement | |Assignee | None | |Priority | Medium | md5: 51a14dc2e0b979e10e1e74bb2ae8e290Issue Description:
This code works in 5.1.3 (Xcode 11.3.1), but does not work in Swift 5.2 (Xcode 11.4, iOS 13.4)
Note that the `topViewController` example is just an example. The second case, of `childForStatusBarStyle` is used widely and in many StackOverflow answers.
Regardless of the safety and how wise it is to use this pattern, there should not be a silent regression from one Swift version to the other.
Please, let’s add a warning either at compile time or runtime that this unsafe behavior and only available for compatibility reasons.