Commit Graph

4494 Commits

Author SHA1 Message Date
Huon Wilson
72a87a76f8 [stdlib] Work-around incorrect name resolution with conditional BidirectionalCollections.
If a type conditionally conforms to BidirectionalCollection, suffix's (and the
others) use of `index` ends up dispatching through `Collection.index` seemingly
because it is a protocol requirement. The intended function is
BidirectionalCollection's overloaded `index` (which _isn't_ connected to a
protocol requirement), which is called for non-conditional conformances. As
such, this is a work-around to stop code crashing.

Noticed in SR-8022, rdar://problem/41216424.
2018-07-19 12:22:32 +10:00
swift-ci
3aef406989 Merge remote-tracking branch 'origin/master' into master-next 2018-07-18 15:49:08 -07:00
Matt Diephouse
f0cb64dec3 Conform Never to Error, Equatable, Comparable, and Hashable (#16857) 2018-07-18 15:41:14 -07:00
swift-ci
bbe8675fde Merge remote-tracking branch 'origin/master' into master-next 2018-07-18 11:49:19 -07:00
Ben Cohen
33c2efe32e Update random docs to SystemRandomNumberGenerator (#18042) 2018-07-18 11:45:57 -07:00
swift-ci
db0da0f0b1 Merge remote-tracking branch 'origin/master' into master-next 2018-07-18 11:29:16 -07:00
Pavel Yaskevich
d8e9bff817 Merge pull request #18039 from xedin/transparent-magnitude
[stdlib] Try to make `magnitude` transparent again by using `&+`
2018-07-18 11:20:18 -07:00
swift-ci
3e9d33f3cf Merge remote-tracking branch 'origin/master' into master-next 2018-07-18 10:49:25 -07:00
Nate Cook
2536277362 [stdlib] Various documentation improvements (#18013)
- Revise Bool.toggle() discussion and fix attribute placement
- Revise to Hasher abstracts and discussions
- Correct the name of the remainder operator
- Clean up deprecations and paste-os w/in UnsafePointer
2018-07-18 12:41:22 -05:00
Pavel Yaskevich
8f8a441c49 [stdlib] Try to make magnitude transparent again by using &+
Improvements from SE-0213 made constant propagation more
precise but, as a side-effect, resulted in more false positives,
to mitigate that `magnitude` has marked as `@inline(__always)`
but it could be made transparent again by using `&+` operator.
2018-07-18 00:25:10 -07:00
swift-ci
6f860ad2b3 Merge remote-tracking branch 'origin/master' into master-next 2018-07-17 20:09:49 -07:00
Ben Cohen
074dc43c3e Restore Sequence conformance to FlattenSequence.Iterator (#18024) 2018-07-17 20:00:30 -07:00
swift-ci
2776303905 Merge remote-tracking branch 'origin/master' into master-next 2018-07-17 18:00:27 -07:00
Pavel Yaskevich
a9660c7bc5 Merge pull request #17860 from xedin/SE-0213
[TypeChecker] SE-0213: Implement literal init via coercion
2018-07-17 17:53:25 -07:00
swift-ci
f0ad0f59c3 Merge remote-tracking branch 'origin/master' into master-next 2018-07-17 13:40:09 -07:00
Ben Cohen
be894e4510 Replace Random.default with SystemRandomNumberGenerator (#17989) 2018-07-17 13:17:06 -07:00
Pavel Yaskevich
aa9b3d8474 [TypeChecker] SE-0213: Implement literal init via coercion
Implementation is as follows: In `preCheckExpression` try to
detect if there is `T(literal)` call in the AST, replace it with
implicit `literal as T`, while trying to form type-checked AST,
after constraint solving, restore source information and drop
unnecessary coercion expression.

Resolves: rdar://problem/17088188
Resolves: rdar://problem/39120081
Resolves: rdar://problem/23672697
Resolves: rdar://problem/40379985
2018-07-17 12:08:59 -07:00
swift-ci
9b12d01fc2 Merge remote-tracking branch 'origin/master' into master-next 2018-07-17 09:09:17 -07:00
Nate Cook
4b9d611b87 [stdlib] Use nonmutating method to access _FixedArray contents on subscript (#17911) 2018-07-17 10:54:23 -05:00
Karoy Lorentey
c599572e56 [stdlib] _CocoaFastEnumerationStackBuf: make internal
_CocoaFastEnumerationStackBuf is now only used by Set and Dictionary, in code that isn’t exposed in the ABI. Remove @usableFromInline.
2018-07-17 16:00:12 +01:00
Karoy Lorentey
c19547a2e0 [stdlib] Set: Update methods defined in terms of key-value
insert(value, forKey: key), removeValue(forKey: key) doesn’t make sense for Set. Simplify.
2018-07-17 15:59:51 +01:00
Karoy Lorentey
543e050702 [stdlib] Set, Dictionary: Remove _Mutable*Buffer protocols
They had but a single type conforming them, so they did not pull their weight as internal interface-enforment protocols.
2018-07-17 15:59:51 +01:00
Karoy Lorentey
5a22b9016a [stdlib] Split _HashBuffer into four different protocols
This allows Set’s internal types not to define Key, Value, SequenceElement & SequenceElementWithoutLabels typealiases.

Splitting the protocol on the mutable/immutable axis allows us to remove some obsolete method definitions.
2018-07-17 15:59:51 +01:00
Karoy Lorentey
9756677d72 [stdlib] Set, Dictionary: Remove RawStorage typealiases
These were an artifact of gybbing.
2018-07-17 15:59:51 +01:00
Karoy Lorentey
a339f88a29 [stdlib] NFC: cosmetic changes 2018-07-17 15:59:51 +01:00
Karoy Lorentey
99f348800d [stdlib] Set, Dictionary: Make Cocoa->native conversion non-inlinable 2018-07-17 15:59:50 +01:00
Karoy Lorentey
47cae81c75 [stdlib] Set, Dictionary: Make Cocoa iteration state non-inlinable. 2018-07-17 15:59:50 +01:00
Karoy Lorentey
4ac2fc7517 [stdlib] _SwiftDeferredNS*: Clean up gyb artifacts
Remove typealiases and member functions made obsolete by de-gybbing.
2018-07-17 15:59:50 +01:00
Karoy Lorentey
619db38b5d [stdlib] Make non-verbatim bridged Set and Dictionary implementations internal
There is no reason to expose these in the Swift ABI.
2018-07-17 15:59:50 +01:00
Karoy Lorentey
c72bf4cdfa [stdlib] Make Set & Dictionary enumerators internal
There is no reason to expose these in the Swift ABI.
2018-07-17 15:59:50 +01:00
Tony Allevato
5352545f9c Apply review feedback 2018-07-16 18:00:39 -07:00
swift-ci
928ed50802 Merge remote-tracking branch 'origin/master' into master-next 2018-07-16 16:09:09 -07:00
Ben Cohen
57528ef458 De-gyb Stride.swift (#17956) 2018-07-16 16:02:22 -07:00
swift-ci
b4ebb5f916 Merge remote-tracking branch 'origin/master' into master-next 2018-07-16 12:49:11 -07:00
Michael Munday
e50f3ba592 [stdlib] Fix exact floating point to integer cast overflow detection (#16960)
LLVM specifies that the result of fptosi and fptoui instructions are
undefined if the target type cannot represent the value exactly. On
IBM Z (s390x) these instructions currently saturate when overflow
occurs. This means that the round-trip used to detect overflow
succeeds in situations where the conversion is not actually exact.

For example, casting Int32.max to a Float32 via a sitofp instruction
results in Int32.max + 1. This is inexact. However if we then convert
back to an Int32 via a fptosi instruction the result is clamped to
Int32.max and so the round trip has resulted in the same value. We
therefore cannot rely on round trips alone to verify the exactness
of this cast portably.

This commit modifies the conversion routines so that they do not
rely on undefined behavior and avoid using round trips in general.
2018-07-16 12:32:43 -07:00
swift-ci
c7a4d5fd76 Merge remote-tracking branch 'origin/master' into master-next 2018-07-16 08:29:07 -07:00
Ben Cohen
b77b544cdc Remove remaining @ininable from @_transparent (#17968) 2018-07-16 08:12:52 -07:00
swift-ci
895d5c4667 Merge remote-tracking branch 'origin/master' into master-next 2018-07-15 14:39:12 -07:00
Ben Cohen
bd7171bedf [stdlib] De-gyb Sort (#17954)
* [stdlib] De-gyb Sort
2018-07-15 14:23:06 -07:00
swift-ci
e9b00394f2 Merge remote-tracking branch 'origin/master' into master-next 2018-07-14 22:49:04 -07:00
Daiki Matsudate
a3552f393e [stdlib] Add compactMapValues(_:) to Dictionary (#15017)
add compact map values on hashed collections
2018-07-14 22:35:16 -07:00
swift-ci
b3490042bf Merge remote-tracking branch 'origin/master' into master-next 2018-07-14 22:29:11 -07:00
Ben Cohen
a8328a820f Factor a couple more universal inits into _Pointer (#17952) 2018-07-14 22:14:27 -07:00
swift-ci
ad8ce7e56f Merge remote-tracking branch 'origin/master' into master-next 2018-07-14 16:29:03 -07:00
Mark Lacey
51f8c93f58 Merge pull request #17918 from rudkx/remove-inc-dec-operators
Remove the '++' and '--' operators.
2018-07-14 16:27:57 -07:00
swift-ci
aef1ed620b Merge remote-tracking branch 'origin/master' into master-next 2018-07-14 07:59:20 -07:00
Ben Cohen
436b8610e7 [stdlib][WIP] Factor out common parts of pointer types and de-gyb (#17951)
* Add conformances to _Pointer and remove from pointer types

* De-gyb pointer files
2018-07-14 07:36:45 -07:00
swift-ci
a14d1db34b Merge remote-tracking branch 'origin/master' into master-next 2018-07-13 12:09:09 -07:00
Tony Allevato
f99109c552 [stdlib] NFC: Unicode.Scalar.Properties documentation fixes 2018-07-12 21:32:05 -07:00
Brent Royal-Gordon
b6e35038b2 [SILGen] Output a different message for failed IUO force-unwraps
Modifies SILGen and the `Swift._diagnoseUnexpectedNilOptional` call to print a slightly different message for force unwraps which were implicitly inserted by the compiler for IUOs. The message is chosen based on the presence of certain flags in the `ForceValueExpr`, not on the type of the value being unwrapped.
2018-07-12 19:09:56 -07:00