Commit Graph

1231 Commits

Author SHA1 Message Date
practicalswift
fa7fbdb8b0 [gardening] Remove redundant nil-initialization of optional variable
From the Swift documentation:

"If you define an optional variable without providing a default value,
 the variable is automatically set to nil for you."
2016-09-18 07:40:07 +02:00
K Staring
7e51593508 Merge branch 'master' of https://github.com/apple/swift 2016-09-16 21:16:55 +02:00
Dmitri Gribenko
30509f1b64 StdlibUnittest: add an argument label to checkHashable
I think it improves readability of the callsite.
2016-09-15 10:20:09 -07:00
K Staring
afc95a5e2a disable handy pthread wrappers on FreeBSD since they don't compile
Things like: PthreadBarriers.swift:114:50: error: cannot convert value of type 'UnsafeMutablePointer<pthread_mutex_t>' (aka 'UnsafeMutablePointer<OpaquePointer>') to expected argument type 'UnsafeMutablePointer<pthread_mutex_t?>' (aka 'UnsafeMutablePointer<Optional<OpaquePointer>>')
on barrier.pointee.mutex . I need to do more research to understand this
2016-09-13 11:08:00 +02:00
Dmitri Gribenko
a4af3e62c3 StdlibUnittest: remove 'expectEmpty()' and 'expectNotEmpty()' 2016-09-12 10:33:07 -07:00
Dmitri Gribenko
243a35cd65 Migrate callsites from 'expectEmpty()' to 'expectNil()' 2016-09-10 20:05:42 -07:00
Dmitri Gribenko
b8a475be72 StdlibUnittest: rename 'expectEmpty()' and 'expectNotEmpty()' to 'expectNil()' and 'expectNotNil()'
The new names are what people generally expect.  The old names made more
sense in the old times when the 'Optional.None' case could not be
created with the 'nil' keyword.
2016-09-10 20:05:42 -07:00
Dmitri Gribenko
92c180031f stdlib: make 'Sequence.first(where:)' a pure protocol extension (no dynamic dispatch)
SE-0032 did not propose a protocol entry point, only a protocol
extension.

Using a pure protocol extension is the right choice here because a
concrete sequence can't provide a more efficient implementation of this
method than the default one.
2016-09-09 11:30:55 -07:00
Dmitri Gribenko
ef974af339 stdlib: disable an incorrect String comparison optimization on platforms that call ICU directly
... and add a test to ensure that the next attempt at writing this
optimization won't introduce a regression.
2016-09-06 22:46:40 -06:00
Dmitri Gribenko
10b339d2cb StdlibUnittest: improve error messages in checkComparable() 2016-09-06 22:46:40 -06:00
Dmitri Gribenko
6b4427b573 StdlibUnittest: expose cartesianProduct() helper 2016-09-06 20:41:03 -07:00
Dmitri Gribenko
9d9803c690 StdlibUnittest: test _copyToContiguousArray() in checkSequence() 2016-09-05 22:52:00 -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
Arsen Gasparyan
20aa8cbfc7 Add tests for SetAlgebra protocol 2016-08-24 10:46:18 +03:00
Slava Pestov
79a1512576 Sema: Three fixes for the new @escaping attribute
- If a parameter type is a sugared function type, mark the type
  as non-escaping by default. Previously, we were only doing this
  if the parameter type was written as a function type, with no
  additional sugar.

  This means in the following cases, the function parameter type
  is now non-escaping:

  func foo(f: ((Int) -> Void))

  typealias Fn = (Int) -> Void
  func foo(f: Fn)

- Also, allow @escaping to be used in the above cases:

  func foo(f: @escaping ((Int) -> Void))

  typealias Fn = (Int) -> Void
  func foo(f: @escaping Fn)

- Diagnose usages of @escaping in inappropriate locations, instead
  of just ignoring them.

