There's some behavior from 4.1 and 3 that seems to have regressed in swift-corelibs-foundation, but not the Darwin version of Foundation.
In particular, if I do this:
let value = NSNumber(value: 0.25) as? Bool
In Swift 4.1, 3.1, and also MacOS X 4.2, this returns nil. IBM-Swift/SwiftyJSON on Linux relies on this behavior to detect JSON types for example.
Unfortunately, with the swift-4.2-RELEASE tag, if I'm using swift-corelibs-foundation, either on MacOS X or Linux, this code always returns false.
There's an underlying bug in the implementation of
Bool._conditionallyBridgeFromObjectiveC that I'm attempting to fix (it returns
false for 0.25, and
true for 1.25, while Darwin). I've got a fix, and I've updated the unit tests, but the issue I'm hitting is that for some reason swift-corelibs-foundation seems to consider that the 'as' cast can never fail.
It obviously could fail in 4.1, so I'm trying to understand what drives the 'as' cast and why it is going through
_unconditionallyBridgeFromObjectiveC for NSNumber, instead of
_conditionallyBridgeFromObjectiveC like it appeared to do in 4.1 and earlier?