Commit Graph

13406 Commits

Author SHA1 Message Date
Karoy Lorentey
21d31ea6d9 [Foundation] _Bridged[Stored]NSError: Remove explicit impls for hashValue/_rawHashValue
The compiler-synthesized / stdlib-provided default implementations seem perfectly fine for these.
2018-12-10 13:00:57 +00:00
Karoy Lorentey
bbaec3d8bd [Foundation] Update hashing for bridged Error/NSError types
Protocols in resilient libraries that wish to provide a default implementation of hashing need to do so by providing a hash(into:) implementation.

hashValue has been deprecated as a Hashable requirement in SE-0206. Implementing only it in a protocol extension curses conforming types to get deprecation warnings by default.
2018-12-10 13:00:56 +00:00
Jon Shier
c739498c9b Remove usage lines from docs. 2018-12-09 19:20:49 -05:00
Jon Shier
e4a700c32d Update inline documentation. 2018-12-09 19:08:41 -05:00
Michael Gottesman
089e3a8ecd [cmake] tools/swift-reflection-test => stdlib/tools/swift-reflection-test.
If one thinks about it, swift's build has two sections: a runtime or target
section (i.e. ./stdlib) and a host section (everything
else). swift-reflection-test is an abberation from that pattern since it is
built for target platforms but is in the section of host tools.

In this commit, I move it into ./stdlib. Beyond being a bitter location
conceptually this will additionally allow me to avoid a dependency cycle in
between the compiler and the stdlib build.

After this, there is only one more target in the compiler code: swift-lang. From
talking with Xi Ge, we can move that into its own separate project as a
package. Once that is done, I will not have any more cycles.
2018-12-09 02:20:33 -08:00
Slava Pestov
929bf610e0 Runtime: Fix demangling of function with single tuple-typed argument
While declaration mangling now does the right thing for parameter lists,
the function type mangling unfortunately still models the parameter list
as a single tuple node.

