Commit Graph

376 Commits

Author SHA1 Message Date
Nate Cook
58933d88c5 [stdlib] Rename index(...) methods to firstIndex(...)
A la SE-204.
2018-04-21 18:07:25 -05:00
Slava Pestov
2e5aef9c8d stdlib: Remove redundant @usableFromInline attributes 2018-04-06 00:02:30 -07:00
Slava Pestov
e1f50b2d36 SE-0193: Rename @_inlineable to @inlinable, @_versioned to @usableFromInline 2018-03-30 21:55:30 -07:00
Antoine Cœur
3362b23f2a typo 2018-03-14 12:07:19 +08:00
Paul Hudson
45b25b9b85 [Gardening] Changed lowercaseString to lowercased() in comments. 2018-03-13 09:55:33 -05:00
Nate Cook
642cbbad7c [stdlib] Documentation revisions and expansions
- Adding docs for unbounded ranges
- Filling in missing docs for range-expression subscripts
- Equality operators for arrays
- Fix issues with range discussions
- Fill in missing integer docs
2018-02-19 11:49:58 -06:00
Ben Cohen
c1d4b60281 [stdlib] Collection compatibility shim fixes (#14342)
* Fix compatibility shims for IndexDistance

* Add a second test for implied IndexDistance, Bidirectional conformance
2018-02-01 19:47:11 -08:00
Max Moiseev
f764ff33db Fix an @available attribute 2018-01-03 16:15:23 -08:00
Ben Cohen
c7e05cb21e [stdlib][Gardening] Delete few rogue IndexDistance numericCasts that slipped through (#13684) 2018-01-03 15:53:28 -08:00
Erik Eckstein
5d1827b5ba Remove a wrong assert in the specializer.
In case of partial specialization, the replacement type of a substitution can be generic.
I couldn't find a small unit test for this bug fix. But it is tested by compiling the stdlib with the change in Collection.swift.

rdar://problem/36033852
2017-12-14 15:28:07 -08:00
Graydon Hoare
62a6b74ad1 Revert "[stdlib] Conditional conformances for Lazy[Filter|Map]Collection" 2017-12-10 12:48:36 -08:00
Max Moiseev
e4f94a318f [stdlib] Improve default implementation of Collection.distance(from:to:)
(cherry picked from commit 72948cae9a)
2017-12-08 13:07:07 -08:00
Ben Cohen
4ddac3fbbd [stdlib] Eradicate IndexDistance associated type (#12641)
* Eradicate IndexDistance associated type, replacing with Int everywhere

* Consistently use Int for ExistentialCollection’s IndexDistance type.

* Fix test for IndexDistance removal

* Remove a handful of no-longer-needed explicit types

* Add compatibility shims for non-Int index distances

* Test compatibility shim

* Move IndexDistance typealias into the Collection protocol
2017-12-08 12:00:23 -08:00
Max Moiseev
3bace08f9a Revert "[stdlib] Improve default implementation of Collection.distance(from:to:)"
This reverts commit 72948cae9a.
2017-12-07 14:28:19 -08:00
Max Moiseev
72948cae9a [stdlib] Improve default implementation of Collection.distance(from:to:) 2017-12-06 18:19:34 -08:00
Ben Cohen
c4f0b5fe94 [stdlib] Adopt conditional conformance for Indices, Slice, ReversedCollection (#12913)
* Refactor Indices and Slice to use conditional conformance

* Replace ReversedRandomAccessCollection with a conditional extension

* Refactor some types into struct+extensions

* Revise Slice documentation

* Fix test cases for adoption of conditional conformances.

* [RangeReplaceableCollection] Eliminate unnecessary slicing subscript operator.

* Add -enable-experimental-conditional-conformances to test.

* Gruesome workaround for crasher in MutableSlice tests
2017-11-30 09:10:22 -08:00
Nate Cook
0648aad14f [stdlib] Constrain SubSequence.IndexDistance == IndexDistance 2017-10-09 01:59:44 -05:00
Doug Gregor
797df6e8d7 Eliminate the _*Indexable protocols.
The various _*Indexable protocols only exist to work around the lack of
recursive protocol constraints. Eliminate all of the *_Indexable protocols,
collapsing their requirements into the corresponding Collection protocol
(e.g., _MutableIndexable —> Collection).

This introduces a number of extraneous requirements into the various
Collection protocols to work around bugs in associated type
inference. Specifically, to work around the lack of "global" inference
of associated type witnesses. These hacks were implicitly present in
the *Indexable protocols; I've made marked them as ABI FIXMEs here so
we can remove them when associated type inference improves.

Fixes rdar://problem/21935030 and a number of ABI FIXMEs in the library.
2017-10-01 15:08:23 -07:00
Doug Gregor
9d2c9be04e Remove already-completed or separate-discussed ABI FIXMEs. 2017-10-01 15:08:22 -07:00
Doug Gregor
af48bdc539 Use Collection protocols in IndexingIterator and Default*Indices constraints.
Eliminates a few explicit uses of the Indexable protocols.
2017-10-01 15:08:22 -07:00
Doug Gregor
52eb618abc [Collections] Constrain Indices type to Collection.
Make the Indices types conform to the appropriate Collection protocol:
* Collection.Indices: Collection
* BidirectionalCollection.Indices: BidirectionalCollection
* RandomAccessCollection.Indices: RandomAccessCollection
2017-10-01 15:08:22 -07:00
Doug Gregor
6b51806b54 [SE-0157] Make *Collection.SubSequence conform to corresponding *Collection.
Introduce (recursive) constraints that make the *Collection constraint
of SubSequence match that of its enclosing *Collection, e.g.,
MutableCollection.SubSequence conforms to MutableCollection.

Fixes rdar://problem/20715031 and more of SR-3453.
2017-10-01 15:08:22 -07:00
Doug Gregor
e5f893bc59 [Sequence] Make Sequence.SubSequence conform to Sequence.
Addressed ABI FIXME’s #4, #5, #104 and #105, making Sequence’s
SubSequence conform to Sequence, with the same element type, and for
which the SubSequence of a SubSequence is the same SubSequence.

Fixes SR-318 / rdar://problem/31418206.
2017-10-01 15:08:22 -07:00
Max Moiseev
53b8419279 [stdlib] Make all the stdlib APIs @_inlineable
This change in theory should allow us to remove a special stdlib-only
sil-serialize-all compilation mode.

<rdar://problem/34138683>
2017-09-29 11:26:56 -07:00
Doug Gregor
0793f6c8c5 Revert "[Sequence] Make Sequence.SubSequence conform to Sequence."
This reverts commit 7dc8737c9c.
2017-09-14 09:12:56 -07:00
Doug Gregor
7dc8737c9c [Sequence] Make Sequence.SubSequence conform to Sequence.
Addressed ABI FIXME’s #4, #5, #104 and #105, making Sequence’s
SubSequence conform to Sequence, with the same element type, and for
which the SubSequence of a SubSequence is the same SubSequence.

Fixes SR-318 / rdar://problem/31418206.
2017-09-12 06:52:01 -07:00
Maxim Moiseev
6c7d93491f Merge pull request #11627 from moiseev/swift-2-artifacts
[stdlib] Remove the Grand Renaming artifacts of Swift 3 era
2017-09-05 11:41:18 -07:00
Max Moiseev
1e51177fec Add back the Generator typealias in the name of source stability 2017-08-29 14:22:21 -07:00
Kuba (Brecka) Mracek
d03a575279 Unify the capitalization across all user-visible error messages (#11599)
* Unify the capitalization across all user-visible error messages (fatal errors, assertion failures, precondition failures) produced by the runtime, standard library and the compiler.

* Update some more tests to the new expectations.
2017-08-29 12:16:04 -07:00
Maxim Moiseev
ee5fb33656 [stdlib] Remove the Grand Renaming artifacts of Swift 3 era 2017-08-28 15:54:11 -07:00
Nate Cook
781f6326bd [stdlib] Various documentation revisions and fixes
- Revisions to unsafeDowncast and withVaList
- Fix the Int64/UInt64 discussion
- Buffer pointer revisions
- Fix Optional example to use new integer methods
- Revise and correct some UnsafeRawBufferPointer docs
- Fix symmetricDifference examples
- Fix wording in FloatingPoint.nextDown
- Update ImplicitlyUnwrappedOptional
- Clarify elementsEqual
- Minor integer doc fixes
- Comment for _AppendKeyPath
- Clarification re collection indices
- Revise RangeExpression.relative(to:)
- Codable revisions
2017-07-31 10:56:53 -05:00
Nate Cook
825e9d077d [stdlib] More documentation revisions / consistency fixes. 2017-06-13 14:08:00 -05:00
Nate Cook
b7af9bfe83 [stdlib] Remove SeeAlso tags 2017-06-13 11:23:51 -05:00
Nate Cook
0a7780c213 [stdlib] Various minor documentation revisions 2017-06-12 16:20:11 -05:00
Dave Abrahams
72f5e7c0c2 [stdlib] Eliminate _Element 2017-05-22 16:17:58 -07:00
ben-cohen
efd4edf486 Restore @inline(__always) on Collection.first 2017-05-14 14:59:48 -07:00
Ben Cohen
ea2f64cad2 [stdlib] Add Sequence.Element, change ExpressibleByArrayLiteral.Element to ArrayLiteralElement (#8990)
* Give Sequence a top-level Element, constrain Iterator to match

* Remove many instances of Iterator.

* Fixed various hard-coded tests

* XFAIL a few tests that need further investigation

* Change assoc type for arrayLiteralConvertible

* Mop up remaining "better expressed as a where clause" warnings

* Fix UnicodeDecoders prototype test

* Fix UIntBuffer

* Fix hard-coded Element identifier in CSDiag

* Fix up more tests

* Account for flatMap changes
2017-05-14 06:33:25 -07:00
Nate Cook
dafe368220 Address @dabrahams’s feedback 2017-05-13 12:25:42 -05:00
Nate Cook
f650e0a7da [stdlib] String and range expressions
* finish string documentation revisions
* revise examples throughout to use range expressions instead of e.g.
  prefix(upTo: _)
2017-05-13 10:06:12 -05:00
Nate Cook
1b8d982f98 [stdlib] Miscellaneous documentation revisions
* documented swap(_:_:) and MutableCollection.swapAt(_:_:)
* clarifications and fixes elsewhere
2017-05-13 10:06:09 -05:00
Nate Cook
7fa74f590d [stdlib] Documentation revisions for string + ranges
* removing .characters from examples
* beginning new String doc revisions
* improvements to the String Foundation overlay docs
* minor revisions elsewhere
2017-05-13 10:06:05 -05:00
Ben Cohen
d95704128d revert changes to stdlib 2017-05-11 12:05:47 -07:00
Ben Cohen
c03b14e93f Revert "Merge pull request #9379 from airspeedswift/redundant-where"
95e9681d10
2017-05-11 11:43:54 -07:00
ben-cohen
e4af80d39c Remove redudant constraints to supress warnings 2017-05-07 11:30:01 -07:00
Ben Cohen
f6f3ed0fe7 Add Collection constraints via protocol where clauses (#9374) 2017-05-07 08:55:48 -07:00
Dave Abrahams
fe38ab1579 [stdlib] Inline var first default implementation 2017-05-02 18:36:04 -07:00
Dave Abrahams
2226cbacc0 [stdlib] Inline all of IndexingIterator 2017-05-02 16:54:27 -07:00
Dave Abrahams
5ad4ef4508 [stdlib] UnicodeDecoders: bidirectional UnicodeScalar view
Reverse iteration over a collection is significantly slower than forward.

REVERSE_COLLECTION

user	0m4.609s
user	0m4.587s
user	0m4.585s

COLLECTION

user	0m3.423s
user	0m3.517s
user	0m3.492s
2017-04-27 14:00:18 -07:00
Doug Gregor
13f6c79b2a [Stdlib] For Collections, the SubSequence of a Subsequence is SubSequence.
Part of ABI FIXME #99, this gives us some nice consistency that
ensures that slicing a SubSequence gives us another SubSequence. There
are two source-compatibility implications to this change:

* Collections now need to satisfy this property, which could not be
  expressed in Swift 3. There might be some Collections that don't
  satisfy this property, and will break with the Swift 4 compiler
  *even in Swift 3 compatibility mode*. Case in point...
* The Lazy collection types were formulated as a lazy collection of
  the base slice (e.g., LazyCollection<ArraySlice<T>>) rather than as
  a slice of the lazy collection (e.g.,
  Slice<LazyCollection<Array<T>>). The former doesn't meet the new
  requirements, so change to the latter.
2017-04-20 13:18:32 -07:00
Doug Gregor
29a15ce402 [Stdlib] Apply SE-0142 to fix ABI FIXME #92, part of ABI FIXME #99. 2017-04-19 23:15:33 -07:00