Commit Graph

3939 Commits

Author SHA1 Message Date
Mark Lacey
393eae2fb4 Merge pull request #14364 from rudkx/typealias-for-iuo
Make ImplicitlyUnwrappedOptional<T> an unavailable typealias.
2018-02-02 17:46:49 -08:00
Ben Cohen
cfaff1dc7d [stdlib] Move _copyBuffer to be an init on _ArrayBufferProtocol (#14222)
* Move _copyBuffer to be an init on _ArrayBufferProtocol

* Make init(copying:) inlineable, even though its inline(never), to allow specialization.

* Delete old array swap test, as swap on arrays is no longer valid.

* Delete the old static method
2018-02-02 10:42:45 -08:00
Mark Lacey
2008674495 Make ImplicitlyUnwrappedOptional<T> an unavailable typealias.
Also remove the decl from the known decls and remove a
bunch of code referencing that decl as well as a bunch of other
random things including deserialization support.

This includes removing some specialized diagnostics code that
matched the identifier ImplicitlyUnwrappedOptional, and tweaking
diagnostics for various modes and various issues.

Fixes most of rdar://problem/37121121, among other things.
2018-02-02 08:35:53 -08:00
Xiaodi Wu
c1f3176fe7 Remove sole use of _floorLog2 2018-02-02 10:07:18 -06:00
Xiaodi Wu
f4a3947632 Remove _countLeadingZeros and _floorLog2 2018-02-02 09:58:00 -06:00
Michael Ilseman
2785bee6e0 Merge pull request #14356 from milseman/what_a_character
[string] Minor cleanup on Character
2018-02-02 07:54:34 -08:00
Mark Lacey
e43ff7164c Merge pull request #14299 from rudkx/iuo-remove-the-type
IUO: Generate Optional<T> rather than ImplicitlyUnwrappedOptional<T>
2018-02-01 21:58:37 -08:00
Ben Cohen
9ee856f386 [stdlib][WIP] Eliminate (Closed)CountableRange using conditional conformance (#13342)
* Make Range conditionally a Collection

* Convert ClosedRange to conditionally a collection

* De-gyb Range/ClosedRange, refactoring some methods.

* Remove use of Countable{Closed}Range from stdlib

* Remove Countable use from Foundation

* Fix test errors and warnings resulting from Range/CountableRange collapse

* fix prespecialize test for new mangling

* Update CoreAudio use of CountableRange

* Update SwiftSyntax use of CountableRange

* Restore ClosedRange.Index: Hashable conformance

* Move fixed typechecker slowness test for array-of-ranges from slow to fast, yay

* Apply Doug's patch to loosen test to just check for error
2018-02-01 20:59:28 -08:00
Ben Cohen
c1d4b60281 [stdlib] Collection compatibility shim fixes (#14342)
* Fix compatibility shims for IndexDistance

* Add a second test for implied IndexDistance, Bidirectional conformance
2018-02-01 19:47:11 -08:00
Michael Ilseman
49a2103a60 [string] Minor simplification to Character init 2018-02-01 19:25:23 -08:00
Xiaodi Wu
37beb71708 Merge pull request #14295 from xwu/integer-documentation
[docs] Update and fill in documentation for DoubleWidth and integer protocols
2018-02-01 16:07:05 -06:00
Michael Ilseman
d5d9e2bac8 [string] Minor expression simplification. NFC 2018-02-01 12:10:25 -08:00
Michael Ilseman
9948141a99 [gardening] Strip trailing whitespace; NFC 2018-02-01 12:10:25 -08:00
Lance Parker
bce84b8c49 fix mutations for substrings through views 2018-01-31 16:49:14 -08:00
Xiaodi Wu
21d59c415d Address reviewer feedback 2018-01-31 15:09:15 -06:00
Ben Cohen
dd5e6b64ea Add custom implementations of removeLast and remove(at:) to Array (#14273) 2018-01-31 22:05:19 +01:00
Mark Lacey
f08823757a IUO: Generate Optional<T> rather than ImplicitlyUnwrappedOptional<T>.
Stop creating ImplicitlyUnwrappedOptional<T> so that we can remove it
from the type system.

Enable the code that generates disjunctions for Optional<T> and
rewrites expressions based on the original declared type being 'T!'.

Most of the changes supporting this were previously merged to master,
but some things were difficult to merge to master without actually
removing IUOs from the type system:
- Dynamic member lookup and dynamic subscripting
- Changes to ensure the bridging peephole still works

Past commits have attempted to retain as much fidelity with how we
were printing things as possible. There are some cases where we still
are not printing things the same way:
- In diagnostics we will print '?' rather than '!'
- Some SourceKit and Code Completion output where we print a Type
  rather than Decl.

Things like module printing via swift-ide-test attempt to print '!'
any place that we now have Optional types that were declared as IUOs.

There are some diagnostics regressions related to the fact that we can
no longer "look through" IUOs. For the same reason some output and
functionality changes in Code Completion. I have an idea of how we can
restore these, and have opened a bug to investigate doing so.

There are some small source compatibility breaks that result from
this change:
- Results of dynamic lookup that are themselves declared IUO can in
  rare circumstances be inferred differently. This shows up in
  test/ClangImporter/objc_parse.swift, where we have
    var optStr = obj.nsstringProperty
  Rather than inferring optStr to be 'String!?', we now infer this to
  be 'String??', which is in line with the expectations of SE-0054.
  The fact that we were only inferring the outermost IUO to be an
  Optional in Swift 4 was a result of the incomplete implementation of
  SE-0054 as opposed to a particular design. This should rarely cause
  problems since in the common-case of actually using the property rather
  than just assigning it to a value with inferred type, we will behave
  the same way.
- Overloading functions with inout parameters strictly by a difference
  in optionality (i.e. Optional<T> vs. ImplicitlyUnwrappedOptional<T>)
  will result in an error rather than the diagnostic that was added
  in Swift 4.1.
- Any place where '!' was being used where it wasn't supposed to be
  allowed by SE-0054 will now treat the '!' as if it were '?'.
  Swift 4.1 generates warnings for these saying that putting '!'
  in that location is deprecated. These locations include for example
  typealiases or any place where '!' is nested in another type like
  `Int!?` or `[Int!]`.

This commit effectively means ImplicitlyUnwrappedOptional<T> is no
longer part of the type system, although I haven't actually removed
all of the code dealing with it yet.

ImplicitlyUnwrappedOptional<T> is is dead, long live implicitly
unwrapped Optional<T>!

Resolves rdar://problem/33272674.
2018-01-31 12:15:58 -08:00
Xiaodi Wu
78875d934c Update and fill in documentation for DoubleWidth and integer protocols 2018-01-30 20:52:24 -06:00
swift-ci
b28c282f09 Merge pull request #14219 from xwu/nunc-est-dividendum 2018-01-30 17:56:50 -08:00
Xiaodi Wu
4b9ff41303 Address reviewer comments 2018-01-30 18:55:19 -06:00
swift-ci
238b876602 Merge pull request #14251 from vedantk/pretty-print 2018-01-29 18:36:24 -08:00
Vedant Kumar
5049db0dd9 [DebuggerSupport] Attempt expanding objects with .class display style
When pretty-printing objects, attempt to expand & print objects which
have the `.class` display style even if they do not have any instance
variables. The pretty-printer will still bail out if the object does not
conform to CustomReflectable.

This is enough to teach the pretty-printer to format bridged NSStrings.

rdar://36843869
2018-01-29 15:31:53 -08:00
Mike Ash
5e2b11d42d Merge pull request #14157 from mikeash/conditionally-disable-runtimefunctioncounters
[Runtime] Remove RuntimeFunctionCounters in no-assert builds.
2018-01-29 15:48:32 -05:00
Jordan Rose
1a30ffdbd7 Revert "[stdlib] Add custom implementations of removeLast and remove(at:) to Array (#14212)"
This reverts commit 5ed4afe50b. It
doesn't appear to be correct when the client is compiled with
optimizations (as in, there's a failing bot).
2018-01-28 21:26:55 -08:00
Xiaodi Wu
cc0e64dec4 Implement efficient DoubleWidth division and fix division-related bugs 2018-01-28 14:01:06 -06:00
Ben Cohen
5ed4afe50b [stdlib] Add custom implementations of removeLast and remove(at:) to Array (#14212)
* Add custom implementations of removeLast and remove(at:) to Array
2018-01-28 04:55:33 -08:00
swift-ci
39e03788a3 Merge pull request #14209 from xwu/revised-combine-hash-values-link 2018-01-26 23:13:03 -08:00
Xiaodi Wu
bd6d94063d Update link citing Hoad and Zobel (2003) 2018-01-27 00:00:27 -06:00
Mike Ash
6f37cca3e0 [Runtime] Disable RuntimeFunctionCounters tests if the counters are disabled.
Also update how the variable is managed in the build system to allow the test to be conditional based on it, and make it more natural to set it on the command line.
2018-01-26 15:35:33 -05:00
Karoy Lorentey
7a6d14f968 Merge pull request #14126 from lorentey/warnings1
[stdlib] _SwiftNativeNS*.init(): Add @nonobjc attribute
2018-01-26 11:46:35 +00:00
Mike Ash
f48bd293cb [Runtime] Remove RuntimeFunctionCounters in no-assert builds.
A build option to include or exclude RuntimeFunctionCounters. By default, it's enabled when assertions are enabled.

rdar://problem/35864525
2018-01-25 12:18:25 -05:00
Karoy Lorentey
75a376d319 [stdlib] Use Int._binaryLogarithm() to round up to nearest power of 2 2018-01-25 15:48:34 +00:00
Karoy Lorentey
34184a0162 Don't expose empty initializers in _SwiftNativeNS* classes to Objective-C
These aren't supposed to be called from Objective-C, and having them @nonobjc does not preclude subclasses from re-exposing their own initializers.

This fixes a build-time warning for @objc inference on _SwiftNativeNSArray.init.
2018-01-25 14:39:04 +00:00
Karoy Lorentey
4b2ab698ea Merge pull request #14131 from lorentey/warnings3
[stdlib] Silence deprecation warnings about CharacterView in stdlib
2018-01-25 00:13:34 +00:00
Karoy Lorentey
1c88937cf4 Merge pull request #14127 from lorentey/warnings2
[stdlib] Add a return value to _UIntBuffer.removeFirst()
2018-01-24 21:47:38 +00:00
Karoy Lorentey
e6afe829a1 [stdlib] Silence deprecation warnings about CharacterView in stdlib
- Rename `Substring.CharacterView` to `Substring._CharacterView`, adding a deprecated typealias for the original name, like we do for `String.CharacterView`.
- Add a non-deprecated `Substring._characters` property, emulating `String.characters`.
- Explicitly deprecate the following members:
    * String.withMutableCharacters<R>(_: (inout CharacterView) -> R) -> R
    * String.subscript(Range<Index>) -> String.CharacterView
    * Substring._CharacterView.subscript(Range<Index>) -> Substring.CharacterView
    * Substring.init(_: CharacterView)
    * String.init(_: Substring.CharacterView)
2018-01-24 21:16:48 +00:00
Karoy Lorentey
39bf3a2e85 [stdlib] Fix _UIntBuffer.removeFirst() to match RangeReplaceableCollection requirement. 2018-01-24 16:44:18 +00:00
Michael Ilseman
b8a870300c Merge pull request #14118 from milseman/hash_hack_attack
[string] ARC hack around hashValue
2018-01-24 08:16:38 -08:00
Karoy Lorentey
92a2f9cb8f Merge pull request #14027 from lorentey/rdar/36619317
[stdlib] Set, Dictionary: Take the max load factor into account in `.init(minimumCapacity:)`
2018-01-24 11:31:17 +00:00
Michael Ilseman
ccdba811f1 Merge pull request #14117 from milseman/sanitime_runty
[string] sanity check for runtime size
2018-01-23 23:06:31 -08:00
Michael Ilseman
436475fb99 [string] ARC hack around hashValue
Avoid a source of ARC for hashValue, which is perf-sensitive
especially for hashed collection growth.

This improves the Dictionary benchmark by around 30%.
2018-01-23 21:43:17 -08:00
Michael Ilseman
5b716bd4bc [string] sanity check for runtime size 2018-01-23 20:24:42 -08:00
Nate Cook
5afeecb246 [stdlib] Remove MutableCollection.sorted methods (#14005)
* [stdlib] Remove MutableCollection.sorted methods

This removes the implementations of sorted() and sorted(by:) on Mutable-
Collection, which only changed some minor wording in the docs.

This also adds documentation to the partition(by:) implementations so that
they will appear downstream.

* [stdlib] De-gyb CollectionAlgorithms.swift

* Update tests for MutableCollection.sorted() changes
2018-01-23 14:17:32 -08:00
Michael Ilseman
f3c691f019 Merge pull request #14077 from milseman/arc_bridge
[string] Hack around more ARC.
2018-01-23 09:40:29 -08:00
Karoy Lorentey
de2add8047 [stdlib] Set, Dictionary terminology: Distinguish capacity from bucket count.
"Capacity" in the public Set/Dictionary API means the maximum number of items that a collection instance may hold without reallocation. In implementation details, the same word was also used for the capacity of the underlying storage buffer, which is usually higher due to the maximum load factor.

Having the same name for two different values has led to bugs where the logical/effective capacity is passed directly to a function expecting the raw storage capacity, or vice versa. This change updates internal names to clearly distinguish between the two senses, introducing "bucketCount" as the name for the storage buffer capacity, and reserving "capacity" for the maximum logical item count.
2018-01-23 17:22:31 +00:00
swift-ci
16c93f834c Merge pull request #14076 from lattner/fastar-print 2018-01-23 00:06:31 -08:00
Michael Ilseman
ef926c9031 [string] Hack around more ARC.
Utilize pre-existing CFStringGetLength hack. Gives about 20%
performance improvement bridging in contiguous NSStrings from
ObjectiveC.
2018-01-22 21:29:39 -08:00
Michael Ilseman
51c560f74c Merge pull request #14052 from milseman/ascii_view
[string] Hoist UTF8View fast-path for known ASCII
2018-01-22 21:11:06 -08:00
Chris Lattner
1287d62f8f Stop pessimizing print performance for no reason.
As pointed out in Ole Begeman's blog:
https://oleb.net/blog/2016/09/playground-print-hook/

The playground print hook is being initialized a a non-null noop hook,
which causes the fast paths in the print functions to be unused, and
forcing the creation of a tee stream for things that have nothing to
do with playgrounds.  It is sad that no one noticed this...
2018-01-22 19:56:37 -08:00
Mishal Shah
dc0be0e0da Merge pull request #14060 from milseman/vacuous_singleton
[string] Workaround fail emptySingleton check.
2018-01-22 12:27:27 -08:00