Commit Graph

69 Commits

Author SHA1 Message Date
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
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
Nate Cook
0782b482b3 [stdlib] Documentation improvements
- Revise Equatable and Hashable for synthesized requirements
- Complete Strideable and stride(from:...:by:) documentation
- Revise DoubleWidth type docs
- Add complexity notes for Set.index(of:) and .contains(_:)
- Fix typos in Set.formUnion docs
- Add missing axioms for SetAlgebra (SR-6319)
- Improve guidance for description and debugDescription
- Add note about the result of passing duplicate keys to
  Dictionary(uniqueKeysWithValues:)
- Fix typo in BinaryInteger docs
- Update Substring docs with better conversion example
- Improve docs for withMemoryRebound and isKnownUniquelyReferenced
- Add missing docs not propagated from protocols
2018-01-05 17:06:44 -06: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
e7b668e705 Part the third 2017-12-01 12:40:19 -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
Xiaodi Wu
2a5b0d4a61 Disable conditional conformance of Stride{To|Through} 2017-11-25 12:49:59 -06:00
Xiaodi Wu
06ef6736d5 Add conditional conformance for Stride{To|Through} 2017-11-25 12:31:54 -06:00
Xiaodi Wu
94e3677033 Remove uninhabitable _DisabledRangeIndex_ type 2017-11-25 11:52:08 -06:00
Xiaodi Wu
c53dc66de8 Simplify Strideable._step 2017-11-25 11:50:00 -06:00
Xiaodi Wu
d3fe5ac264 Support fused multiply-add and remove buggy Collection conformance in floating-point strides 2017-11-25 11:44:18 -06:00
Ben Cohen
35452c2e62 [stdlib] Remove _Strideable protocol 2017-11-16 13:38:24 -08:00
Max Moiseev
9b98303a95 Temporarily add an O(N) underestimatedCount to StrideTo and StrideThrough 2017-11-09 14:42:04 -08:00
Max Moiseev
67763cd92d Mark Stride collections as internal while waiting for conditional conformances 2017-11-09 11:16:06 -08:00
Max Moiseev
0bc9c05b2f Use the ClosedRangeIndex for StrideThrough collections 2017-11-07 11:45:48 -08:00
Max Moiseev
1f7d155702 Use RandomAccessSlice for StrideToCollection.SubSequence 2017-11-06 15:59:04 -08:00
Max Moiseev
10f880c3dc [stdlib] Implement StrideTo and StrideThrough collections
In the absence of conditional conformances, they are now extra types
with different constraints, plus extra overloads to the
stride(from:to:by:) and stride(from:through:by:).
2017-11-06 15:59:04 -08:00
Max Moiseev
2874662ffb [stdlib] Implement _preprocessingPass and _customContainsEquatableElement for StrideTo and StrideThrough 2017-10-12 16:46:17 -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
Robert Widmann
d0bc2a8611 Custom message for recursive Strideable witness
Strideable declares a default witness for Equatable and Comparable

extension Strideable {
  @_inlineable
  public static func < (x: Self, y: Self) -> Bool {
    return x.distance(to: y) > 0
  }

  @_inlineable
  public static func == (x: Self, y: Self) -> Bool {
    return x.distance(to: y) == 0
  }
}

This witness is implemented recursively because the expectation
is that Stride != Self.  However, it is possible to implement
SignedNumeric and Strideable together and inherit this conformance
which will cause undefined behavior - usually a crash.

Provide an overload when Stride == Self and crash with custom message
that mentions that Equatable and Comparable have to be implemented
in this case.

