Commit Graph

13406 Commits

Author SHA1 Message Date
Doug Gregor
905c830c45 [Runtime] Handle Error bridging as a last chance to cast to NSError/NSObject.
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.
2019-12-13 23:55:13 -08:00
Doug Gregor
5ed0641c59 [Runtime] Handle Error-conforming-to-NSObject casting fully.
I missed a case where an Error-conforming class is dynamically casted
to NSObject (via NSError). Fix it.
2019-12-13 23:55:13 -08:00
swift_jenkins
24888c3e68 Merge remote-tracking branch 'origin/master' into master-next 2019-12-12 12:39:50 -08:00
tbkka
cc8f8e929c SR-7732: Dynamic casting CFError to Error results in a memory leak (#28686)
* 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
2019-12-12 12:30:21 -08:00
Mike Ash
1da182555a [Runtime] When the ObjC runtime supports lazy class names, lazily create the ObjC names for generic classes.
rdar://problem/57674583
2019-12-12 15:25:22 -05:00
swift_jenkins
68c8b43146 Merge remote-tracking branch 'origin/master' into master-next 2019-12-12 09:59:57 -08:00
Karoy Lorentey
aeea84d931 Merge pull request #28728 from lorentey/assert-vs-internalInvariant
[stdlib] Don’t use assert() in the stdlib
2019-12-12 09:52:17 -08:00
Karoy Lorentey
d83a4257f0 [stdlib] Don’t use assert() in the stdlib
assert() is designed to be used in user code only; the equivalent stdlib function is called _internalInvariant().

rdar://57101013
2019-12-11 19:23:46 -08:00
swift_jenkins
d87b8df89a Merge remote-tracking branch 'origin/master' into master-next 2019-12-11 19:00:39 -08:00
Dan Zheng
8aac6f9a1a [AutoDiff upstream] Conform floating-point types to Differentiable. (#28718)
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.
2019-12-11 18:43:09 -08:00
swift_jenkins
4b192b0d2e Merge remote-tracking branch 'origin/master' into master-next 2019-12-11 13:40:24 -08:00
Ravi Kandhadai
d154f45f01 [stdlib-private][os log] Add new log methods for each specific logging level.
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.
2019-12-11 11:49:02 -08:00
swift_jenkins
6b53fd184c Merge remote-tracking branch 'origin/master' into master-next 2019-12-11 11:00:08 -08:00
Karoy Lorentey
4c3c3355f0 Merge pull request #28685 from lorentey/i-heard-you-like-runtime-so-i-put-a-runtime-in-your-foundation-overlay-so-you-can-run-while-you-found
[Foundation][runtime] Remove swift_errorBridgingInfo
2019-12-11 10:54:40 -08:00
swift_jenkins
c62f3500d8 Merge remote-tracking branch 'origin/master' into master-next 2019-12-11 07:40:52 -08:00
Luciano Almeida
392baefc47 [stdlib][Qol] SR-11295 Removing stdlib unnecessary coercions (#27165)
* Removing unnecessary casts from stdlib

* Minor adjustments

* [stdlib][qol] Clean up error variable assign NSError

* Removing unnecessary coercions after removing DeclRefExpr restriction.
2019-12-11 07:30:25 -08:00
swift_jenkins
3140acc993 Merge remote-tracking branch 'origin/master' into master-next 2019-12-10 21:20:05 -08:00
Robert Widmann
43a3ab7e35 Merge pull request #28665 from CodaFi/the-phantom-menace
Explicitly State CodingKeys as a Codable Requirement
2019-12-10 21:06:01 -08:00
swift_jenkins
a80cdb4dcc Merge remote-tracking branch 'origin/master' into master-next 2019-12-10 18:00:31 -08:00
Karoy Lorentey
2e17867774 Merge pull request #28378 from JacobMao/fix/SR-11283
SR-11283: Amend OptionSet.remove method
2019-12-10 17:41:45 -08:00
Robert Widmann
3bda241b11 State CodingKeys as an explicit requirement
The presence of this attribute will be used to guide the protocol derivation machinery to synthesize CodingKeys.
2019-12-10 16:28:51 -08:00
Karoy Lorentey
c34389ce72 [Foundation][runtime] Remove swift_errorBridgingInfo
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
2019-12-10 15:33:24 -08:00
swift_jenkins
cce8830e9b Merge remote-tracking branch 'origin/master' into master-next 2019-12-10 15:20:30 -08:00
Joe Groff
c8d2ec29a8 Merge pull request #28682 from apple/swift52-hooks
Bump runtime to load backward compatibility hacks from __swift52_hooks
2019-12-10 15:15:29 -08:00
Ravi Kandhadai
5ec4e762cf Merge pull request #28670 from ravikandhadai/oslog-ns-object-extension
[os log][stdlib/private] Add extensions for logging NSObjects.
2019-12-10 15:03:01 -08:00
Joe Groff
f7caa2d618 Bump runtime to load backward compatibility hacks from __swift52_hooks 2019-12-10 13:10:08 -08:00
Joe Groff
fb34044408 Merge remote-tracking branch 'origin/master' into master-next 2019-12-10 12:46:41 -08:00
Ravi Kandhadai
f705720f1e [os log][stdlib/private] Add extensions for logging NSObjects.
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.
2019-12-09 20:03:50 -08:00
Azoy
e3a440186a Reorder conformances in cake test 2019-12-07 14:53:13 -05:00
Azoy
eebf8825f9 post de-gyb formatting 2019-12-07 11:05:45 -05:00
Azoy
0c4aa6055f de-gyb unavailablestringapis 2019-12-07 11:05:45 -05:00
Azoy
3f5c7162cc de-gyb runtime 2019-12-07 11:05:45 -05:00
Azoy
73250ad93a de-gyb mirrors 2019-12-07 11:05:45 -05:00
Azoy
48672551c9 de-gyb existentialcollection 2019-12-07 11:05:44 -05:00
Azoy
eb8bd16ca5 de-gyb codable 2019-12-07 11:05:44 -05:00
Azoy
5469cd2c62 de-gyb builtinmath 2019-12-07 11:05:44 -05:00
Robert Widmann
c93d5095fc Merge pull request #28619 from plotfi/master-dec6-1
[NFCi] Adding inttypes.h to Errors.cpp due to llvm.org change in STLExtras.h.
2019-12-06 17:56:50 -08:00
Butta
14cc620016 [android] A few tweaks for native compilation and to get more tests working
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.
2019-12-07 01:01:59 +05:30
Puyan Lotfi
caf5af4027 [NFCi] Adding inttypes.h to Errors.cpp due to llvm.org change in STLExtras.h.
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)
2019-12-06 14:28:36 -05:00
Varun Gandhi
affa1b49bf [Runtime] Memset Extradata fully before copy from pattern. (#28478)
The third argument of memset needs a size in *bytes* not words.
2019-12-04 08:48:01 -08:00
Robert Widmann
5725984dc6 Merge pull request #28462 from dtorres/patch-1
[LazyFilterSequence] Preserve order of predicates
2019-12-03 19:37:36 -08:00
Ravi Kandhadai
05be088431 [stdlib/private][oslog] Make tiny helper functions of struct OSLogMessage constant_evaluable
instead of transparent.
2019-12-03 11:14:49 -08:00
Robert Widmann
9893ef575b Merge pull request #20481 from linux-on-ibm-z/swift4.2-s390x-ABIChanges
Towards s390x arch support - ConfigureSystemZ changes
2019-12-02 11:17:03 -08:00
swift-ci
4caf584406 Merge pull request #28436 from mikeash/better-metadata-generic-args-dumping 2019-12-02 11:16:43 -08:00
Saleem Abdulrasool
ff5741cec2 Merge pull request #28464 from compnerd/local-remote
build: separate out host build of SwiftRemoteMirror
2019-12-02 09:02:22 -08:00
Erik Eckstein
3e932c075d stdlib: Add custom .first to Array
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
2019-11-27 09:55:27 +01:00
Erik Eckstein
87298c07c8 stdlib: make the non-native Array.count smaller more efficient.
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.
2019-11-26 18:20:39 +01:00
Saleem Abdulrasool
683f7f563e build: separate out host build of SwiftRemoteMirror
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.
2019-11-24 10:08:36 -08:00
Diego Torres
3c4eeadc83 Preserve order of predicates
Fixes https://bugs.swift.org/browse/SR-11841
2019-11-24 15:42:33 +01:00
Adrian Prantl
1d5518236d Add missing include for PRIxPTR (NFC) 2019-11-22 13:18:01 -08:00