Commit Graph

284 Commits

Author SHA1 Message Date
Dave Abrahams
c2642e65e7 [stdlib] id-as-Any: hashed collection casting
Relax some preconditions in the cast machinery and write a comprehensive
test suite.

FIXMEs in test/1_stdlib/HashedCollectionCasts.swift.gyb show where the
typechecker doesn't seem to quite work, or the frontend might be
generating the wrong runtime calls.

TODO: Add tests for failing downcasts
2016-07-21 15:38:23 -07:00
Doug Gregor
778e76e158 [SE-0091 Follow-up] Move more operators into types, now for generic operators. 2016-07-21 12:54:27 -07:00
John McCall
0c642a8098 Stub out Set/Dictionary casting intrinsics on non-ObjC platforms. 2016-07-19 14:35:03 -07:00
Dave Abrahams
b2bbd4c599 reduce(_ initial:combine:) => reduce(_ initialResult:_ nextPartialResult) 2016-07-19 07:12:59 -06:00
Dave Abrahams
014b6972cf isOrderedBefore: => by areInIncreasingOrder: 2016-07-19 07:05:54 -06:00
Andrew Trick
73106dd7c3 Rename initialize(with:count:) to initialize(to:count:). (#3601)
As proposed in SE-0107: UnsafeRawPointer.

"with" is considered a vacuous preposition. "to" implies direction.
2016-07-18 23:37:45 -07:00
Michael Gottesman
fc37603c5f Revert "Implement SE-0118" 2016-07-18 16:44:58 -07:00
Dave Abrahams
b0044948df reduce(_ initial:combine:) => reduce(_ initialResult:_ nextPartialResult) 2016-07-18 14:30:46 -06:00
Dave Abrahams
f3ccc956c6 isOrderedBefore: => by areInIncreasingOrder: 2016-07-18 14:29:09 -06:00
Michael Gottesman
40e1991e12 Revert "Name and label changes for closure parameters (for review only) (#2981)"
This reverts commit 18406900ba.
2016-07-15 19:45:26 -07:00
Dave Abrahams
18406900ba Name and label changes for closure parameters (for review only) (#2981)
Implement SE-0118 Name and label changes for closure parameters

[SE-0118](https://github.com/apple/swift-evolution/blob/master/proposals/0118-closure-parameter-names-and-labels.md)
2016-07-15 15:31:48 -07:00
Robert Widmann
c39da37525 Merge pull request #3474 from CodaFi/postminimalist-abstract-expressionism
[SE-0115] Rename *LiteralConvertible protocols to ExpressibleBy*…
2016-07-12 21:08:52 -07:00
Robert Widmann
f97e5dcb0e [SE-0115][1/2] Rename *LiteralConvertible protocols to ExpressibleBy*Literal. This
change includes both the necessary protocol updates and the deprecation
warnings
suitable for migration.  A future patch will remove the renamings and
make this
a hard error.
2016-07-12 15:25:24 -07:00
Dave Abrahams
125823d16c [stdlib] ManagedBuffer: rename Value => Header
This implements SE-0114 Updating Buffer "Value" Names to "Header" Names
https://github.com/apple/swift-evolution/blob/master/proposals/0114-buffer-naming.md
2016-07-06 17:45:17 -07:00
Rintaro Ishizaki
6ef62f3c73 [stdlib] Better diagnosis for unavailable APIs
Added tests for expected-error and fix-its.

- Add arguments signature regardless that is the same as before.
  Because the error message looks more natural.
  e.g. "makeIterator" => "makeIterator()",
  "replaceSubrange" => "replaceSubrange(_:with:)"
- Any${ExistentialCollection}.underestimateCount() was a method, not
  computed property.
- 'LazySequenceType' has been renamed to 'LazySequenceProtocol', but not
  'LazyCollectionProtocol'
- Streamable.writeTo(_:) had no argument label.
- Fixed typo in print() debugPrint() error message (not working for now)
- Repeated.init(): changed `renamed` to `message` because the arugment
  order has changed.
- Marked `public` for some unavailable method on `Sequence`
- Sequence.split(_:maxSplit:allowEmptySlices) was replaced with
  split(separator:maxSplits:omittingEmptySubsequences:),
  not split(separator:omittingEmptySubsequences:isSeparator:)
- Sequence.split(_:allowEmptySlices:isSeparator) was replaced with
  split(maxSplits:omittingEmptySubsequences:isSeparator:),
  not split(_:omittingEmptySubsequences:isSeparator:)
- Sequence.startsWith(_:isEquivalent:) or startsWith(_:) had no label on
  the first argument.
- transcode(_:_:_:_:stopOnError), not transcode(_:_:_:_:stoppingOnError)
- Removed mutating methods from UnsafePointer.
  alloc(_:), dealloc(_:), setter:memory, initialize(_:), destroy(),
  and destroy(_:)
2016-07-01 14:52:09 +09:00
Dmitri Gribenko
6f502fae0b stdlib: make some internal Dictionary APIs safer by sinking the _fixLifetime() call deeper into implementation details 2016-06-22 14:10:10 -07:00
Doug Gregor
2807a17eb8 [Type checker SR-899] Warning on missing ".self" for single-parameter functions.
Due to a modeling error in the type checker's folding of type
references into type expressions, code such as "strideof(Int)" would
be accepted without the required ".self". Commit
4a60b6cbf4 fixes the modeling issue but
left the historical accepts-invalid; now, diagnose these cases with a
warning + Fix-It to ease the transition.

Fixes SR-899.
2016-06-12 22:31:59 -07:00
Rintaro Ishizaki
668b9dbc64 [stdlib] Apply tail style "where" clause to stdlib/public/core 2016-06-02 12:00:55 +09:00
Patrick Pijnappel
daec2dae00 Resolve conflicts with master 2016-05-24 19:21:04 +02:00
Dmitri Gribenko
0b4162bef0 stdlib: make the argument label in _UnsafeBitMap.sizeInWords more clear to avoid bits vs. bytes vs. words confusion 2016-05-23 18:41:39 -07:00
Dmitri Gribenko
b811f929ef stdlib: rename _BitMap to _UnsafeBitMap
_BitMap is nothing more than a convenience wrapper around an
UnsafeMutablePointer.
2016-05-23 18:41:39 -07:00
Dmitri Gribenko
389fa5fc69 stdlib: move _BitMap to its own file 2016-05-23 18:41:39 -07:00
Dmitri Gribenko
ea07472556 stdlib: Dictionary: rename the wordsFor() function to conform to API guidelines 2016-05-23 18:41:39 -07:00
Dmitri Gribenko
f78613758a stdlib: Dictionary: use the two-argument version of UnsafeMutablePointer.initialize() instead of a loop 2016-05-23 18:41:39 -07:00
Dmitri Gribenko
f7d110d4ea stdlib: Dictionary: abstract away some of the address calculations in _roundUp() 2016-05-23 18:41:39 -07:00
Dmitri Gribenko
78b60fb431 stdlib: Dictionary: simplify code and fix coding style 2016-05-23 18:41:39 -07:00
Dmitri Gribenko
0da6efdc1b stdlib: Dictionary: use strideof() to calculate the array size
Since sizeof(UInt) == strideof(UInt) there is no bug here, but
strideof() is the correct API to use for this purpose.
2016-05-23 18:41:39 -07:00
Dmitri Gribenko
e424982497 stdlib: Dictionary: attach a comment directly to the method 2016-05-23 18:41:39 -07:00
Dmitri Gribenko
1c09782396 stdlib: Dictionary: contain the unsigned division optimization in a getter method, expose a clean API to the outside 2016-05-23 18:41:39 -07:00
Nate Cook
44b2d56a7f [stdlib] Revise documentation for string-related types
This documentation revision covers a large number of types & protocols:
String, its views and their indices, the Unicode codec types and protocol,
as well as Character, UnicodeScalar, and StaticString, among others.

This also includes a few small changes across the standard library for
consistency.
2016-05-22 03:04:22 -05:00
practicalswift
61e4cde148 [gardening] Fix inconsistent formatting. 2016-05-20 21:26:16 +02: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
b7432d84b3 [stdlib] Revisions to dictionaries and 'Policy' protocols
This revises documentation for Dictionary and the related types and protocols,
including Equatable, Comparable, and Hashable.
2016-05-19 13:17:00 -05: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
Dmitri Gribenko
0868b6f70c stdlib: Dictionary, Set: allow querying for a mismatched type when bridged
Swift's Dictionary and Set are typed, but when bridged to NSDictionary
and NSSet they should behave accordingly, that is, allow querying for
keys of arbitrary types.

rdar://problem/23679193
2016-05-16 15:30:44 -07:00
Dmitri Gribenko
e211572b0e Merge pull request #2459 from tanadeau/sr-1052-use-attr
[WIP][SR-1052] Use @discardableResult and warn by default
2016-05-12 18:46:29 -07:00
Slava Pestov
ce0b51cc9b Update resilience annotations in stdlib for recent changes
The new indexing model and floating point stuff was missing a few
annotations, causing a build failure with -enable-resilience.
2016-05-11 22:51:33 -07:00
Trent Nadeau
6e327b4ddb Updated stdlib to use @discardableResult and _ = . 2016-05-11 22:53:37 -04:00
Patrick Pijnappel
4419614be4 Move post-nil guarantee to separate line for Iterators' next() 2016-05-08 21:36:39 +02:00
Roman Levenstein
b55564228f Fix some Set-related performance regressions introduced by the new indexing model.
Implement the FIXME and perform only one lookup instead of two.

rdar://26129485
2016-05-06 07:25:08 -07:00
Patrick Pijnappel
ab9e74cba3 Resolve conflicts with upstream 2016-05-05 08:55:34 +02:00
Mark Lacey
e03d334b68 Use Builtin.unreachable() in unavailable functions.
Saves a bit of code size in the standard library by eliminating some
static strings and function calls.

rdar://problem/25767016
2016-05-02 21:30:25 -07:00
Nate Cook
3fb445410f Update documentation comments for revised Set API 2016-04-27 10:56:35 -05:00
Dave Abrahams
9bee5d182f [stdlib] location/formLocation => index/formIndex 2016-04-26 17:46:16 -07:00
Dave Abrahams
debde16e2c Merge set-api branch into swift-3-indexing-model 2016-04-26 15:56:42 -07:00
Nate Cook
6e274913bf [stdlib] Revise documentation for Array- and Set-related types.
This adds and expands documentation for sequences, collections, and the array
types as well as `Set` and its related protocols.
2016-04-25 12:54:39 -05:00
Dave Abrahams
47a870cc50 [stdlib] Use location/formLocation for all index movement 2016-04-21 17:13:41 -07:00
Dmitri Gribenko
3d4378c86c stdlib: add ABI fixmes 2016-04-18 17:15:09 -07:00
Dmitri Gribenko
2b35fea059 Merge remote-tracking branch 'origin/master' into swift-3-indexing-model 2016-04-16 00:30:12 -07:00
Andrew Trick
e6e128b0b0 Remove on old workaround from HashedCollections.
It was casting an AnyObject pointer to an Int pointer before accessing
it. This is fortunately no longer needed because theoretically it's
undefined behavior.
2016-04-14 18:36:42 -07:00