Commit Graph

2952 Commits

Author SHA1 Message Date
Joe Groff
720f496b2e Merge pull request #6605 from jckarter/unsafe-bitcast-warnings
Sema: Warn about some common classes of `unsafeBitCast` misuse.
2017-01-06 09:13:56 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Joe Groff
d0787fb6b5 Sema: Warn about some common classes of unsafeBitCast misuse.
- Most immediately, we now have `withoutActuallyEscaping` as a supported way to temporarily reference a nonescaping closure as if it were escapable, and we plan to break the ABI for escaping and nonescaping closures so that the old `unsafeBitCast` workaround no longer works.
- `unsafeBitCast` is also commonly used to kludge pointers into different types, but we have more semantically meaningful APIs for type punning now. Guide users towards those APIs.
- Suggest more specific and type-safe operations, like `bitPattern:` initializers or `unsafeDowncast`, for the situations where `unsafeBitCast` is being used to avoid dynamic type checks or reinterpret numerical bits.
2017-01-05 21:19:02 -08:00
Nate Cook
b582683ecb [stdlib] Use unsigned arithmetic in partition 2017-01-05 21:32:32 -06:00
Nate Cook
5d42113375 [stdlib] Expand comments for _sort3 2017-01-05 21:32:28 -06:00
Max Moiseev
e91536b05d Correcting doubleWidthDivide precondition 2017-01-05 16:23:49 -08:00
Max Moiseev
156b171722 Adding DoubleWidth<> 2017-01-05 14:21:05 -08:00
Ben Cohen
ca6353d60e Update raw version to return a typed buffer 2017-01-05 11:59:50 -08:00
Ben Cohen
d12beac355 Add UnsafeRawBufferPointer.initialize(as:from:) 2017-01-05 11:59:49 -08: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
Max Moiseev
36ad3b4300 Introducing abs<T : SignedArithmetic & Comparable> 2017-01-05 11:33:46 -08:00
Nate Cook
c67ebf836a Merge pull request #6502 from xwu/init-with-literals
Add doc comments for initializers for literals [NFC]
2017-01-04 23:56:26 -06:00
Ben Cohen
8ca0df6074 Merge pull request #6542 from airspeedswift/who-fixes-the-fixmes
[stdlib] Tag a handful of additional issues with FIXME(ABI)
2017-01-04 18:43:04 -08:00
Ben Cohen
6bb212cb26 Merge pull request #6538 from airspeedswift/int-string-radix-default
[stdlib] Combine String.init(Integer) with and without radix
2017-01-04 18:42:17 -08:00
Xiaodi Wu
a698ca906b Address reviewer comments 2017-01-04 15:16:50 -06:00
swift-ci
f801430025 Merge pull request #6517 from sigito/patch-2 2017-01-03 19:51:16 -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
Joe Groff
796df2dc44 Merge pull request #6429 from jckarter/type-of-by-overload-resolution
`withoutActuallyEscaping`
2017-01-03 18:47:29 -08:00
Ben Cohen
9a4349ce89 Combine String.init with and without radix 2017-01-03 18:39:59 -08:00
Ben Cohen
28114baeb9 Flag various FIXMEs as ABI-impacting 2017-01-03 18:36:20 -08:00
Robert Widmann
e1822bccfa Merge pull request #6516 from sigito/patch-1
Removed repetitive docstring
2017-01-03 17:35:37 -07:00
JP Simard
7301b79342 remove superfluous parentheses in control statements in stdlib source
since this appears to be the convention followed elsewhere in the code base.
2016-12-31 18:40:15 -08:00
Yurii Samsoniuk
2b62ed250a Updated index(_:offsetBy:limitedBy:) code example 2016-12-31 15:48:52 +01:00
Yurii Samsoniuk
faa7c749df Removed repetitive docstring 2016-12-31 15:19:44 +01:00
Xiaodi Wu
539dc2a6d0 Add doc comments for initializers for literals 2016-12-28 15:13:28 -05:00
Joe Groff
0c9297862f Sema: Handle type-checking for withoutActuallyEscaping.
withoutActuallyEscaping has a signature like `<T..., U, V, W> (@nonescaping (T...) throws<U> -> V, (@escaping (T...) throws<U> -> V) -> W) -> W, but our type system for functions unfortunately isn't quite that expressive yet, so we need to special-case it. Set up the necessary type system when resolving an overload set to reference withoutActuallyEscaping, and if a type check succeeds, build a MakeTemporarilyEscapableExpr to represent it in the type-checked AST.
2016-12-22 17:51:26 -08:00
Joe Groff
1889fde228 Resolve type(of:) by overload resolution rather than parse hackery.
`type(of:)` has behavior whose type isn't directly representable in Swift's type system, since it produces both concrete and existential metatypes. In Swift 3 we put in a parser hack to turn `type(of: <expr>)` into a DynamicTypeExpr, but this effectively made `type(of:)` a reserved name. It's a bit more principled to put `Swift.type(of:)` on the same level as other declarations, even with its special-case type system behavior, and we can do this by special-casing the type system we produce during overload resolution if `Swift.type(of:)` shows up in an overload set. This also lays groundwork for handling other declarations we want to ostensibly behave like normal declarations but with otherwise inexpressible types, viz. `withoutActuallyEscaping` from SE-0110.
2016-12-22 16:28:31 -08:00
Nate Cook
0a0c77ed3f Merge pull request #6275 from natecook1000/nc-revise-pointers
[stdlib] Revise unsafe pointers documentation
2016-12-22 15:19:51 -06:00
Nate Cook
4edccfef63 [stdlib] Change wording in UnsafeBufferPointer discussion 2016-12-22 12:54:26 -06:00
swift-ci
6805ecccae Merge pull request #6311 from natecook1000/nc-fixes-06 2016-12-21 21:28:48 -08:00
practicalswift
ce7a10474f [gardening] Fix accidental double and triple spaces. 2016-12-21 22:13:56 +01:00
Nate Cook
606bf83af3 [stdlib] Modify intro sort to pivot on median of 3
This modifies the _partition function used during sorting to select
the median of the first, middle, and last elements in the range to
be partitioned. Before partitioning begins, those three elements are
sorted, after which the middle element is selected as the pivot. This
change improves performance for sorted or nearly-sorted data.
2016-12-21 13:19:42 -06:00
Max Moiseev
d9013a4b62 Adding endianness related inits and properties to FixedWidthInteger 2016-12-20 15:54:25 -08:00
Philippe Hausler
7d01c5d851 Add a fast-path case for enumeration of keys and objects for bridged Dictionaries 2016-12-20 15:16:48 -08:00
Nate Cook
77fc4948cc [stdlib] Add note about pointer alignment for subtraction 2016-12-20 12:39:01 -06:00
Ben Cohen
11e8a1feda Merge pull request #6388 from airspeedswift/_assertFailure-labels
[stdlib] Adjust _assertionFailed signature for naming guidelines
2016-12-20 08:49:59 -08:00
Max Moiseev
138d9df43e Getting rid of no longer needed minimumSignedRepresentationBitWidth 2016-12-19 16:26:15 -08:00
Max Moiseev
51128d3547 Adding smart shift default implementations to BinaryInteger via an extension 2016-12-19 16:10:24 -08:00
Max Moiseev
4675e12bc6 Implementing non-mutating shifts using mutating ones (for consistency) 2016-12-19 15:28:18 -08:00
Max Moiseev
4c1cc0f885 Moving bitwise operations and shifts to BinaryInteger protocol 2016-12-19 15:19:04 -08:00
Max Moiseev
059f7a53e2 doubleWidth operations on Int64 need special implementation for 32bit platforms 2016-12-19 14:42:33 -08:00
Max Moiseev
3276aa5bcf Merge remote-tracking branch 'origin/master' into new-integer-protocols 2016-12-19 13:15:50 -08:00
Nate Cook
4169635a20 [stdlib] Consistency fixes in Array documentation
- Removed "see other" note from type discussion
- Modified index(_:offsetBy...) to match other collections
- Word choice in reserveCapacity(_:)
2016-12-19 14:16:36 -06:00
Nate Cook
82811c57f0 [stdlib] Improvements to Collection doc comments 2016-12-19 13:05:19 -06:00
Ben Cohen
f089e16c61 kill another FIXME I missed 2016-12-19 09:53:40 -08:00
Ben Cohen
14bbb92466 Adjust _assertionFailed signature for naming guidelines 2016-12-19 08:51:42 -08:00
Paul Hudson
94ef84b649 Minor style fix: added space before brace. 2016-12-18 19:15:13 +00:00
Max Moiseev
ea8f2209a3 Overflow checks in division/modulo operators + tests 2016-12-15 16:32:07 -08:00
Max Moiseev
d318ec540c Type hints in comparisons 2016-12-15 16:31:19 -08:00