Commit Graph

5263 Commits

Author SHA1 Message Date
Michael Ilseman
42b8f18634 [TLS] Add a uText to our TLS
ICU's uText APIs offer a cross-encoding means of interacting with
grapheme breaking. Storing one on our TLS allows us to explore mised
encodings, and even for UTF-16 might be profitable if setText
mallocs/frees an internal uText (which seems to be the case). This
isn't hooked up to anything yet, but its highly likely we will be
using it soon and adding it now enables more rapid development of the
UTF-8 prototype, due to it's tie-in with the runtime.
2018-09-21 10:23:12 -07:00
Mike Ash
317451c8ee [Runtime][Stdlib][Overlays] Add comments to all the renamed classes explaining the rename and noting that the old name cannot be used due to conflicts.
rdar://problem/35768222
2018-09-20 12:07:30 -04:00
Joe Groff
7d78b09794 Merge pull request #19382 from jckarter/identity-key-path-syntax
Implement the final approved syntax for SE-227 identity key paths.
2018-09-20 08:03:42 -07:00
Ben Cohen
7cee5d18ba Give StringProtocol.SubSequence a default of Substring to supress warning 2018-09-19 20:44:17 -07:00
Ben Cohen
412a045f71 [stdlib] JAFIA (#19074)
* Lazy/generic types needing specialization

* Move DictionaryLiteral typealias to compatibility shims file

* Static String is mainly transparent so needs no inlining

* UnboundedRange hack doesn't need inlining

* Unmanaged needs unsafe performance

* Onone enum namespace

* Output stream specialize-never and calls to lock/unlock don't need inlining

* no need for @_frozen on internal enum

* DropWhile needs lazy-performance
2018-09-19 19:41:06 -07:00
Max Moiseev
9bff6e411f Merge pull request #19310 from moiseev/int-transparent
[WIP][stdlib] Audit @_transparent/@inlinable in Integers.swift
2018-09-19 14:22:09 -07:00
Joe Groff
93b5de61e7 Implement the final approved syntax for SE-227 identity key paths.
`\.self` is the final chosen syntax. Implement support for this syntax, and remove the stopgap builtin and `WritableKeyPath._identity` property that were in place before.
2018-09-19 11:45:13 -07:00
Jordan Rose
c78045e672 Merge pull request #19332 from jrose-apple/usability-testing
Enforce that a fixed-contents struct has usable-from-inline fields
2018-09-18 15:01:31 -07:00
Jordan Rose
55eaa7ffcf [stdlib] Add some missing '@usableFromInline's
Caught by the rule I'm about to add in the next commit: a fixed-layout
struct must only contain public/@usableFromInline members.
2018-09-17 17:18:30 -07:00
Michael Ilseman
0e17e76ebd Merge pull request #19209 from benrimmington/emoji_gate_2
[SE-0211] Emoji properties require ICU 57 or later
2018-09-15 08:49:19 -07:00
Mike Ash
f4818ea81e Merge pull request #19289 from mikeash/thread-local-storage-dedicated-keys
[Runtime][Stdlib] Use dedicated thread-local storage keys when possible.
2018-09-14 10:45:04 -04:00
Maxim Moiseev
224098b12d [stdlib] Audit @_transparent/@inlinable in Integers.swift 2018-09-13 17:20:20 -07:00
Mike Ash
798edb9d0e [Runtime][Stdlib][Overlays] Rename various Objective-C classes and methods that would conflict when loading old Swift libraries into a process alongside ABI-stable libraries.
rdar://problem/35768222
2018-09-13 16:55:10 -04:00
Mike Ash
29ff3de4ab [Runtime][Stdlib] Use dedicated thread-local storage keys when possible.
rdar://problem/32275323 rdar://problem/44104305
2018-09-13 14:36:57 -04:00
Soroush Khanlou
5736cacc9a Add count(where:) and tests (#16099)
* add count(where:) and tests

* Revise count(where:) documentation

* Remove errant word in abstract

* add a benchmark for ranges and strings with help from @natecook1000

* update benchmark to use Array instead of Range
2018-09-13 12:37:06 -05:00
Ben Rimmington
cec9faf1c0 [SE-0211] Emoji properties require ICU 57 or later 2018-09-13 18:18:33 +01:00
Ben Cohen
d414ece556 Switch ManagedBuffer.header to use _modify (#19226) 2018-09-11 17:40:43 -07:00
Ben Cohen
2292df33a2 Swiftch Dictionary.subscript(_:default:) to use _modify (#19218) 2018-09-11 14:25:46 -07:00
Ben Cohen
d86d972d47 Switch Dictionary.Values.subscript to use _modify (#19222) 2018-09-11 14:07:45 -07:00
swift-ci
cc329fee03 Merge pull request #19141 from aschwaighofer/remove_constant_string_literal 2018-09-10 15:51:47 -07:00
swift-ci
77d25d8bd6 Merge pull request #18974 from lorentey/dictionary-generalized-accessors 2018-09-10 09:26:19 -07:00
Ben Cohen
b4a23adcf0 [stdlib] Update Array.subscript to use _modify (#19154)
* Switch Array to use subscript _modify

* Add _modify to ContiguousArray

* XFAIL linux failing test
2018-09-07 10:36:58 -07:00
Saleem Abdulrasool
434de94a96 Merge pull request #19155 from compnerd/nilNativeObject
stdlib: remove unused variable `_nilNativeObject` (NFC)
2018-09-06 10:43:31 -07:00
Doug Gregor
7bc7b1e22e [Standard library] Downgrade non-ABI ABI FIXMEs to FIXMEs.
Now that we have removed overriding protocol requirements from witness
tables, they no longer have any effect on the ABI. Replace the FIXME
(ABI) comments with normal FIXMEs: there is no more ABI work to do
here.
2018-09-05 22:01:06 -07:00
Doug Gregor
cffe3869a6 Merge pull request #19034 from DougGregor/protocol-override
Introduce overrides of protocol members and drop them from witness tables
2018-09-05 20:57:21 -07:00
Saleem Abdulrasool
82ef1abe59 stdlib: remove unused variable _nilNativeObject (NFC) 2018-09-05 18:31:38 -07:00
Jordan Rose
5dace224a0 Merge pull request #18623 from dingobye/sr8453
[Sema] Warn for redundant access-level modifiers on setters or used in an extension.
2018-09-05 17:44:26 -07:00
Doug Gregor
0a8058ca6a [Integer protocols] Make BinaryInteger.Words conform to RandomAccessCollection.
Require that BinaryInteger.Words conform to RandomAccessCollection with
an Index type of Int, simplifying clients.

Fixes rdar://problem/36410936.
2018-09-05 16:22:27 -07:00
Doug Gregor
f8e53d9129 [Standard library] Audit protocol member overrides in protocols.
Add the `-warn-implicit-overrides` flag when building the standard library
and overlays, so that each protocol member that overrides a member of an
inherited protocol will produce a warning unless annotated with either
‘override’ or ‘@_nonoverride’.

An annotation of `override` will mean that the overriding requirement will be treated identically to the overridden declaration. If for some reason a concrete type’s conformance to the inheriting protocol provides a different witness for the overriding requirement than the conformance to the inherited protocol’s witness for the overridden requirement, the witness for the inheriting (more-specialized) protocol will be ignored. A protocol requirement marked ‘override’ only makes sense when the declaration is needed to help associated type inference, which is why the ‘override’ annotations correlate so closely with ABI FIXMEs.

An annotation of `@_nonoverride` means that the two protocol requirements will be treated independently, and may be bound to different witnesses. Use `@_nonoverride` when we might need different witnesses, e.g., because the semantics of the potentially-overriding declaration differ from that of the potentially-overridden declaration. `BidirectionalCollection.index(_:offsetBy:)` is the most obvious example, because the `BidirectionalCollection` ’s version of `index(_:offsetBy:)` allows negative indices. `RandomAccessCollection` ’s version is also marked `@_nonoverride` because it is required to be asymptotically faster than the `Collection` or `BidirectionalCollection` versions.
2018-09-05 13:51:26 -07:00
Arnold Schwaighofer
73df12c09f Remove dead constant_string_literal
constant_string_literal was added to support a one word representation
of String that never materialized.
2018-09-05 12:13:57 -07:00
Stephen Canon
190c7d6b9f Default implementation of isMultiple(of:) on BinaryInteger
In order to provide source compatibility with existing user types conforming to BinaryInteger, we want to have a default implementation available. It's somewhat difficult to provide a good default implementation that correctly handles arbitrary non-symmetrical ranges in the face of negative divisors, so fall back on testing divisibility of the magnitudes, which avoids the problem.

On the plus side, this default implementation works fine for types conforming to UnsignedInteger, which lets us move the FixedWidthInteger implementation down to FixedWidthInteger & SignedInteger, and simplify it in the process.
2018-09-04 16:32:14 -04:00
Kirill Chibisov
aa34eb24d1 [stdlib][fix] Fixed wrong sorting behavior (#19107)
* [stdlib] Fixed wrong sorting behavior

* [stdlib] Refactored siftDown.

* [stdlib][test] Added tests for heapSort.
2018-09-04 10:44:16 -07:00
swift-ci
161819b31c Merge pull request #18634 from natecook1000/nc-random-highlevel-notes 2018-09-04 08:14:43 -07:00
Stephen Canon
c1f25e0673 [SE-0225] Implementation of isMultiple for BinaryInteger. (#18689)
* Implement SE-0225 (BinaryInteger.isMultiple(of:))

A default implementation is provided for FixedWidthInteger, with very basic test coverage included.
2018-09-04 10:31:05 -04:00
Nate Cook
908ac9f43b Revise note about future random algorithm changes 2018-09-03 22:16:23 -05:00
Nate Cook
8174511a3f Add notes about future changes to high-level random algorithms 2018-09-03 22:16:23 -05:00
Maxim Moiseev
91143a2630 [NFC][stdlib] Unify usage of argument labels in operators 2018-08-31 13:03:18 -07:00
Max Moiseev
b4e7cc81ef Merge pull request #19036 from moiseev/ungyb-int
[stdlib] Partially ungyb Integers
2018-08-31 10:14:27 -07:00
Max Moiseev
e8b6091755 [stdlib] Deprecate Collection.index(of:) and index(where:) (#19071)
This should have been done for Swift 4.2 according to SE-0204, but
better later than never. Deprecating these methods as of Swift 5.0.

Also modfying the tests to check for the deprecation message.

Fixes: <rdar://problem/43694210>
2018-08-30 19:32:27 -07:00
Maxim Moiseev
dca1ad87af [stdlib] Partially ungyb Integers
The new file straucture is similar to that of floating point types,
where protocols live in one file, and concrete types – in another.
2018-08-29 13:46:10 -07:00
Doug Gregor
ecf752d54b Revert "Revert " [Foundation] Collapse (SignedInteger|UnsignedInteger) reqts into FixedWidthInteger"" 2018-08-29 13:18:44 -07:00
Mike Ash
8a9065a369 Revert " [Foundation] Collapse (SignedInteger|UnsignedInteger) reqts into FixedWidthInteger" 2018-08-29 13:55:20 -04:00
Doug Gregor
4b625a3dda Merge pull request #19006 from DougGregor/error-bridging-integer-type
[Foundation] Collapse (SignedInteger|UnsignedInteger) reqts into FixedWidthInteger
2018-08-29 08:37:02 -07:00
Ben Cohen
83823f5f7f [stdlib] Obsolete various compatibility shims in 5.0 (#19008)
* Obsolete ModifierSlice typealiases in 5.0

* Obsolete *Indexable in 5.0

* Obsolete IteratorOverOne/EmptyIterator in 5.0

* Obsolete lazy typealiases in 5.0

* Drop .characters from tests

* Obsolete old literal protocols in 5.0

* Obsolete Range conversion helpers in 5.0

* Obsolete IndexDistance helpers in 5.0

* Obsolete Unsafe compat helpers in 5.0

* Obsolete flatMap compatibility helper in 5.0

* Obsolete withMutableCharacters in 5.0

* Obsolete customPlaygroundQuickLook in 5.0

* Deprecate Zip2Sequence streams in 5.0

* Replace * with swift on lotsa stuff

* Back off obsoleting playground conformances for now
2018-08-28 13:20:25 -07:00
Doug Gregor
4acd723d16 [Foundation] Handle unsigned error codes without trapping.
When working with Error types with unsigned raw values, numeric-cast into
a UInt and then map the bits over to an Int so we preserve values not
representable in an Int without wrapping.

Thanks to @jrose-apple for pointing this out!
2018-08-28 10:49:01 -07:00
Doug Gregor
bd799d4b43 [Foundation] Collapse (SignedInteger|UnsignedInteger) reqts into FixedWidthInteger.
Simplify the default implementations provided for RawRepresentable
error types whose raw values are integral, replacing duplicated code
(for SignedInteger or UnsignedInteger) with a single constraint on
BinaryInteger.

Fixes rdar://problem/35230187.
2018-08-28 10:49:01 -07:00
Chéyo Jiménez
a527e53e17 Renamed DictionaryLiteral to KeyValuePairs (#16577)
* renamed DictionaryLiteral to KeyValuePairs per SE-0214

* renamed DictionaryLiteral type tests to KeyValuePairs

* [SE-0214] Move changelog entry (Swift 4.2 => 5.0)

* [SE-0214] Update comment in AST/Expr.h

* [SE-0214] Use generic typealias

See also <https://github.com/apple/swift/pull/17711>

* [SE-0214] Update source-stability.swift.expected
2018-08-27 10:51:12 -07:00
Karoy Lorentey
653b68c4be [stdlib] Fix crucial thinko 2018-08-26 13:12:51 +01:00
Ben Cohen
75018155ff Kill old set/dictionary-specific bridging entrypoints (#18930) 2018-08-25 07:27:26 -07:00
Karoy Lorentey
715ccd721d [stdlib] Implement the new _modify accessor in Dictionary.subscript
This enables in-place mutations of the key-based subscript.
These get rid of one of two full hash table lookup operations (including hashing the key) relative to the getter+setter approach. They can also eliminate COW copies in code like this:

dictionary[foo]?.append(bar)

(Admittedly this isn’t a very useful example.)
2018-08-25 02:09:33 +01:00