Change the runtime's behavior to match the AST mangler, which wraps
a single tuple-typed parameter in a tuple node, so that we can produce
different mangling trees for function types taking multiple arguments
versus a single tuple argument.
2018-12-08 23:57:21 -05:00
Pitiphong Phongpattranont
a75d98f68c Refactor the looking for existing container code and change the error message on the condition 2018-12-08 13:39:40 +07:00
Pitiphong Phongpattranont
d61830b266 Change the tab character to be space for the wrong indentation 2018-12-08 13:39:39 +07:00
Pitiphong Phongpattranont
80056e2fb9 Fixed the wrong indentation due to the GitHub editor 2018-12-08 13:39:39 +07:00
Pitiphong Phongpattranont
c7a2b31cd2 Fixed the wrong indentation 2018-12-08 13:39:39 +07:00
Pitiphong Phongpattranont
9a3038d3f0 Precondition for the mismatch container type when requesing for the nested container with the same key 2018-12-08 13:39:38 +07:00
Pitiphong Phongpattranont
1750e04186 Look up and reuse the container when asking for the nested container with the same key in PlistEncoder 2018-12-08 13:39:38 +07:00
Pitiphong Phongpattranont
32ef8773a2 Look up and reuse the container when asking for the nested container with the same key in JSONEncoder 2018-12-08 13:39:38 +07:00
Joe Groff
b2ceb4b753 Merge pull request #21102 from jckarter/unconditional-cast-source-loc-abi
Runtime: Provide ABI space for source location info in unconditional casts.
2018-12-07 19:04:59 -08:00
Ben Cohen
11769d2494 Add tests for withContiguousStorageIfAvailable 2018-12-07 17:30:13 -08:00
Bob Wilson
d24bb36aab Merge pull request #21119 from mikeash/existential-metatype-metadata-cast-fix
[Runtime] Fix incorrect cast in NonFixedExistentialMetatypeBox::Container::getNumWitnessTables.
2018-12-07 15:20:07 -08:00
Greg Parker
368ca184fa [runtime] Fix some bugs when the stable ABI's is-Swift bit is set. (#21114)
* cmake: Propagate SWIFT_DARWIN_ENABLE_STABLE_ABI_BIT to overlay builds.
* runtime: Clear the correct bit in getROData()
* test/IRGen/objc_class_export.swift: Allow either is-Swift bit.
* test/stdlib/SwiftObjectNSObject.swift: Allow either name for SwiftObject.
2018-12-07 12:47:39 -08:00
Max Moiseev
290e9025fa Merge pull request #21118 from benrimmington/remove-interval-group-info
[stdlib] Remove Interval.swift from GroupInfo.json
2018-12-07 11:16:55 -08:00
Ben Cohen
ad50a39b12 [stdlib] Add withContiguous{Mutable}StorageIfAvailable (#21092)
* Add MutableCollection.withContiguousMutableStorageIfAvailable

* Add withContiguousMutableStorageIfAvailable impls

* Add tests on concrete types

* Add Sequence.withContiguousStorageIfAvailable

* Implement withContiguousStorageIfAvailable in concrete types
2018-12-07 10:01:18 -08:00
Karoy Lorentey
b77351548a Merge pull request #21045 from lorentey/modify-vs-throw
[stdlib] Dictionary: Support throwing yields in _modify accessors
2018-12-07 17:08:42 +00:00
Mike Ash
2114ce011e [Runtime] Fix incorrect cast in NonFixedExistentialMetatypeBox::Container::getNumWitnessTables.
The incorrect cast led to absurd values for getNumWitnessTables which then caused crashes (or worse?) down the line.

SR-8158 rdar://problem/41725205
2018-12-07 09:51:12 -05:00
Ben Rimmington
4e667cb97b [stdlib] Remove Interval.swift from GroupInfo.json 2018-12-07 12:39:36 +00:00
Saleem Abdulrasool
6e7051eb1e Merge pull request #20944 from compnerd/os-family
stdlib: restructure for OS family layout of SDK overlay
2018-12-06 18:22:51 -08:00
Max Moiseev
51b9c52c23 Merge pull request #21097 from moiseev/test-error
Make an StdlibUnitTest error message a bit more useful
2018-12-06 16:40:14 -08:00
Joe Groff
bce1f5ef4a Runtime: Provide ABI space for source location info in unconditional casts.
Currently ignored, but this will allow future compilers to pass down source location information for cast
failure runtime errors without backward deployment constraints.
2018-12-06 14:58:14 -08:00
Maxim Moiseev
ebf90f78be Make an StdlibUnitTest error message a bit more useful 2018-12-06 14:11:57 -08:00
swift-ci
9596624981 Merge pull request #21082 from compnerd/house-of-cards 2018-12-06 12:46:33 -08:00
swift-ci
80abe8ca2f Merge pull request #21044 from mikeash/anyhashable-to-enum-fix 2018-12-06 12:31:45 -08:00
Saleem Abdulrasool
41d9c2cc59 stdlib: restructure for OS family layout of SDK overlay
The SDK directory is now confusing as the Windows target also has a SDK
overlay.  In order to make this more uniform, move the SDK directory to
Darwin which covers the fact that this covers the XNU family of OSes.
The Windows directory contains the SDK overlay for the Windows target.
2018-12-06 11:32:05 -08:00
Saleem Abdulrasool
547701f7f3 build: repair the windows cross-compilation
The SIMDOperators module was being added prior to SwiftOnoneSupport, which
resulted in the import library target for Windows not being setup prior to use.
As a result, we would link against the DLL rather than the import library which
is not supported (except as a MinGW hack in the binutils linker).  Re-order the
registration to ensure that the target is setup already.
2018-12-06 10:04:33 -08:00
Michael Ilseman
8863a5514c Merge pull request #21024 from milseman/fass_and_smol
[String] In-register comparison of small ASCII strings
2018-12-06 09:01:37 -08:00
Michael Ilseman
4394ce1a23 Merge pull request #21072 from milseman/i_dem_potent
[String] String-from-whole-Substring fast-path.
2018-12-06 09:01:12 -08:00
Doug Gregor
00d2acd809 Merge pull request #21037 from DougGregor/flatten-abs
[ABI] [stdlib] Remove magnitude-based overload of abs(_:).
2018-12-06 08:36:24 -08:00
Mike Ash
6f7143bfaf [Runtime] Allow casts from AnyHashable to a Hashable enum to succeed.
rdar://problem/46472361
2018-12-06 10:33:35 -05:00
Karoy Lorentey
549926337c Merge pull request #20967 from lorentey/aump-read
[stdlib] AutoreleasingUnsafeMutablePointer: Switch subscripts to _read accessors
2018-12-06 15:13:09 +00:00
sarveshtamba
7dbda7847d Updating Change 'isValidPointerForNativeRetain' check for PowerPC(ppc64le) 2018-12-06 11:43:25 +00:00
Doug Gregor
ab75577079 [stdlib] Teach abs(_:) to use magnitude when it can.
Within the (single) implementation of abs(_:), dynamically check whether
the numeric type and its `Magnitude` are of the same type and, if so,
return the result of `magnitude`. This ensures that we do the right thing
with respect to (e.g.) floating point values like -0.0, without resorting
to overloading of abs(_:).
2018-12-05 21:05:52 -08:00
Jon Shier
2bc4cbbfdd Update for revised proposal. 2018-12-05 23:17:35 -05:00
Michael Ilseman
255c17aeb6 [String] String-from-whole-Substring fast-path.
Add in a fast-path for Strings created from Substring which covers the
entire String. Put String-from-Substring behind a non-inlinable
resilience barrier for future flexibility.
2018-12-05 18:22:47 -08:00
Michael Ilseman
b08d94d6ba [String] In-register smol ASCII string compare
Compare small strings in-register when they store ASCII (and thus NFC)
contents.
2018-12-05 18:16:46 -08:00
Karoy Lorentey
1485404532 [stdlib] Document that hashValue is deprecated 2018-12-05 19:00:35 +00:00
adrian-prantl
bf2a4712ec Merge pull request #21017 from adrian-prantl/debrief
Remove \brief commands from doxygen comments.
2018-12-05 10:40:53 -08:00
Karoy Lorentey
ce96f1e528 [stdlib] _modify: Use defer to ensure invariants are restored when yield throws
_modify mustn’t leave Collection storage in an inconsistent state when the code to which we’re yielding happens to throw. In practice this means that any cleanup code must happen in defer blocks before the yield.

Fix Dictionary to do just that and add tests to cover this functionality (as well as some other aspects of _modify).
2018-12-05 17:35:24 +00:00
sarveshtamba
2fbdf74df2 Change 'isValidPointerForNativeRetain' check for PowerPC(ppc64le) 2018-12-05 07:22:03 +00:00
Doug Gregor
85d488d461 [stdlib] Remove magnitude-based overload of abs(_:).
The standard library has two versions of the `abs(_:)` function:

```
func abs<T : SignedNumeric>(_ x: T) -> T where T.Magnitude == T
func abs<T : SignedNumeric & Comparable>(_ x: T) -> T
```

The first is more specialized than the second because `T.Magnitude` is
known to conform to `Comparable`. Indeed, it’s a more specialized
implementation that returns `magnitude`.

However, this overload behaves oddly: in the expression `abs(-8)`, the type
checker will pick the first overload because it is more specialized. That’s
a general guiding principle for overloading: pick the most specialized
overload that works.

However, to select that overload, it needs to pick a type for the literal
“8” for which that overload works, and it chooses `Double`. The “obvious”
answer, `Int`, doesn’t work because `Int.Magnitude == UInt`.

There is a conflict between the two rules, here: we prefer more-specialized
overloads (but we’ll fall back to less-specialized if those don’t work) and we prefer to use `Int` for integer literals (but we’ll fall back to `Double` if it doesn’t work). We have a few options from a type-checker
perspective:

1. Consider the more-specialized-function rule to be more important
2. Consider the integer-literals-prefer-`Int` rule to be more important
3. Call the result ambiguous and make the user annotate it

The type checker currently does #1, although at some point in the past it
did #2. Moving forward, #1 is a better choice because it prunes the number
of overloads that need to be considered: if the more-specialized overload
succeeds its type-check, the others need not be considered. It’s also
easier to reason about than the literal-scoring approach, because there can
be a direct definition for “more specialized than” that can be reasoned
about.

I think we should dodge the issue by removing the more-specialized version
of `abs(_:)`. Its use of `magnitude` seems unlikely to provide a
significant performance benefit, and the presence of overloading either
forces us to consider both overloads always (which is bad for type checker
performance) or accept the regression that `abs(-8)` is `Double`. Better
to eliminate the overloading and, if needed in the future, find a better
way to introduce the more-specialized implementation without it being a
separate signature.

Fixes rdar://problem/42345366.
2018-12-04 23:10:04 -08:00
Ben Cohen
fc7830a4ed Remove Swift 3-only Compatibility Shims (#21019) 2018-12-04 18:22:27 -08:00
Adrian Prantl
ff63eaea6f Remove \brief commands from doxygen comments.
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.

Patch produced by

      for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
2018-12-04 15:45:04 -08:00
Bob Wilson
8e38173884 Merge pull request #21008 from mikeash/keypath-allocation-overflow-fix
[Stdlib] Ensure key paths allocate space for the terminating NUL.
2018-12-04 15:01:37 -08:00
Michael Ilseman
3e8b015afe Merge pull request #20983 from milseman/comparison_reform
[String] Comparison Speedups
2018-12-04 14:53:45 -08:00
John McCall
9379e19748 Merge pull request #21000 from rjmccall/arm64-tbi-future-proofing
Future-proof the ARM64 ABI by not reserving the entire top byte
2018-12-04 16:24:54 -05:00