Commit Graph

65 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
e1f50b2d36 SE-0193: Rename @_inlineable to @inlinable, @_versioned to @usableFromInline 2018-03-30 21:55:30 -07:00
Ben Cohen
c7e05cb21e [stdlib][Gardening] Delete few rogue IndexDistance numericCasts that slipped through (#13684) 2018-01-03 15:53:28 -08:00
Doug Gregor
a55adb2622 [Standard library] Remove extraneous associated type defaults.
These are no longer required by associated type inference.
2017-12-19 13:03:51 -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
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
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
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
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
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
Nate Cook
b7af9bfe83 [stdlib] Remove SeeAlso tags 2017-06-13 11:23:51 -05: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
Ben Cohen
d95704128d revert changes to stdlib 2017-05-11 12:05:47 -07:00
Ben Cohen
f6f3ed0fe7 Add Collection constraints via protocol where clauses (#9374) 2017-05-07 08:55:48 -07:00
Doug Gregor
d1d4238c40 [Stdlib] Remove ABI FIXMEs #94 and #96, which are consequences of other FIXMEs.
There isn't any work related to SE-0142 associated type where clauses
for these particular ABI FIXMEs. Rather, we get all of the constraints
we need from Collection and the recursive constraint we cannot yet
express, all of which are covered by other ABI FIXMEs.
2017-04-19 23:15:32 -07:00
practicalswift
8c2b87bce0 [gardening] Add correct copyright notices 2017-01-07 20:32:18 +01:00
Nate Cook
82811c57f0 [stdlib] Improvements to Collection doc comments 2016-12-19 13:05:19 -06:00
Nate Cook
3bc4909de8 [stdlib] Various revisions and fixes for documentation
- Fix wording for RandomAccessCollection
- Add note about array growth to reserveCapacity(_:)
- Reformat lazy flatMap discussions
- Improve Collection symbol consistency
2016-12-15 11:47:19 -06:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Doug Gregor
f786a9a230 [Standard library] Duplicate subscript requirement in BidirectionalCollection.
The BidirectionalCollection protocol has no requirements that mention
the associated type 'SubSequence', which means it cannot be easily
inferred. Duplicate the subscript requirement from Collection into
BidirectionalCollection to aid type witness inference.
2016-11-08 16:11:30 -08:00
Louis D'hauwe
f9cd8b129d Updated popLast() and removeLast() documentation. 2016-10-18 21:29:01 +02:00
Louis D'hauwe
520d0d2e12 Updated popLast() and removeLast() documentation. 2016-10-18 15:59:19 +02:00
Louis D'hauwe
ad827ccd51 Use code style in documentation for referred functions. 2016-10-18 00:30:42 +02:00
Louis D'hauwe
f1a2f22b17 Improved documentation for removeLast() 2016-10-18 00:21:18 +02:00
Louis D'hauwe
cdbfc4fb45 Improved documentation for popLast() with note about performance versus removeLast() 2016-10-17 23:47:08 +02:00
airspeedswift
ed5231b47c Numbered all FIXME(ABI) entries for tracking purposes. (#4868) 2016-09-19 16:41:41 -07:00
Dave Abrahams
5c13e35f29 [stdlib] Suppress noisy warnings
We don't have a way yet to say "this is deprecated for users, but let
the stdlib use it without complaining" so we need to do refactoring
shenanigans.
2016-08-28 15:06:42 -07:00
Maxim Moiseev
1faa41246a [stdlib] Adding radar links to the FIXME(ABI) markers (#4511) 2016-08-25 16:50:14 -07:00
Dave Abrahams
8a73f0b98e [stdlib] Change Indexable deprecation messages
It's important to let people know that, in contrast with existing
practice in other frameworks, we really are going to remove the
deprecated API, and soon.
2016-08-08 13:44:41 -07:00
Dave Abrahams
168047d0f0 Deprecate the Indexable protocols
Using them is always a mistake; the user should choose the corresponding
Collection protocol instead.
2016-08-07 22:20:27 -07:00
Nate Cook
63a4107c3c [stdlib] Fix type inference issue for BidirectionalCollection
This resolves the issue described in SR-1922, where conformance
to a bidirectional collection gives errors when implemented using
only the minimal protocol requirements.
2016-07-14 00:34:23 -05:00
Dmitri Gribenko
d591f9cf7a stdlib: remove most uses of @warn_unused_result, which does nothing now
I kept the one on sorted(), because that one requires a less trivial
change.
2016-05-19 18:39:39 -07:00
Nate Cook
982e3d09f8 [stdlib] Revise documentation for new indexing model
This revises and expands on documentation for the new collection methods
for working with indices and the revised Swift 3 set APIs. In addition,
it includes documentation for the new range types.
2016-05-19 10:16:14 -05:00
Dave Abrahams
0d68b3a4af [stdlib] Generate RandomAccessCollection defaults
The defaults we were generating for Collection and
BidirectionalCollection didn't make any sense, because if you could do
that strideable arithmetic then you essentially had random access.
Instead we constrain the defaults to apply to RandomAccessCollection
where the Indices are a CountableRange.
2016-05-02 11:35:32 -07:00
Dave Abrahams
446657459f [stdlib] index(...) tests => StdlibCollectionUnittest
Moving the ones that can be applied generally into the unit testing
library.
2016-05-01 14:00:24 -07:00
Dave Abrahams
9bee5d182f [stdlib] location/formLocation => index/formIndex 2016-04-26 17:46:16 -07:00
Dave Abrahams
47a870cc50 [stdlib] Use location/formLocation for all index movement 2016-04-21 17:13:41 -07:00
Max Moiseev
63d3d1a573 [stdlib][swift-3-indexing-model] extensions for Collection and BidirectionalCollection with strideable indexes 2016-04-21 12:14:56 -07:00
Dmitri Gribenko
3e708a9328 Merge commit '8e292daec1bc790c96b5ee39b8d55dadcac6ce1b' into swift-3-indexing-model 2016-04-14 15:10:26 -07:00
Dmitri Gribenko
735f1287b0 Merge remote-tracking branch 'origin/swift-3-indexing-model' into swift-3-indexing-model 2016-04-14 14:10:27 -07:00
Dmitri Gribenko
10697f939f Merge commit '510f29abf77e202780c11d5f6c7449313c819030' into swift-3-indexing-model 2016-04-14 13:45:27 -07:00
Max Moiseev
37bf02f7da [stdlib][swift-3-indexing-model] changes in index(_:stepsFrom:limitedBy:)
- index(_:stepsFrom:limitedBy:) returns Index?
- formIndex(_:stepsFrom:limitedBy) returns Bool
2016-04-14 11:49:27 -07:00
Nate Cook
f947c7c81c [New indexing model] Finish documentation revisions
- Replaced RandomAccessIndex mentions from Strideable documentation
  with stronger guarantees if Stride conforms to Integer.
- Other cleanup and revisions.
2016-04-08 14:04:34 -05:00
Nate Cook
34773e9612 [New indexing model] Revise documentation for collections
- Revised outdated descriptions
- Added missing documentation comment blocks
- Added preconditions where possible now that Index: Comparable
2016-04-07 16:53:11 -05:00
Dave Abrahams
94771b4a39 [stdlib] Update indexing model doc comments
Also fix some diagnostics
2016-04-06 17:34:00 -07:00
Dave Abrahams
1798fc8f84 [stdlib] Doc comment update WIP 2016-04-05 15:16:13 -07:00
Dave Abrahams
a5c3c63c3d [stdlib] Indexing model: nix RangeOfStrideable
Instead, use CountableRange which is constrained to have a Strideable
Bound whose Stride conforms to Integer.
2016-03-28 17:06:09 -07:00
Dave Abrahams
da5c4036ac func index(n: IndexDistance, stepsFrom i: Index)
M-x findr-query-replace

\<func advance(\([^(),]*\|[^(),]+([^()]*)[^(),]*\)\(,[
]*\)by \([^(),]*\|[^(),]+([^()]*)[^(),]*\)

func index(\3\2stepsFrom \1
2016-03-28 13:23:04 -07:00