Commit Graph

1358 Commits

Author SHA1 Message Date
Itai Ferber
07d396b712 Encode Decimal as a numeric value in JSON
Allow JSONEncoder/JSONDecoder to intercept Decimal values so they get
a numeric representation in JSON (instead of their default keyed
implementation).
2017-06-23 13:02:13 -07:00
Itai Ferber
72d62af309 Merge pull request #10520 from itaiferber/foundation-shared-encoders
Allow Codable classes to share an Encoder with superclass
2017-06-23 12:48:09 -07:00
Maxim Moiseev
3c9481b4a6 Merge pull request #10521 from moiseev/intents-availability
[overlay] Fix availability in INSearchCallHistoryIntent
2017-06-23 11:06:10 -07:00
Maxim Moiseev
6c4379f8b3 [overlay] Fix availability in INSearchCallHistoryIntent 2017-06-22 15:55:22 -07:00
Itai Ferber
25fc3ed34f Merge pull request #10515 from itaiferber/nskeyedarchiver-data-overloads
Change NSKeyedUnarchiver method instead of adding overloads
2017-06-22 15:54:49 -07:00
Itai Ferber
184efb085c Allow classes to share an Encoder with superclass
On encode, we previously treated every container request as a push;
instead, we should allow the same container type to be requested
multiple times so a class can pass its Encoder directly to its
superclass if it needs to.
2017-06-22 15:45:02 -07:00
Itai Ferber
a5df6fa484 Change modified method instead of adding overloads
The unarchiveTopLevelObjectWithData which returns Any? (instead of
AnyObject?) was added in Swift 4 and has only shipped in the betas so
far. Instead of adding new overloads which take different types, we
should just fix this one and call it a day.
2017-06-22 14:23:21 -07:00
Philippe Hausler
d31ffc7d5e [Foundation] Validate indexes and ranges passed into Data so that bounding conditions are respected 2017-06-22 11:25:57 -07:00
Itai Ferber
004a98b76f Merge pull request #10474 from itaiferber/nskeyedarchiver-data-overloads
NSKeyedUnarchiver methods should take Data (instead of just NSData)
2017-06-22 10:44:54 -07:00
Philippe Hausler
6d7c49ff61 [Foundation] Prevent incorrect slice access when dropping elements 2017-06-22 07:23:46 -07:00
Itai Ferber
cc313da8ab NSKeyedUnarchiver methods should take Data
We missed a few NSKeyedUnarchiver methods during our original renaming
for Swift — some of these methods still take NSData when they can take
Data. We can add Data variants which bridge to NSData to fix this in a
backwards-compatible way.
2017-06-21 16:23:29 -07:00
Maxim Moiseev
b5f28bfb35 Merge pull request #10430 from moiseev/focus-shim
[overlay] Implement UIFocusEnvironment.contains using a shim
2017-06-21 08:56:29 -07:00
Jordan Rose
e9622db324 [Foundation] Make CocoaError.Code and URLError.Code Hashable. (#10437)
This is consistent with imported error codes, which are always
Hashable. URLError.Code was also Hashable in Swift 3.1 by virtue of
being defined as an enum; the change to a struct broke that.

rdar://problem/32066434
2017-06-20 20:15:48 -07:00
Jordan Rose
f868d6dffe Fix up 08c2a7a3ac for 32-bit platforms. (#10433)
...where swift::TwoWordPair is defined a little less freely.
2017-06-20 19:24:36 -07:00
Jordan Rose
08c2a7a3ac Finish off the log part of _swift_checkClassAndWarnForKeyedArchiving. (#10418)
Logs a warning the first time a problematic class is archived or
unarchived. We expect people to actually fix these issues, so the
performance of the warning isn't too important.

Sample output:

  [timestamp] Attempting to archive Swift class '_Test.Outer.ArchivedThenUnarchived', which does not have a stable runtime name.
  [timestamp] Use the 'objc' attribute to ensure that the runtime name will not change: "@objc(_TtCC5_Test5Outer22ArchivedThenUnarchived)"
  [timestamp] If there are no existing archives containing this class, you can choose a unique, prefixed name instead: "@objc(ABCArchivedThenUnarchived)"

Finishes rdar://problem/32414508
2017-06-20 17:15:28 -07:00
Max Moiseev
52522f118c [overlay] Implement UIFocusEnvironment.contains using a shim
Addresses: <rdar://problem/32538412>
2017-06-20 17:14:24 -07:00
Itai Ferber
e0f75bf841 Merge pull request #10343 from itaiferber/cg-types-codable-conformance
Add Codable conformance to common CG types
2017-06-20 09:32:56 -07:00
Roman Levenstein
2f920c4ad2 Add a new frontend option -sil-serialize-witness-tables to force serialization of SIL witness tables
This option is supposed to be used only for compiling overlays. User code should never be compiled with this option.
2017-06-19 19:49:01 -07:00
Itai Ferber
fedf8e6908 Add Codable conformance to common CG types
Give custom Codable implementations for CGAffineTransform, CGPoint,
CGSize, CGRect, and CGVector, along with unit tests.
2017-06-19 17:23:11 -07:00
Philippe Hausler
29f080f0c3 [Foundation] 1-ary IndexPath forms invalid range on slices 2017-06-16 17:41:19 -07:00
Philippe Hausler
c358afe655 [Foundation] Adjust Double and Float bridges to be more lenient 2017-06-16 15:18:27 -07:00
Philippe Hausler
689fc28edc [Foundation] Add migration hints for deprecated NSNumber based initializers 2017-06-16 15:18:27 -07:00
Philippe Hausler
1ca142eba4 [Foundation] Correct NSRange equality typo and add unit tests for newly added NSRange behaviors (#10282) 2017-06-16 13:38:31 -07:00
Maxim Moiseev
a8f3f29917 [overlay] Adding back dependencies on os and XPC to CloudKit (#10258) 2017-06-15 11:50:54 -07:00
Maxim Moiseev
07031ab480 Merge branch 'master' into watchkit-deps 2017-06-14 16:49:51 -07:00
Mishal Shah
c5ff1f2cac Update master to build with Xcode 9 beta 1, OS X 10.13, iOS 11, tvOS 11, and watchOS 4 SDKs. 2017-06-14 16:20:35 -07:00
Max Moiseev
bba4d9eada [overlay] Add mising dependencies to WatchKit overlay
Fixes: <rdar://problem/32776189>
2017-06-14 15:38:49 -07:00
Maxim Moiseev
a31e2bde14 Merge pull request #10097 from apple/stringprotocol-reform
[stdlib] Eliminate over-constraint on StringProtocol
2017-06-14 15:13:56 -07:00
Itai Ferber
5daa71c8ad Merge pull request #10249 from itaiferber/master
Allow SingleValueContainers to decode collections
2017-06-14 14:24:15 -07:00
Max Moiseev
5b9cba1830 [overlay] Update CloudKit overlay dependencies
Fixes: <rdar://problem/32769260>
2017-06-14 12:21:42 -07:00
Itai Ferber
48d183e62a Allow SingleValueContainers to decode collections
SingleValueDecondingContainers in JSON and Plist previously held the
assertion that attempting to decode an array or dictionary from them
was a type mismatch (since those represented unkeyed and keyed
containers, respectively). This assertion is no longer true, though,
since encode<T : Encodable>(_:) and decode<T : Decodable>(_:) allow
you to do just that.

This lifts the assertion and adds unit tests to both implementations to
ensure this works. (Addresses https://bugs.swift.org/browse/SR-5089)
2017-06-14 11:14:20 -07:00
Erik Eckstein
ce188682e5 runtime: remove an unnecessary helper function to get the class name 2017-06-13 15:20:07 -07:00
Erik Eckstein
1bff67f573 runtime: use class_getName instead of NSStringFromClass in _swift_checkClassAndWarnForKeyedArchiving 2017-06-13 09:25:42 -07:00
Erik Eckstein
488c43c825 runtime: add a runtime function _swift_checkClassAndWarnForKeyedArchiving
This function checks if a mangled class name is going to be written into an NSArchive.
If yes, a warning should be printed and the return value should indicate that.

TODO: print the actual warning

rdar://problem/32414508
2017-06-07 17:02:00 -07:00
Jordan Rose
485ebefba7 Merge pull request #10083 from jrose-apple/nscoding-diags-take-2
Update and re-enable the diagnostics for unstable runtime names
2017-06-05 19:51:01 -07:00
Jordan Rose
f0aca936c7 Allow '@objc(RuntimeName)' on classes with generic ancestry.
This is accomplished by recognizing this specific situation and
replacing the 'objc' attribute with a hidden '_objcRuntimeName'
attribute. This /only/ applies to classes that are themselves
non-generic (including any enclosing generic context) but that have
generic ancestry, and thus cannot be exposed directly to Objective-C.

This commit also eliminates '@NSKeyedArchiverClassName'. It was
decided that the distinction between '@NSKeyedArchiverClassName' and
'@objc' was too subtle to be worth explaining to developers, and that
any case where you'd use '@NSKeyedArchiverClassName' was already a
place where the ObjC name wasn't visible at compile time.

This commit does not update diagnostics to reflect this change; we're
going to change them anyway.

rdar://problem/32414557
2017-06-05 17:32:25 -07:00
Max Moiseev
6738a2afd7 [overlay] Add unavailble x/y to CGRect to redirect to minX/minY 2017-06-05 14:01:14 -07:00
Dave Abrahams
eb04df45f4 [stdlib] Eliminate over-constraint on StringProtocol 2017-06-03 17:18:20 -07:00
Chris Amanse
c783d27f17 Remove for loop in computing mantissa double value (#8804) 2017-05-27 13:53:25 -07:00
Alex Blewitt
3b628d32fc Fix typo in renamed function SR-5015 (#9939) 2017-05-26 06:41:39 -07:00
Philippe Hausler
c40ba96328 [Foundation] Correct data subscript indexing to be offset from the base index (#9816) 2017-05-24 09:43:56 -07:00
Dave Abrahams
399193ff30 Merge pull request #9847 from apple/eliminate-_Element
[stdlib] Eliminate _Element
2017-05-23 16:44:55 -07:00
Ted Kremenek
dbe77601f3 Merge pull request #9791 from itaiferber/swift-archival-serialization-updates
Enhancements to Codable API
2017-05-22 23:53:49 -07:00
Dave Abrahams
72f5e7c0c2 [stdlib] Eliminate _Element 2017-05-22 16:17:58 -07:00
Max Moiseev
4179fcb390 [overlay] Fix CMTimeRange.isValid
<rdar://problem/30576556>
2017-05-22 10:36:38 -07:00
Maxim Moiseev
421684b12f Merge pull request #9755 from moiseev/affine-transform-hashvalue
[Foundation] Unbreaking the expression that used to be too complex
2017-05-22 10:03:33 -07:00
Itai Ferber
d16297dad5 Introduces changes to Codable stdlib API
* Adds conformance of Optional to Codable
* encode(...) arguments are no longer Optional; Optional values go
  through generic version
* encodeIfPresent added to KeyedEncodingContainerProtocol to mirror
  decodeIfPresent
* JSONEncoder and PropertyListEncoder updated to reflect these changes
2017-05-22 09:29:36 -07:00
Kevin Ballard
7be57bbf95 [SDK] Fix broken rangeIndex test for IndexSet.Index comparisons
It was always testing `rhs` against `rhs`, so it could never fail. But
we don't actually need the test at all, because the `value` field is
sufficient to compare indices.
2017-05-19 15:18:04 -07:00
Kevin Ballard
76fe9ea214 [SDK] Fix IndexSet.startIndex for empty sets that used to have values
We can't rely on `_range(at:)` producing valid results for sets that
have no ranges.

Fixes SR-4947.
2017-05-19 15:18:04 -07:00
eeckstein
bc4ad8f079 Merge pull request #9754 from eeckstein/enable-gen-inline
Enable generic inlining and partial specialization in libswiftFoundation
2017-05-18 19:03:50 -07:00