Commit Graph

2015 Commits

Author SHA1 Message Date
Nate Cook
41ea7e296c Merge pull request #10113 from natecook1000/nc-dict-tuples
[stdlib] Add dictionary overloads for merging methods
2017-06-06 14:58:15 -07:00
Nate Cook
a48e7fd954 [stdlib] Test that dictionaries can be passed to merge/merging 2017-06-05 15:54:16 -07:00
Robert Widmann
6509f78f13 tests: replace remaining 'mkdir -p' calls with %empty-directory(...)'
These changes were made manually.
2017-06-04 11:08:39 -07:00
Dmitri Gribenko
984210aa53 tests: replace '// RUN: rm -rf' '// RUN: mkdir' pairs with '%empty-directory(...)'
These changes were made using a script.
2017-06-04 11:08:39 -07:00
Dmitri Gribenko
486cab447d tests: replace 'rm -rf %t && mkdir -p %t' with '%empty-directory(%t)'
These changes were made using a script.
2017-06-04 11:08:39 -07:00
Dave Abrahams
b2e4bd5d09 [stdlib] Replace _HeapBuffer with a thin wrapper
...over ManagedBufferPointer
2017-06-01 04:40:52 -07:00
Dave Abrahams
ce804529a1 [stdlib] Dump _StringStorage.grow()
This implementation detail was adding lots of needless complexity
2017-05-31 16:12:22 -07:00
Ben Cohen
02e2bd5380 Re-gyb sorting (#9818) 2017-05-21 16:59:46 -07:00
Ben Cohen
169f3aed6f Revert "Un-XFAIL Lazy.swift test (#9777)"
This reverts commit f9893a9758.
2017-05-19 11:30:33 -07:00
Ben Cohen
f9893a9758 Un-XFAIL Lazy.swift test (#9777) 2017-05-19 10:03:54 -07:00
Dave Abrahams
fd30b72ee1 [stdlib] Fix a race
Lock-free programming is almost always a bug.
Fixes <rdar://25398370> Data Race in StringBuffer.append (found by TSan)
2017-05-18 16:29:59 -07:00
Doug Gregor
2a9867bf88 [CoreGraphics] Make CGColor adopt _ExpressibleByColorLiteral.
The backflips here are because we cannot add initializers to imported
CF types; they would be factory initializers. Fixes
rdar://problem/32196175.
2017-05-18 09:57:52 -07:00
Mark Lacey
bc7dff5c9f Revert "Re-instate "Improve disjunction selection""
This reverts commit
ecfa406fc5, which was reinstating
3c5b393e0c.

It does not revert one test change from that commit, because
inexplicably one of the tests is still failing, probably due to some
other changes that have happened since. I'm leaving a ticket open to
investigate.

I've added one of the new cases that is failing as a result of this
change.

This is being reverted not because of bugs in this particular commit,
but because it seems to be exposing other bugs in the type checker that
are resulting in source compatibility problems. We need to shake these
other bugs out of the type checker before bringing this change back.
2017-05-15 11:27:11 -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
f030652cc9 Merge pull request #9462 from natecook1000/nc-dict-keys-compat
[stdlib] Provide Swift 3 compatible Dict.keys/values
2017-05-10 15:37:39 -05:00
Nate Cook
b71e2636c4 Update dictionary tests 2017-05-10 11:27:34 -05:00
Nate Cook
bdcf640b59 Updated tests for Dictionary.keys/values 2017-05-10 10:45:08 -05:00
Jordan Rose
01cb554387 Re-apply "Make all CF types Equatable and Hashable." (#4568)
Like NSObject, CFType has primitive operations CFEqual and CFHash,
so Swift should allow those types to show up in Hashable positions
(like dictionaries). The most general way to do this was to
introduce a new protocol, _CFObject, and then have the importer
automatically make all CF types conform to it.

This did require one additional change: the == implementation that
calls through to CFEqual is in a new CoreFoundation overlay, but the
conformance is in the underlying Clang module. Therefore, operator
lookup for conformances has been changed to look in the overlay for
an imported declaration (if there is one).

This re-applies 361ab62454, reverted in
f50b1e73dc, after a /very/ long interval
where we decided if it was worth breaking people who've added these
conformances on their own. Since the workaround isn't too difficult---
use `#if swift(>=3.2)` to guard the extension introducing the
conformance---it was deemed acceptable.

https://bugs.swift.org/browse/SR-2388
2017-05-08 14:05:11 -07:00
Ben Cohen
f6f3ed0fe7 Add Collection constraints via protocol where clauses (#9374) 2017-05-07 08:55:48 -07:00
Max Moiseev
178b9f0b44 [stdlib] Adding bounds check in a.subscript(Index) fast path
UnsafeBufferPoiunter subscript used in the fast path only checks bounds
in Debug mode, therefore extra checks are needed.

Addresses: <rdar://problem/31992473>
2017-05-05 15:26:24 -07:00
Graydon Hoare
badf215b82 Use .skip rather than .xfail on unknown-cause stdlib String test (rdar://31992473) 2017-05-05 11:06:45 -07:00
Maxim Moiseev
b93dd6602e XFAILing the String test to fix the build 2017-05-05 10:38:50 -07:00
Ted Kremenek
cb7ad7d785 Merge pull request #9162 from phausler/safe_nsnumber
[Foundation] Implementation of SE-0170 for safer NSNumber bridging
2017-05-04 13:30:31 -07:00
Philippe Hausler
a9600338c8 [Foundation] Disable more NSNumber test failures due to incorrect float representations 2017-05-04 11:03:20 -07:00
Philippe Hausler
0011117a20 [Foundation] Work-around ambiguity of initializers by avoiding using bitPattern in literal cases that could be claimed as double values 2017-05-03 12:56:03 -07:00
Nate Cook
5aed293cde [stdlib] Fix test for different hash layouts 2017-05-02 15:27:49 -05:00
Philippe Hausler
d9ae358b05 Rename NSNumber bridge tests to be clear on what they do 2017-05-02 09:30:35 -07:00
Nate Cook
5da1ce032f [stdlib] Fix order for Dictionary.keys/values tests 2017-05-02 09:48:22 -05:00
Nate Cook
2e2e4d9bda Revert "Revert "[stdlib] Dictionary/Set enhancements""
This reverts commit 328ebe8567.
2017-05-01 16:06:14 -05:00
Ben Cohen
43211b602a [stdlib] De-gyb sorting (#9135)
* [stdlib] De-gyb sort algorithms

* [stdlib] Rename Sort.swift.gyb

* Update tests for de-gybbed sort
2017-04-30 18:11:27 -07:00
Arnold Schwaighofer
6c854c2532 [stdlib] Disable failing Lazy.swift.gyb test again
rdar://31897334
2017-04-30 15:33:42 -07:00
swift-ci
8fea2f7ac2 Merge pull request #9134 from airspeedswift/delete-dead-code 2017-04-30 08:26:38 -07:00
ben-cohen
a7def4bba9 Delete old unused String._splitFirst 2017-04-30 06:04:15 -07:00
Mark Lacey
ecfa406fc5 Re-instate "Improve disjunction selection"
Thie reinstates 3c5b393e0c, which was
backed out due to it exposing an ambiguous expression in a recent stdlib
commit.
2017-04-29 17:53:13 -07:00
Mark Lacey
1de530e229 Revert "Improve disjunction selection" 2017-04-29 10:45:15 -07:00
Mark Lacey
2e9858d5c7 Merge pull request #9059 from rudkx/disjunction-selection
Improve disjunction selection
2017-04-29 10:10:16 -07:00
Arnold Schwaighofer
328ebe8567 Revert "[stdlib] Dictionary/Set enhancements" 2017-04-29 07:02:57 -07:00
Mark Lacey
3c5b393e0c [Constraint solver] Rework how we select the next disjunction to visit.
We previously used a simple heuristic of visiting the disjunction with
the fewest number of elements in it.

Instead, this commit introduces a new way to select the best disjunction
to explore based on attempting disjunctions based on either how much
information we have about the associated type variables (e.g. how many
of the arguments of a function call in the case of bind overload
disjunctions) or by other criteria that help constraint the search or
split the connected components (e.g. coercions and calls to
initializers).

A key part of the improvement here is allowing the type checker to
attempt bindings of types to type variables when there are still
argument conversion constraints between type variables in the
system. The insight here is if there are no other constraints blocking
an attempt to bind types and we have types to try, we will be able to
test those types against active conformance constraints and potentially
fail much earlier while solving.

Visiting disjunctions in a different order exposed some other problems
with the type checker including a couple cases where map is used that
are now considered ambiguous due to problems in how we are ranking
solutions.

I measured an 11-13% reduction in type checking time for the standard
library using a release build of the compiler.
2017-04-28 00:50:16 -07:00
Nate Cook
e2328885c1 [stdlib] Dictionary/Set enhancements
A variety of enhancements from SE-154 and SE-165:

- Custom Keys and Values collections for Dictionary
- Two sequence-based Dictionary initializers
- Merging methods for Dictionary
- Capacity checking and reserving for Dictionary and Set
- Type-specific filter(_:) methods for Dictionary and Set
- A mapValues(_:) method for Dictionary
- A grouping Dictionary initializer
2017-04-26 11:21:16 -05:00
Erik Eckstein
f74e677312 Disabled a test to unblock ci
rdar://problem/31780356
2017-04-24 08:54:59 -07:00
Ben Cohen
5494424b9a Correct UnsafeBufferPointer's Collection.makeIterator, add _copyContents (#8902) 2017-04-21 15:53:51 -07:00
Doug Gregor
70ee642072 [Stdlib] Eliminate LazyFilterIndex.
Eliminate the vestigial type `LazyFilterIndex`, which was
necessary pre-Swift-3 to allow the index to move. Swift 3's indexing
model means that the movement of indices is on the collection itself,
so we no longer need `LazyFilterIndex`: instead, the `Index` type of
the lazy filtered collection is simply the `Index` type of the base
collection, which is a nice convenience: it means you can take indices
from a lazy wrapper around a given collection C and use them with the
collection C (and, with care, vice-versa) without jumping through
extra hoops.
2017-04-20 16:15:41 -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
Doug Gregor
0dd1da35d4 [Stdlib] Use SE-0142 to address ABI FIXMEs #68, #89, #90, #91.
Address ABI FIXME #68 by using same-type constraints directly on an
associated type to describe the requirements on the Indices associated
type of the Collection protocol. ABI FIXMEs #89, #90, #91 are all in
StdlibUnittest, and provoke warnings once #68 is fixed, but it's nice
to clear them out.

Fixes SR-2121.
2017-04-19 23:15:32 -07:00
Max Moiseev
9b53efd72c Merge branch 'master' into new-integer-protocols 2017-04-17 09:53:44 -07:00
Max Moiseev
2e67c13d15 Fixing some tests 2017-04-14 16:19:06 -07:00
Mark Lacey
f2564109c0 Reinstate diagnostics for assignment from Int to unsigned types.
These had previously been removed in
9c2bc50acd because of differences in the
diagnostics being emitted across different platforms.

It looks like we're always emitting the same diagnostic now, so restore
a specific message.

Resolves: rdar://problem/19677545
2017-04-13 14:40:43 -07:00
Max Moiseev
022665547b Merge branch 'master' into new-integer-protocols 2017-04-07 14:42:53 -07:00
Andrew Trick
1c2165d7fb Don't enable validation testing of Data.SubSequence. It hasn't been fixed yet. 2017-04-06 17:12:18 -07:00
Andrew Trick
8668f9bd72 Add init(rebasing:) to UnsafeBufferPointer.
This is required for consistency with UnsafeRawBufferPointer.
2017-04-06 17:12:18 -07:00