Commit Graph

1419 Commits

Author SHA1 Message Date
Morten Bek Ditlevsen
a5a68ca25d Fix negation of 0 length Decimal (#15986)
A Decimal value with _length 0 and _isNegative set to 1 is interpreted as a NaN. The 'negate()' function however, flipped the _isNegative flag without regard for the _length 0 case. This meant that -0 would become NaN. The fix checks for the _length 0 special case. In NSDecimalSubtract() the same check was performed. Since this now happens in negate(), it is removed from the NSDecimalSubtract() function.
2018-04-18 10:18:34 -07:00
Philippe Hausler
57d0ea8013 [Foundation] Guard Data access to NSData._isCompact under availability guards 2018-04-12 09:53:34 -07:00
Devin Coughlin
302d82731a [Foundation] Address exclusivity violation in Data
Address an exclusivity violation in Data's Iterator.next() by changing two private
'let' stored properties to be 'var'.

Making the properties 'var' changes code generation of next() so that the stored
properties are read independently of the other contents of the struct. This
prevents an exclusivity violation when reading '_endIdx' and '_data' while
simultaneously mutating '_buffer' with the call to withUnsafeMutablePointer().

The 'let' pattern is an idiom we would eventually like to support (see SR-7396),
but for now we need to remove the exclusivity violation.
2018-04-09 16:18:17 -07:00
Sho Ikeda
9efd347100 [gardening][Overlay] Use isEmpty in Data.swift 2018-04-05 17:50:20 +09:00
Sho Ikeda
68e76535bc [gardening][Calendar] No need to discard the retrun value of insert(_:) which is discardable 2018-04-04 19:29:42 +09:00
Xi Ge
d93e0dfa01 Merge pull request #15636 from Fidetro/master
Fixed JSONEncoder code style issues
2018-04-01 08:39:04 -07:00
swift-ci
6c42bcccbd Merge pull request #15507 from devincoughlin/foundation-datecomponents-exclusivity-warnings 2018-03-31 10:47:38 -07:00
swift-ci
ee57586822 Merge pull request #15652 from brennanMKE/semicolon 2018-03-31 08:19:28 -07:00
brennanMKE
fb2f55f558 [stdlib] remove trailing semicolon in stdlib source 2018-03-30 22:44:05 -07:00
Slava Pestov
e1f50b2d36 SE-0193: Rename @_inlineable to @inlinable, @_versioned to @usableFromInline 2018-03-30 21:55:30 -07:00
fidetro
2bf6b88585 Fixed code style issues 2018-03-31 05:00:46 +08:00
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
Devin Coughlin
524f273d99 [Foundation] Fix exclusivity warnings in DateComponents
DateComponents has a number of exclusivity warnings that all result from the same idiom
for applying mutation in computed properties:

    public var era: Int? {
        get { return _handle.map { _getter($0.era) } }
        set { _applyMutation { $0.era = _setter(newValue) } }
    }

Here _applyMutation() is a mutating method, so it requires exclusive access to 'self'
for the duration of the call. However, calling the _setter() method in the block
requires access to read 'self', which conflicts with the already in-progress modifying
access begun by _applyMutation().

A fix is to change _setter() to be a static function, so it doesn't require access to
'self'.
2018-03-25 19:47:50 -07: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