Commit Graph

291 Commits

Author SHA1 Message Date
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
Ben Cohen
465f243943 Move += operator for append(contentsOf:) up to RangeReplaceableCollection 2017-01-05 11:59:49 -08:00
Ben Cohen
fefc2e40df Migrate _copyContents to be called from UnsafeMutableBufferPointer with checks for overrun. 2017-01-05 11:59:49 -08:00
Ben Cohen
4dc5eacef5 Merge branch 'master' into im-not-warning-you-again 2017-01-05 10:11:48 -08:00
JP Simard
65688bdc39 [gardening] replace unused closure parameters with '_' in stdlib source (#6522)
* replace unused closure parameters with '_' in stdlib source

* fold some _ closure arguments into line above

* fold more _ closure arguments into line above
2017-01-03 20:10:41 -07:00
ben-cohen
adf56d1435 supress function-arg-before-defaulted-arg warning 2016-12-29 10:49:14 -08:00
ben-cohen
ce0d713cd6 fixed where clauses, Optional-as-Any and unused vars 2016-12-29 07:58:12 -08:00
Max Moiseev
7afd9bbdef Making StdlibUnittest compile in absense of + on Strideable 2016-12-02 15:21:51 -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
76e0a99a37 Merge branch 'master' into new-integer-protocols 2016-10-31 09:29:19 -07:00
practicalswift
cc852042c9 [gardening] Fix accidental trailing whitespace. 2016-10-29 10:22:58 +02:00
Max Moiseev
ea8e0f0e15 Merge remote-tracking branch 'origin/master' into new-integer-protocols 2016-09-21 14:48:35 -07:00
airspeedswift
ed5231b47c Numbered all FIXME(ABI) entries for tracking purposes. (#4868) 2016-09-19 16:41:41 -07:00
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
Dmitri Gribenko
243a35cd65 Migrate callsites from 'expectEmpty()' to 'expectNil()' 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
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
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
Dmitri Gribenko
66b5bc01f6 StdlibUnittest: fix a warning by actually using the unused value 2016-08-08 01:56:26 -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
Dave Abrahams
f06a9a1154 Merge 'origin/master' into new-integer-protocols 2016-07-29 17:52:49 -07:00
Robert Widmann
14dc86cf15 Polish off uses of dynamicType in codebase 2016-07-29 16:58:40 -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
Maxim Moiseev
2540b6d0cc getting rid of toIntMax in StdlibCollectionUnittest 2016-07-29 17:52:39 +03: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
Dmitri Gribenko
558f2b8591 Merge pull request #3517 from natecook1000/nc-SE-0120
[stdlib] Implement partition API change (SE-0120)
2016-07-24 01:43:02 -07:00
Nate Cook
4ee37b7a2a Remove leftover print 2016-07-24 00:56:50 -05:00
Andrew Trick
ecc6bd51ad Type system support for raw pointer conversion. (#3685)
* [Type System] Handle raw pointer conversion.

As proposed in SE-0107: UnsafeRawPointer.
https://github.com/apple/swift-evolution/blob/master/proposals/0107-unsaferawpointer.md#implicit-argument-conversion

UnsafeMutablePointer<T> -> UnsafeMutableRawPointer
UnsafeMutablePointer<T> -> UnsafeRawPointer
UnsafePointer<T> -> UnsafeRawPointer
UnsafeMutableRawPointer -> UnsafeRawPointer

inout:
&anyVar -> UnsafeMutableRawPointer
&anyVar -> UnsafeRawPointer

array -> UnsafeRawPointer
string -> UnsafeRawPointer

varArray -> UnsafeMutableRawPointer

* Rename expectEqual(_, _, sameValue:) to expectEqualTest to workaround a type system bug.

<rdar://26058520> Generic type constraints incorrectly applied to functions with the same name

This is exposed by additions to the type system for UnsafeRawPointer.

Warning: unit tests fail very confusingly without this fix.
2016-07-23 11:30:49 -07:00
Nate Cook
c9c865c279 [stdlib] Update partition(by:) tests
Adds a dispatch test for partition(by:), since it's now a protocol
requirement. Also adds a new logging collection wrapper that only
logs when _withUnsafeMutableBufferPointerIfSupported is called --
any calls to this method from dispatched methods are uncounted by
the standard logging wrappers.
2016-07-22 22:31:27 -05:00
Nate Cook
2a6a67118a Test partition(by:) on all mutable collections 2016-07-21 10:18:20 -05:00
Nate Cook
29bbff221b [stdlib] Update partition tests with feedback 2016-07-21 10:18:20 -05:00
Nate Cook
1d037800b9 [stdlib] Update tests for new partition APIs
Special thanks to @aschwaighofer for help with these tests and fix-its!
2016-07-21 10:18:20 -05:00
Rintaro Ishizaki
42d09e7331 [SE-0095 Migration] Migrate protocol<...> usage 2016-07-21 14:29:33 +09:00
Rintaro Ishizaki
0a40f10bb4 [SE-0095] Migrate remaining use of protocol<> syntax 2016-07-20 19:18:46 +09:00
Joe
67dccb283e [SE-0095] Code feedback changes; Any is parsed as a keyword
- Any is made into a keyword which is always resolved into a TypeExpr,
allowing the removal of the type system code to find TheAnyType before
an unconstrained lookup.
- Types called `Any` can be declared, they are looked up as any other
identifier is
- Renaming/redefining behaviour of source loc methods on
ProtocolCompositionTypeRepr. Added a createEmptyComposition static
method too.
- Code highlighting treats Any as a type
- simplifyTypeExpr also does not rely on source to get operator name.
- Any is now handled properly in canParseType() which was causing
generic param lists containing ‘Any’ to fail
- The import objc id as Any work has been relying on getting a decl for
the Any type. I fix up the clang importer to use Context.TheAnyType
(instead of getAnyDecl()->getDeclaredType()). When importing the id
typedef, we create a typealias to Any and declare it unavaliable.
2016-07-19 12:01:37 -07:00
Andrew Trick
5a8271c621 Rename UnsafePointer allocate & deallocate. (#3608)
As proposed in SE-0107: UnsafeRawPointer:
Rename 'init(allocatingCapacity:)' to 'UnsafeMutablePointer.allocate(capacity:)'
Rename 'deallocateCapacity' to 'deallocate(capacity:)'

`allocate` should not be an initializer. It's primary function is to allocate
memory, not initialize a pointer.
2016-07-19 11:48:18 -07:00
Dave Abrahams
dcbfdb5339 _ includeElement/whereElementsSatisfy predicate => _ isIncluded 2016-07-19 07:05:54 -06:00
Dave Abrahams
4b072f630c _ isSeparator: => whereSeparator isSeparator: 2016-07-19 07:05:53 -06:00