Commit Graph

1407 Commits

Author SHA1 Message Date
Max Moiseev
a582a7628c Remove the underscored public protocols from overlays
These protocols were introduced to work around the problem where
compiler could not correctly handle instance of multiple @available
attributes (one for the language version and another for teh OS version)
applied to the same member.

Now that the compiler issues has been fixed, it is the right time to get
rid of the workarounds.

Addresses: <rdar://problem/36556261>
2018-03-30 13:43:41 -07:00
Karoy Lorentey
e485c1506b Merge pull request #15382 from lorentey/conditional-hashable2
[SE-0143][stdlib] Conditionally conform stdlib types to Hashable
2018-03-28 21:45:02 +01:00
Sho Ikeda
1c3909e03d [Dispatch][gardening] Use Optional.map over flatMap where appropriate
The initializers used here are not optional ones, so there is no need to use `flatMap`.
2018-03-27 23:22:25 +09:00
Karoy Lorentey
18e7470ae7 [Foundation] NSArray, NSDictionary: Add custom AnyHashable representations
Now that Array and Dictionary conform to Hashable, we need to make sure that their bridged counterparts provide the same hash values when converted to AnyHashable.
2018-03-23 19:08:39 +00:00
Sho Ikeda
c076316722 [gardening][Overlay] Prefer macOS over OSX for @available 2018-03-23 13:36:59 +09:00
Stephen Canon
8e11af4012 Make the naming of underlying builtin for FP + Vector match Integer. (#15430)
* Make the underlying builtins for FP + Vector match Integer.

For stdlib integer types, these are named `_value` and `init(_ _value: Builtin.xxx)`. This patch adopts the same scheme for stdlib floating point and SDK overlay vector types, and removes a legacy init for integers that was only needed to support them. There should be no changes visible outside of the stdlib, and no functional change within the stdlib; the naming of some implementation details is simply more uniform now.
2018-03-22 16:43:20 -04:00
Jordan Rose
d150f96967 Merge pull request #14945 from jrose-apple/frozen-enums
Implementation for /most/ of SE-0192 (frozen and non-frozen enums)
2018-03-21 11:06:31 -07:00
Sho Ikeda
c133e09015 Merge pull request #15326 from ikesyo/use-isempty-over-count
[gardening][Data] Prefer `!isEmpty` over `count > 0`
2018-03-21 09:54:39 +09:00
Jordan Rose
3866535e04 [stdlib] Add '@_frozen' to overlay enums that need it
That's just ARCamera.TrackingState and DispatchTimeoutResult.
Verified with the framework owners at Apple.
2018-03-20 14:53:55 -07:00
Max Moiseev
ad43838bb4 Merge pull request #15354 from moiseev/colortable-size
[overlay] Fix the CGColorSpace.colorTable size calculation
2018-03-20 14:03:41 -07:00
Jordan Rose
f7bb041e0f Remove 'public' from a few NSError-bridging-related symbols (#14731)
We're still using most of this, but not all of it has to be public.

rdar://problem/35230025
2018-03-20 13:02:21 -07:00
Stephen Canon
d3cb915abb Updates to tgmath functions for CGFloat (#15360)
* Updates to tgmath functions for CGFloat

These changes bring CGFloat in line with the other FloatingPoint types.  Some of this stuff is now defined at the protocol level, so we can get rid of it at the concrete type level.  A couple other functions have been deprecated for all types, with protocol or tgmath replacements.
2018-03-20 11:14:57 -04:00
Itai Ferber
feae8bd0b0 Merge pull request #15335 from ikesyo/use-isempty-over-count-2
[gardening][(JSON|Plist)Encoder] Prefer `!isEmpty` over `count > 0`
2018-03-20 08:02:38 -07:00
Sho Ikeda
e0eadc26bb [gardening][Foundation] Prefer macOS over OSX for @available 2018-03-20 21:35:58 +09:00
Max Moiseev
243df7e035 [overlay] Fix the CGColorSpace.colorTable size calculation
Fixes: <rdar://problem/38150404>
2018-03-19 16:01:17 -07:00
Sho Ikeda
a63df4daa1 [gardening][(JSON|Plist)Encoder] Prefer !isEmpty over count > 0 2018-03-19 13:42:31 +09:00
Sho Ikeda
ba3a62b725 [gardening][Data] Prefer !isEmpty over count > 0 2018-03-18 00:58:57 +09:00
Sho Ikeda
70ab828d9f [gardening][Dispatch] Prefer macOS over OSX for @available 2018-03-16 13:30:01 +09:00
Jordan Rose
520d6b9b91 Make NS_TYPED_ENUMS ObjectiveCBridgeable when they wrap an object (#15270)
This allows them to be used in generic arguments for NSArray et al.
We already do this for the ones that wrap bridged values (like
NSString/String), but failed to do it for objects that /weren't/
bridged to Swift values (class instances and protocol compositions),
or for Error-which-is-special.

In addition to this being a sensible thing to do, /not/ doing this led
to IRGen getting very confused (i.e. crashing) when we imported a
Objective-C protocol that actually used an NS_TYPED_ENUM in this way.

(We actually shouldn't be using Swift's IRGen logic to emit protocol
descriptors for imported protocols at all, because it's possible we
weren't able to import all the requirements. But that's a separate
issue.)

https://bugs.swift.org/browse/SR-6844
2018-03-15 16:17:38 -07:00
Jordan Rose
74a4adc54c [stdlib] Remove ignored platform-agnostic '@available' from extensions
It looks like we exposed a bunch of Metal APIs to Swift 3 that we
didn't mean to; at this point it would be a source-breaking change to
hide them. Oops.
2018-03-14 16:37:40 -07:00
Sho Ikeda
f956609312 [gardening][Overlay] Prefer macOS over OSX for #available 2018-03-14 14:06:31 +09:00
Sho Ikeda
1fbc03005e [gardening][stdlib/public] Move operators into types 2018-03-11 12:14:56 +09:00
Slava Pestov
9aa4cd6680 os: Fix os_log() handling of '%.*P'
- When a count was part of the format string, we looked at the
  wrong character when forming the count.

- The OSLF_CMD_TYPE_DATA command type expects a pointer preceded
  by a OSLF_CMD_TYPE_COUNT command, not 'count' bytes inline.

Fixes <rdar://problem/38080623>.
2018-03-08 23:10:42 -08:00
Jordan Rose
e202e90294 Clean up _BridgedNSError and _BridgedStoredNSError (#14682)
Despite their similar names and uses, these protocols no longer share
much functionality - the former is used to take @objc enums defined in
Swift that conform to Error and expose them as NSErrors, and the
latter handles NS_ERROR_ENUM C enums, which get imported into Swift as
a wrapper around NSError. We can actually simplify them quite a bit.

- Eliminate base protocol __BridgedNSError, which no longer provides
  any implementation for _BridgedStoredNSError.

- Eliminate default implementations that match what the compiler would
  synthesize.

- Adopt recursive constraints and where-clauses on associated types
  (and update the Clang importer to handle this).

- Collapse signed and unsigned default implementations when reasonable.

- Fold _BridgedStoredNSError's _nsErrorDomain into the existing public
  requirement CustomNSError.errorDomain.

rdar://problem/35230080
2018-03-07 13:14:36 -08:00
Joe Groff
f213671327 Runtime: Handle getDescription correctly in +0 mode.
This can eventually be made more efficient by avoiding copies in all the
callees, but this is the minimal fix. Remove an unnecessary bit of
reverse-dependency on the Foundation overlay while we're here.

rdar://34222540
2018-03-05 11:48:40 -08:00
Philippe Hausler
26d4ea18b2 [Foundation] searching in slices should index relative to the slice (#14851) 2018-02-27 14:00:32 -08:00
najacque
9d80d3285b Merge pull request #14752 from zisko/master
Start building the Accelerate overlay for watchOS
2018-02-26 11:56:02 -08:00
Jordan Rose
6a1161bd93 Tweak _SwiftDispatchOverlayShims for use by swift-corelibs-libdispatch. (#6033) 2018-02-22 09:31:16 -08:00
Connor Wakamo
a2aacd73dd [stdlib] Deprecated PlaygroundQuickLook and CustomPlaygroundQuickLookable.
Deprecated the `PlaygroundQuickLook` enum and `CustomPlaygroundQuickLookable`
protocol. These are being targeted for removal in Swift 5, so we want to
unconditionally deprecate them now to encourage use of
`CustomPlaygroundDisplayConvertible` instead.

This commit includes deprecated the various `CustomPlaygroundQuickLookable`
conformances across the standard library and overlay libraries.
2018-02-21 13:38:31 -08:00
Jacob Mizraji
be098d2efd Start building the Accelerate overlay for watchOS
rdar://34450822
2018-02-20 12:06:38 -08:00
Jordan Rose
54a359731d [SDK] Remove Foundation's last use of _silgen_name (#14484)
No intended functionality change.
2018-02-08 11:42:40 -08:00
Greg Parker
4501e08cee Merge pull request #14373 from troughton/twowordpair-removal
[runtime] Remove TwoWordPair and use the Swift calling convention instead.
2018-02-02 16:27:25 -08:00
troughton
cf28ff448c Remove TwoWordPair and use SwiftCC instead. 2018-02-03 09:43:00 +13:00
Arthur Ariel Sabintsev
fe89d4d333 Fixed comment on Calendar's compare method 2018-02-02 11:20:53 -05:00
Ben Cohen
9ee856f386 [stdlib][WIP] Eliminate (Closed)CountableRange using conditional conformance (#13342)
* Make Range conditionally a Collection

* Convert ClosedRange to conditionally a collection

* De-gyb Range/ClosedRange, refactoring some methods.

* Remove use of Countable{Closed}Range from stdlib

* Remove Countable use from Foundation

* Fix test errors and warnings resulting from Range/CountableRange collapse

* fix prespecialize test for new mangling

* Update CoreAudio use of CountableRange

* Update SwiftSyntax use of CountableRange

* Restore ClosedRange.Index: Hashable conformance

* Move fixed typechecker slowness test for array-of-ranges from slow to fast, yay

* Apply Doug's patch to loosen test to just check for error
2018-02-01 20:59:28 -08:00
Karoy Lorentey
77992d37f0 Merge pull request #14033 from lorentey/rdar/35995647
[Foundation] Coalesce duplicate String keys in bridged NSDictionary and NSSet
2018-01-31 11:57:31 +00:00
Joe Groff
a7a3b17597 Replace nominal type descriptors with a hierarchy of context descriptors.
This new format more efficiently represents existing information, while
more accurately encoding important information about nested generic
contexts with same-type and layout constraints that need to be evaluated
at runtime. It's also designed with an eye to forward- and
backward-compatible expansion for ABI stability with future Swift
versions.
2018-01-29 16:19:25 -08:00
Michael Gottesman
ce0c40e40b [+0-all] Update more runtime files for +0 normal arguments.
This is NFC when --enable-guaranteed-normal-arguments isn't passed into
build-script.

rdar://34222540
2018-01-29 12:13:45 -08:00
Philippe Hausler
c734324a67 [Foundation] Address a potential leak when writing a data to a URL and the file system representation fails (#14176) 2018-01-26 13:25:55 -08:00
Mishal Shah
fdbf76e9f5 Update master to build with Xcode 9.3 beta 1 2018-01-25 16:03:11 -08:00
Michael Gottesman
18bcc1e143 [+0-args] Change SWIFT_CC(Swift) functions to use SWIFT_NS_RELEASES_ARGUMENT instead of NS_RELEASES_ARGUMENT.
rdar://34222540
2018-01-23 16:01:27 -08:00
Greg Parker
7b9224794e [runtime] Reinstate TwoWordPair hack for swiftcall returns. (#14079)
clang is miscompiling some swiftcall functions on armv7s.
Stop using swiftcall in some places until it is fixed.

Reverts c5bf2ec (#13299).

rdar://35973477
2018-01-23 01:04:01 -08:00
Karoy Lorentey
f2a96496a0 [StringGuts] Support for 32-bit platforms
Add 32-bit support to the new StringGuts.
2018-01-21 12:36:09 -08:00
Karoy Lorentey
3982875da0 Use Dictionary’s subscript setter rather than updateValue
It doesn’t matter which value we keep, and since we don’t currently check for duplicate values, there is no reason to retrieve the old value.
2018-01-20 00:58:44 +00:00
Karoy Lorentey
9e4dcd8bae [Foundation] Coalesce duplicate keys in String-keyed NSDictionary and NSSet instances
NSString has a stricter concept of equality than Swift’s String, so it is possible to construct NSDictionary/NSSet instances that contain duplicate keys according to Swift’s definition of string equality. This change improves how we handle these cases by coalescing the duplicate keys (keeping a single value).

rdar://problem/35995647
2018-01-19 22:35:59 +00:00
Ben Cohen
ca6c6b1d36 [stdlib] Cleanup DefaultIndices, delete dead code (#13952)
* Remove a bunch of Default(Bidirectional|RandomAccess)Indices usage from stdlib and test

* Remove some DefaultRandomAccessIndices and IndexDistance usage from Foundation

* Remove no-longer-used internal type in Existentials.swift

* Get rid of indicesForTraversal
2018-01-15 13:48:08 -08:00
Itai Ferber
1e110b8f63 Restore decoder state after throwing on decode
Resolve SR-6408 by restoring the JSON/PlistDecoder stack if an error
is thrown after a container was pushed during encode.
2018-01-11 12:20:01 -08:00
Itai Ferber
57e356b1c4 Restore encoder state after throwing on encode
Resolve SR-6078 by restoring the JSON/PlistEncoder stack if an error
is thrown after a container was pushed during encode.
2018-01-11 12:20:01 -08:00
Gregory Todd Williams
09ed106f25 [stdlib] Don't try to construct invalid UnicodeScalars in CharacterSet
Inserting and removing a single Unicode.Scalar in a CharacterSet must not
attempt to create a Range<Unicode.Scalar> because the upperBound value might
not always be a valid UnicodeScalar.

This fixes a regression to the fix for SR-2988.
2018-01-02 10:07:28 -08:00
Maxim Moiseev
128092a7d6 Rename filterMap to compactMap 2017-12-18 09:22:41 -08:00