- It's better than nothing.
2017-09-15 12:31:09 -04: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
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
ca5c65f93c [stdlib] Nest some additional operators (#9646) 2017-05-17 19:44:08 -07:00
Dave Abrahams
feea061d32 [stdlib] Move new Unicode decoders into the stdlib
No expected change in benchmarks, as legacy components aren't using this yet.
2017-05-01 17:08:08 -07:00
Max Moiseev
a1cb7a8d73 [stdlib] Removing redundand requirement 2017-04-19 11:24:59 -07:00
Max Moiseev
8de33b4824 Overloads for +/- on Strideable for Swift 3 compatibility mode 2017-04-13 17:29:42 -07:00
Max Moiseev
bc7918b94c Commenting out deprecated +/- on Strideable 2017-04-12 17:03:30 -07:00
Max Moiseev
9bf43d632f Arithmetic operators for Strideable where Stride : ExpressibleByIntegerLiteral for compatibility 2017-04-07 11:41:23 -07:00
Max Moiseev
5b613b3f44 Adding deprecated mixed-type arithmetic operators for Strideable & SignedInteger for compatibility 2017-04-07 11:41:22 -07:00
Max Moiseev
2c9be47551 Merge branch 'master' into new-integer-protocols 2017-03-23 16:46:01 -07:00
Doug Gregor
388f0c505e [Stdlib] Eliminate explicit constraints made redundant by inferred ones. 2017-03-22 17:35:12 -07:00
Max Moiseev
b9fb3badc8 Merge remote-tracking branch 'origin/master' into new-integer-protocols 2017-03-22 12:30:24 -07:00
swift-ci
3e085fca4b Merge pull request #7946 from DougGregor/all-conformance-constraint-sources 2017-03-18 01:30:27 -07:00
Doug Gregor
13c4ae0168 [Standard library] Eliminate redundant conformance constraints.
Eliminate all of the redundant conformance constraints in the standard
library that were identified by the newly-introduced warning for
redundant, explicitly-specified conformances.
2017-03-17 20:15:09 -10:00
Roman Levenstein
29ad714bb7 Annotate stdlib functions to get a good performance even in resilient mode, when -sil-serialize-all is disabled
This commit mostly improves the performance of arrays and ranges.
It does not cover Strings, Dictionaries and Sets yet.
2017-03-16 19:46:11 -07:00
Max Moiseev
7d73b2e1ca Arithmetic => Numeric 2017-03-13 11:50:02 -07:00
Maxim Moiseev
f462ce7852 Deprecating + and - for SignedInteger and its Stride (#6603)
* Removing uses of mixed-type + and - in benchmarks

Using type cast or explicit type annotations.

* Deprecating use of + and - on SignedInteger

As it leads to mixed type arithmetics that is not supposed to work.
It was needed before the new collection indexing model to make moving
indexes simple.

* Test deprecation warning
2017-01-11 14:42:27 -08:00
Max Moiseev
27889c6376 Merge remote-tracking branch 'origin/master' into new-integer-protocols 2017-01-06 15:54:44 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01: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
Max Moiseev
2b50c6fadc Fixing the benchmark crash
... by removing the + - overloads for Strideable, and only leaving them
for pointers (both Strideable and _Pointer).

Strideable was used in the past to simplify advancing collection
indices, but with new collection indexing model it is no longer
necessary to overload `+` and `-` for all strideable types..
2016-11-29 15:55:46 -08:00
Max Moiseev
70b2343626 Merge branch 'master' into new-integer-protocols 2016-11-28 15:25:01 -08: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
Max Moiseev
ffc8a37811 Strideable for _Pointer is not necessary in Swift 4
All the necessary methods and operators are already implemented for
concrete pointer types more efficiently.
2016-11-16 14:45:33 -08:00
Max Moiseev
62044dec5e Different Strideable conformances for Swift 3 and Swift 4 2016-10-20 16:53:41 -07:00
Max Moiseev
8e109de9a2 Using Strideable APIs instead of + and - 2016-10-20 16:29:21 -07:00
Max Moiseev
3dcdd1a2c8 Get rid of _DisallowMixedSignArithmetic 2016-10-20 13:53:41 -07:00
Max Moiseev
ea8e0f0e15 Merge remote-tracking branch 'origin/master' into new-integer-protocols 2016-09-21 14:48:35 -07:00