-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
- PromiseKit 6.13.1, installed via CocoaPods
I recently ran into a nasty crashing bug in my codebase because I had a return AnyPromise()
in some edge case. I wasn't aware that it was illegal to construct AnyPromise()
without any arguments.
AnyPromise
's default argument-less init
initializer is correctly marked as unavailable
in the Objective-C header (see https://github.com/mxcl/PromiseKit/blob/master/Sources/AnyPromise.h#L295).
When trying to call it from Objective-C with [[AnyPromise alloc] init]
the compiler correctly complains. However, there's no warning and no compiler error when illegally constructing it from Swift using AnyPromise()
. Is there a way to work around for this? I've tried a few, but to no avail. Shouldn't the Swift compiler pick up the Objective-C unavailable
declaration in AnyPromise.h
? So is there any solution we could implement for this?
Here's a related discussion with an Apple Engineer: https://developer.apple.com/forums/thread/650054?login=true&page=1#648364022