It is unfortunate that sometimes we end up desugaring the typealias,
but currently there are other cases where this occurs too, such as
qualified lookpu of protocol typealiases with a concrete base
type, and generic type aliases. A more general representation for
sugared types (such as an AttributedType sugared type) would allow
us to solve this in a more satisfactory manner in the future.

However at the very least this patch factors out the common code
paths and adds comments, so it shouldn't be too bad going forward.

Note that this is a source-breaking change, both because @escaping
might need to be added to parameters with a sugared function type,
and @escaping might be removed if it appears somewhere where we
do not mark function types as non-escaping by default.
2016-08-17 19:37:23 -07:00
Robert Widmann
3814b7a23d Update the changelog 2016-08-17 00:18:09 -07:00
Robert Widmann
e6c313bce3 Merge pull request #3600 from russbishop/se0045
[SR-1516][stdlib] Implement SE-0045 prefix(while:) and drop(while:)
2016-08-16 16:26:21 -07:00
Russ Bishop
f0e6c306e4 [stdlib][SE-45] Add prefix(while:) and drop(while:) to Sequence
Includes lazy implementation courtesy of Nate Cook
2016-08-15 14:13:27 -07:00
Dave Abrahams
e6dec58cc5 Merge pull request #4041 from xwu/memory-layout-of-value
[stdlib] Implement SE-0136 (Restore MemoryLayout.*(ofValue:))
2016-08-12 11:09:17 -07:00
Dmitri Gribenko
08c772fdac StdlibUnittest: add an allowBrokenTransitivity flag to checkEquatable()
This will be used for testing Swift errors bridged to NSErrors.
2016-08-09 00:49:20 -07:00
Dmitri Gribenko
5a7e8f3337 StdlibUnittest: change Minimal~Class types to actually be classes 2016-08-09 00:49:20 -07:00
Dmitri Gribenko
fd627ff015 StdlibUnittest: add expectEqual(_: Any.Type, _: Any.Type) 2016-08-08 17:56:05 -07:00
Xiaodi Wu
f9435b9ce8 [stdlib] Restore MemoryLayout.*(ofValue:) 2016-08-08 10:46:37 -05:00
Dmitri Gribenko
66b5bc01f6 StdlibUnittest: fix a warning by actually using the unused value 2016-08-08 01:56:26 -07:00
Dmitri Gribenko
1d6b08ba97 stdlib: share the Unicode dataset across different test files 2016-08-07 23:29:24 -07:00
Dmitri Gribenko
987acd375d stdlib: make tests rely on Array implementation details less 2016-08-07 14:20:36 -07:00
Dmitri Gribenko
f45565ca6c StdlibUnittest: add a new overload of expectEqual() 2016-08-07 13:46:31 -07:00
Dmitri Gribenko
3dc793ce8a StdlibUnittest: add checkStrideable() 2016-08-07 03:57:15 -07:00
Michael Ilseman
b7c9eddd11 [noescape by default] drop @noescape from stdlib 2016-08-04 16:09:01 -07:00
Dmitri Gribenko
0118c7378a StdlibCollectionUnittest: reduce boilerplate 2016-08-03 22:38:28 -07:00
Jordan Rose
f42158b12e Revert "[Sema] ban multi-arguments to tuple coercion" (#3922)
It breaks cases where there really is a single unlabeled argument of tuple type, like this:

  let pairs = [(1, "A"), (2, "B")]
  print(pairs.map { $0.0 })
2016-08-01 19:22:19 -07:00
Daniel Duan
c9b73dacc2 [Sema] ban multi-arguments to tuple coercion
Implements part of SE-0110. Single argument in closures will not be accepted if
there exists explicit type with a number of arguments that's not 1.

```swift
let f: (Int, Int) -> Void = { x in } // this is now an error
```

Note there's a second part of SE-0110 which could be considered additive,
which says one must add an extra pair of parens to specify a single arugment
type that is a tuple:

```swift
let g ((Int, Int)) -> Void = { y in } // y should have type (Int, Int)
```

This patch does not implement that part.
2016-07-31 16:22:57 -07:00
Dmitri Gribenko
d098c52edc StdlibUnittest: CheckSequence: properly unwrap a value
Use the supplied callback to unwrap a value.  The value is not
guaranteed to be dynamically a MinimalEquatableValue.
2016-07-31 02:03:58 -07:00
Dmitri Gribenko
a4aa73b93b StdlibUnittest: unbreak testing multiple collections in one file
Commit 93dfc166 "More reliably avoid running duplicate tests"
accidentally disabled too many tests.  If one test file was testing
multiple collections, only the first one was tested, the rest were
skipped as duplicate tests.
2016-07-31 02:03:50 -07:00
Robert Widmann
b79fa44da5 Merge pull request #3878 from CodaFi/decltype
[SE-0096] Implement type(of:)
2016-07-29 18:05:01 -07:00
Dave Abrahams
f06a9a1154 Merge 'origin/master' into new-integer-protocols 2016-07-29 17:52:49 -07:00
Doug Gregor
b9363fe6bd [SE-0111] Enable SE-0111 by default. 2016-07-29 17:28:24 -07:00
Robert Widmann
14dc86cf15 Polish off uses of dynamicType in codebase 2016-07-29 16:58:40 -07:00
Dmitri Gribenko
99dffd7682 Merge pull request #3854 from rintaro/SE-0101-memorylayout
[SE-0101] Implement: Reconfiguring sizeof and related functions into a unified MemoryLayout struct - Part 1
2016-07-29 15:56:27 -07:00
Michael Ilseman
ccda8f33d1 [noescape by default] Proliferate @escaping
Adds an explicit @escaping throughout the standard library, validation
test suite, and tests. This will be necessary as soon as noescape is
the default for closure parameters.
2016-07-29 13:48:07 -07:00
Rintaro Ishizaki
091506315b [SE-0101] Implement: Reconfiguring sizeof and related functions into MemoryLayout struct
As of now:

* old APIs are just marked as `deprecated` not `unavaiable`. To make it
  easier to co-operate with other toolchain repos.
* Value variant of API is implemented as public @private
  `_ofInstance(_:)`.
2016-07-30 03:09:28 +09:00
Maxim Moiseev
2540b6d0cc getting rid of toIntMax in StdlibCollectionUnittest 2016-07-29 17:52:39 +03:00
Maxim Moiseev
655bfe2a57 FIXMEs to change FixedWidthInteger to BinaryInteger in generic code 2016-07-29 13:31:21 +03:00
Maxim Moiseev
6dbb572038 toIntMax is gone 2016-07-29 13:31:21 +03:00
Maxim Moiseev
6ccc6ae490 SetAlgebra conformance errors 2016-07-29 13:31:21 +03:00
Max Moiseev
28a252e33d Operators compile 2016-07-29 13:31:21 +03:00
Andrew Trick
0b75ee975e Remove "illegal" UnsafePointer casts from the stdlib.
Update for SE-0107: UnsafeRawPointer

This adds a "mutating" initialize to UnsafePointer to make
Immutable -> Mutable conversions explicit.

These are quick fixes to stdlib, overlays, and test cases that are necessary
in order to remove arbitrary UnsafePointer conversions.

Many cases can be expressed better up by reworking the surrounding
code, but we first need a working starting point.
2016-07-28 20:42:23 -07:00
Robert Widmann
4c2dbe1723 [stdlib][SE-0089] Finish off Lossless String Conversion (#3761)
* Rename string reflection init

* Addressing PR comments and updating some tests

* Update test suite for lossless string conversion
2016-07-28 17:13:25 -07:00
Mishal Shah
b0fdb80f79 Merge pull request #3816 from xwu/se-0134
[SE-0134][stdlib] Rename/remove two properties on String
2016-07-28 11:32:20 -07:00
Dmitri Gribenko
2d2c76f6ec stdlib: AnyHashable tests: finish tests for CF types 2016-07-28 01:35:58 -07:00