Commit Graph

596 Commits

Author SHA1 Message Date
Doug Gregor
b0f9317765 [SE-0112] Add error protocols LocalizedError, RecoverableError, CustomNSError
An error type can conform to one or more of these new protocols to
customize its behavior and representation. From an implementation
standpoint, the protocol conformances are used to fill in the
user-info dictionary in NSError to interoperate with the Cocoa
error-handling system.

There are a few outstanding problems with this implementation,
although it is fully functional:
  * Population of the userInfo dictionary is currently eager; we
  should use user info providers on platforms where they are
  available.
  * At present, the Swift dynamic casting machinery is unable to unbox a
  _SwiftNativeNSError when trying to cast from it to (e.g.) an
  existential, which makes it impossible to retrieve the
  RecoverableError from the NSError. Instead, just capture the original
  error---hey, they're supposed to be value types anyway!---and use that
  to implement the entry points for the informal
  NSErrorRecoveryAttempting protocol.

This is part (1) of the proposal solution.
2016-07-12 10:53:52 -07:00
Stephen Canon
9c08fbf4ed SE-0113 + residual SE-0067 work (#3443)
Implemented SE-0113 + residual SE-0067 operations.

- adds `rounded` and `round` to `FloatingPoint`, from SE-0113.
- adds `remainder`, `squareRoot`, and `addingProduct`, from SE-0067.
- adds basic test coverage for all of the above.
- provides a default implementation of `nextDown` on `FloatingPoint`.
2016-07-11 09:38:25 -04:00
Michael Ilseman
6cdbacca9d Merge pull request #3420 from milseman/scenekit
[SceneKit] Add apinotes to swift_private some decls
2016-07-08 23:30:33 -07:00
swift-ci
553ae8c034 Merge pull request #3422 from moiseev/callkit-overlay 2016-07-08 22:42:17 -07:00
Max Moiseev
29d7e66493 CallKit overlay with apinotes 2016-07-08 15:43:06 -07:00
Michael Ilseman
cd9b480103 [SceneKit] Add apinotes to swift_private some decls
These apinotes will swift_private many of the bounding box methods,
and adjust the overlays appropriately. Those APIs have better
alternatives provided by the overlays, and thus shouldln't be exposed.
2016-07-08 14:37:16 -07:00
Tony Parker
f9c1dd4386 Adopt the new indexing model for better perf in IndexSet
Concurrently with the development of struct IndexSet, the stdlib team
was busy reworking the way that all indexes in collections worked
(https://github.com/apple/swift-evolution/blob/master/proposals/0065-collections-move-indices.md).
Both efforts landed at basically the same time. We did the minimum
possible to adopt the new indexing model when IndexSet landed. This
change more correctly adopts the new model.

In summary, the new model has the Collection change the value of the
Index, instead of the Index changing the value on its own. Previously,
the Index had methods like successor(), but now the Collection has
methods like index(after:). This means that the index no longer has to
store a reference to the collection in many cases, which means that CoW
semantics can kick in far more often as the index is a dead simple model
object that just stores a bunch of integers. So basically, this change
moves all the logic for moving indexes from Index into IndexSet.

<rdar://problem/26269319> More fully adopt new indexing model for better performance in IndexSet
2016-07-08 14:15:49 -07:00
Tony Parker
b4e10dabad Fix a typo (thanks @KentaKudo) 2016-07-08 11:26:24 -07:00
Tony Parker
c2c1b8468a Add overloads for range types to IndexSet
The Swift 3 refactoring of the range type has led to its split into 4
different types. The IndexSet API should accept any of these as long as
they contain the element type (Int, which is inherently Countable). This
allows callers to use both the ... and ..< syntax, for example.

This commit also adds additional unit tests for some of the IndexSet
API, and turns a few methods with optional/default args into properties
or a method family, since otherwise callers would end up with an
ambigious method call as the range argument would have been defaulted to
nil.

<rdar://problem/26532614> Add overloads for range types to IndexSet
2016-07-08 10:17:03 -07:00
Dmitri Gribenko
ce94bd9cca Merge pull request #3268 from natecook1000/nc-scalarindex-nocore
[stdlib] Remove _StringCore from UnicodeScalarIndex
2016-07-07 17:41:36 -07:00
practicalswift
1c04dd113f Merge pull request #3384 from practicalswift/typo-fixes-20160707
[gardening] Fix recently introduced typos.
2016-07-07 19:22:38 +02:00
Tony Parker
443bb590f5 Add a workaround for MeasurementFormatter so it can use Measurement
Due to current language limitations (26607639), MeasurementFormatter's
stringFromMeasurement: is esentially useless when imported into Swift.
This workaround allows it to work as expected.

<rdar://problem/27173952> Workaround: MeasurementFormatter.string(from:
Measurement<Unit>) doesn't recognize subclasses of Unit
2016-07-07 09:57:54 -07:00
practicalswift
9a8bbe0014 [gardening] Fix recently introduced typos. 2016-07-07 13:14:25 +02:00
Tony Parker
b5db69ff24 Add a fix-it for bytes/mutableBytes, to help migrate from NSData to
struct Data.

<rdar://problem/26246299> Missing fixit for Data.bytes
2016-07-06 16:45:46 -07:00
Tony Parker
29baf4818d Add RangeReplaceableCollection conformance to struct Data.
This also addresses a TODO in the code, now that we can access the base
of a slice.
2016-07-06 16:05:25 -07:00
Max Moiseev
61b7a72d00 Fixing the Intents overlay 2016-07-06 15:14:52 -07:00
Mishal Shah
65a44b581a Update Foundation URL to use new name urlForResource -> url 2016-07-06 13:44:54 -07:00
Mishal Shah
23b646eed2 Update master to build with Xcode 8 beta 2, OS X 10.12, iOS 10, tvOS 10, and watchOS 3 SDKs 2016-07-06 10:48:45 -07:00
Doug Gregor
71882c6516 [API Notes] Use API notes rather than overlays to make error enums bridge.
The Clang attribute allows one to state that a particular enumeration
type describes an error, and associates it with a particular domain
constant. However, due to lack of API notes support, this attribute
wasn't actually getting used. Instead, we had a number of explicit
extensions to enum types to make them conform to the _BridgedNSError
protocol explicitly.

Now that we have API notes, use them to make these enums into error
enums with the appropriate domain, so that the Clang importer will
synthesize the _BridgedNSError conformances. Then, remove all of the
explicit conformances---and with them, the overlays for 12 frameworks.

There is a small fix to more eagerly consider these conformances as
"used" if an expression is formed with the error enum as a value
type. This better ensures that the conformances will be available at
runtime when needed.

This cleanup is needed to implement SE-0112 (NSError bridging),
although it is useful by itself.
2016-07-06 09:54:59 -07:00
Philippe Hausler
24ff368d4f [Foundation] Swift3 API naming feedback
Addresses the following issues:

rdar://problem/25992816 -[NSUserDefaults registerDefaults] is being imported as NSUserDefaults.register(), which is confusing
rdar://problem/26291437 UserDefaults has 'setURL(forKey:)' instead of 'set(_:forKey:)'
rdar://problem/26375229 FileManager overlay has old naming
rdar://problem/26090891 NSBundle methods that are overridden in the apinotes incorrectly handle the first argument pattern
rdar://problem/26271340 struct URL initializer for fileURLWithFileSystemRepresentation is incorrectly named'
rdar://problem/26443640 XMLDTDNode.Kind conflicts with XMLNode.Kind and should be renamed to XMLDTDNode.DTDKind
rdar://problem/26500390 registerUndoWithTarget in overlay not updated for new API names
rdar://problem/26653451 NSCoder encodeDataObject is misleading
rdar://problem/26653653 NSCoder decodeObjectOfClass is redundant
rdar://problem/26653694 NSCoder.decodeTopLevelObjectForKey does not follow naming guidelines
rdar://problem/26656299 SocketNativeHandle should be a hoisted type to SocketPort
https://bugs.swift.org/browse/SR-1903
2016-07-05 11:19:12 -07:00
Philippe Hausler
0db73cb80c Revert "[Foundation] Workaround for importer NS_REFINED_FOR_SWIFT failure in development environments"
This reverts commit 1bfd433d3e.
2016-07-05 11:19:12 -07:00
Nate Cook
2d75c12c2d [stdlib] Remove _StringCore reference from UnicodeScalarIndex
This removes the `_core` property from UnicodeScalarView.Index
and moves any remaining index-moving logic from the index to
the view in UnicodeScalarView and CharacterView.
2016-07-02 23:16:22 -05:00
Chris Lattner
45f2cfaaa0 Implement SE-0099, but where the migration diagnostics are left as warnings
for now.  I'll upgrade them to errors in a week or two to give downstream
projects a chance to update.
2016-07-02 15:44:57 -07:00
practicalswift
5d1af107a3 [gardening] Use "{let,var} c: C" instead of "{let,var} c : C"
Inspired by @gribozavr:s fix in 1ad666742e
2016-07-01 23:51:32 +02:00
Brian Gesiak
f12a1323ce [SR-1738] Allow *only* static libraries to be built
This splits the `--build-swift-stdlib` and `--build-swift-sdk-overlay`
arguments into `dynamic` and `static` variants, which makes the
following build command possible:

```
utils/build-script -- \
  --build-swift-dynamic-stdlib=0 --build-swift-dynamic-sdk-overlay=0 \
  --build-swift-static-stdlib=1 --build-swift-static-sdk-overlay=0
```

This command produces *only* static libraries for the stdlib, and no
SDK overlay libraries at all. Many other finely-grained build options
are now possible.
2016-06-24 09:18:24 -07:00
Jordan Rose
47a247c41b [SDK] Backwards-deployment support for Core Data's generics. (#3154)
rdar://problem/26825103
2016-06-23 12:47:22 -07:00
practicalswift
e78e7e4c3c [gardening] Fix recently introduced typos. 2016-06-23 16:42:48 +02:00
Philippe Hausler
c1ab18e3e7 [gardening] add .self to recent changes for struct Data 2016-06-22 13:11:11 -07:00
Tony Parker
7c0910a2ec Address review feedback 2016-06-22 09:55:59 -07:00
swift-ci
bd2091fd85 Merge pull request #3098 from austinzheng/az-gardening 2016-06-21 11:03:27 -07:00
Tony Parker
11e85d73a4 Add a new set of initializers to Data to aid efficiency and clarity when wrapping NSData.
addresses:
rdar://problem/26385078 Data() really needs a init(length:) and replaceBytes(in:withBytes:)
rdar://problem/26508250 Add more specific init method to Data to indicate keeping a ref type
2016-06-21 10:42:31 -07:00
Philippe Hausler
1bfd433d3e [Foundation] Workaround for importer NS_REFINED_FOR_SWIFT failure in development environments
This is just a work-around for the underlying importer failure tracked by <rdar://problem/26921178>
2016-06-21 10:28:18 -07:00
Austin Zheng
6d385b80ed [gardening] Adding .self suffixes to suppress warnings 2016-06-20 21:46:13 -07:00
Dave Abrahams
26e62ed917 Add missing instances of .self
Passing a type as a metatype directly is no longer supported
2016-06-20 17:11:48 -07:00
Philippe Hausler
2a3787ed08 [Foundation] Fetching userInfo from notifications can cause leaks
<rdar://problem/26882026>
2016-06-20 15:51:28 -07:00
Tony Parker
9da8decff8 Merge pull request #3031 from discorev/patch-1
Correct Foundation Data initialiser to use Base64DecodingOptions
2016-06-20 15:37:30 -07:00
Philippe Hausler
07f0049e75 [Foundation] Override mutable copying for CharacterSet
Some mutation cases will cause the underlying copy on write cases to crash with a  _SwiftNSCharacterSet doesn't respond to -mutableCopyWithZone: failure.
Fixes Bugs:
https://bugs.swift.org/browse/SR-1782
<rdar://problem/26608216>
2016-06-20 08:02:08 -07:00
swift-ci
d68c6dcd6b Merge pull request #3069 from practicalswift/typo-fixes-20160619 2016-06-19 16:02:06 -07:00
practicalswift
4ae4e37b14 [gardening] Fix some spacing inconsistencies. 2016-06-19 21:38:59 +02:00
practicalswift
8d03ea1347 [gardening] Fix some recently introduced typos. 2016-06-19 21:28:36 +02:00
Dmitri Gribenko
5dd3ce9195 Merge pull request #3020 from modocache/sr-1738-add-swift-library-shared-static-args
[SR-1738] add_swift_library takes SHARED/STATIC arg
2016-06-18 15:38:57 -07:00
Brian Gesiak
328de9e280 [SR-1738] add_swift_library takes SHARED/STATIC arg
As a first step to allowing the build script to build *only*
static library versions of the stdlib, change `add_swift_library`
such that callers must pass in `SHARED`, `STATIC`, or `OBJECT_LIBRARY`.

Ideally, only these flags would be used to determine whether to
build shared, static, or object libraries, but that is not currently
the case -- `add_swift_library` also checks whether the library
`IS_STDLIB` before performing certain additional actions. This will be
cleaned up in a future commit.
2016-06-16 13:15:58 -04:00
Ollie Hayman
bf92f0c983 Corrected initialiser to use Base64DecodingOptions
Initialising with a base64 encoded string was using Base64EncodingOptions rather than Base64DecodingOptions - this means strings with unknown characters cannot be decoded properly as the .ignoreUnknownCharacters option is unavailable
2016-06-15 23:00:03 +01:00
practicalswift
b43a26f3ff [gardening] Remove invisible ^P 2016-06-15 22:54:11 +02:00
practicalswift
64b3c6c880 [gardening] Remove invisible ^H 2016-06-15 22:54:11 +02:00
practicalswift
223d8d63f7 [gardening] Use "\"" instead of "“" or "”". 2016-06-15 22:54:11 +02:00
practicalswift
dcab7e726f [gardening] Use "*" instead of "•" 2016-06-15 22:44:23 +02:00
practicalswift
cc47c70019 [gardening] Use "'" instead of "’". 2016-06-15 22:43:25 +02:00
Doug Gregor
eadc7aa727 Merge two SWIFT_MODULE_DEPENDS_OSX into one
This re-establishes MultipeerConnectivity -> AppKit dependency.
2016-06-14 18:11:56 -07:00
Mishal Shah
87b7bcfd3e Update master to build with Xcode 8 beta 1, OS X 10.12, iOS 10, tvOS 10, and watchOS 3 SDKs. 2016-06-14 14:53:55 -07:00