Rather than attempting Error bridging early when trying to dynamically
cast to NSError or NSObject, treat it as the *last* thing we do when
all else fails. Push most of this code over into Objective-C-specific
handling rather than #ifdef'd into the main casting logic to make that
slightly more clear.
One oddity of Error/NSError bridging is that a class that conforms to
Error can be dynamically cast to NSObject via Error bridging. This has
always been known to the static compiler, but the runtime itself was
not always handling such a cast uniformly. Do so now,
uniformly. However, this forced us to weaken an assertion, because
casting a class type to NSError or NSObject can produce an object with
a different identity.
Fixes rdar://problem/57393991.
* SR-7732: Dynamic casting CFError to Error results in a memory leak
The special handling for casting CFError/NSError to Swift Error
type was using cleanup code that didn't correctly handle this case.
This replaces the cleanup code with a more targeted version.
Fixes: SR-7732
Fixes: rdar://problem/40423061
* Whitespace fixes
* Don't rely on localizable strings to verify test behavior.
I've verified this simplified test still leaks with
the original code and does not leak with the fixed code.
* Don't test against old runtimes that predate this fix
* Explicitly test both NSError and CFError
Add `Differentiable` conformances for floating-point types to the
`_Differentiation` module. The `TangentVector` associated type for
floating-point types is `Self`.
This design adheres to the differentiable programming manifesto:
docs/DifferentiableProgramming.md.
Partially resolves TF-1052.
Also, add aliases for the logging levels for source compatibility with swift-server
side logging. Create a new initializer of Logger that can directly accept an
existing os log object of type `OSLog`. This aids in porting uses of existing
os_log API to the new API.
To implement swift_errorBridgingInfo, the Foundation overlay needs to import private runtime headers. Now that we cannot statically link the Foundation overlay, there is no point to keeping this workaround in the overlay any more.
This effectively reverts https://github.com/apple/swift/pull/16677.
rdar://problem/57809306
The extensions for supporting NSObjects are in the file:
OSLogNSObjectType.swift. This creates a new dependency for the
OSLogPrototype overlay on the module: ObjectiveC. However,
ObjectiveC is already a dependency for the os module.
This patch includes tests for the NSObject extensions.
In addition, this patch contains a few other minor changes.
1. It makes the `osLog` function public (so that it can be
used by clients directly). 2. It fixes a lifetime-related
bug in the osLog function implementation. 3. It improves
the OSLogPrototypeExecTest suite by refactoring a few
helper functions.
Now that CMAKE_HOST_SYSTEM_NAME and CMAKE_SYSTEM_NAME are set by default to
Android in the Termux app, make the needed tweaks. Some tests were adapted
to work natively on Android too, adds sys/cdefs.h to the Bionic modulemap,
and includes the start of native Android platform support in the build-script.
In Errors.cpp, PRIxPTR is used in a format string:
constexpr const char *format = "%-4u %-34s 0x%0.16" PRIxPTR " %s + %td\n";
This fails to build because of upstream changes in STLExtras:
049043b598 (diff-43fc25e3af55e1ae97f17ef051d68aa4)
This patch merely adds the include for the needed PRIxPTR define.
(cherry picked from commit 0529fbedca)
This makes Array.first much small and more efficient.
Without this, Array.first compiled down to RandomAccessCollection.first, which ended up in pretty unefficient code.
rdar://problem/46291397
Use _CocoaArrayWrapper.endIndex which returns the NSArray.count.
In the old version, "count" translated to RandomAccessCollection.count, which ended up in multiple calls to endIndex.
Separate out the host build of SwiftRemoteMirror from the "target" build
(the host for the standard library may be different from the host for
the compiler). Restructure the build to ensure that we use the correct
compiler for building the SwiftRemoteMirror for the host. This fixes a
build issue when building for Linux AArch64.