Commit Graph

448 Commits

Author SHA1 Message Date
Andrew Trick 247a258518 Merge pull request #84701 from atrick/rawpointer-nonescapable
[stdlib] ~Escapable raw pointer access: API adoption in URP, UMRP, URBP, UMRBP
2026-05-02 13:11:40 -07:00
Andrew Trick 9ffe1ed933 Update stability-stdlib-source-base.swift.expected
~Escapable adoption:
URP.load, UMRP.load, withUnsafeBytes, withUnsafeMutableBytes
2026-05-01 10:18:15 -07:00
Guillaume Lessard 2861d9e097 Merge pull request #88640 from glessard/rdar139816157-FullyInhabited-protocols 2026-05-01 10:07:53 -07:00
Clinton Nkwocha 973d04d980 Revert "Reapply #87697 and fix overload resolution for Sequence+AsyncSequence types. (#88442)" (#88713)
<!--
The main branch is now in convergence, which means major changes, such
as large refactoring or new features, should be avoided. This strategy
is intended to maintain the stability of the Swift 6.4 release leading
up to the May 4th branch. For any work that requires broad changes or
introduces new features, create a feature branch and open a draft pull
request. All updates to the swiftlang/swift repository’s main branch
require approval from the release managers. A pull request targeting
swiftlang/swift will automatically add release managers. You can also
contact them via @release-managers in the forum group.
-->

<!-- Please fill out the following form: --> 
- **Explanation**: This reverts commit
5ece334724 which aimed to generalize
Sequence methods for typed throws and resolve its side effects on
overload resolution when a type conforms to both Sequence and
AsyncSequence. There appears to be, at least, one more unanticipated
side-effect, hence this pre-emptive revert in view of the soon-to-be
Swift 6.4 release branching.
  <!--
A description of the changes. This can be brief, but it should be clear.
  -->
- **Scope**: The said commit is reverted, preserving the recent
~Copyable/consuming alterations to Sequence.reduce(\_:\_:) (#85716).
  <!--
An assessment of the impact and importance of the changes. For example,
can
  the changes break existing code?
  -->
- **Issues**: Under investigation 
  <!--
  References to issues the changes resolve, if any.
  -->
- **Risk**: Low
  <!--
  The (specific) risk to the release for taking the changes.
  -->
- **Testing**: None
  <!--
  The specific testing that has been done or needs to be done to further
  validate any impact of the changes.
  -->

<!--
Before merging this pull request, you must run the Swift continuous
integration tests.
For information about triggering CI builds via @swift-ci, see:

https://github.com/apple/swift/blob/main/docs/ContinuousIntegration.md#swift-ci

Thank you for your contribution to Swift!
-->
2026-04-30 16:01:48 +01:00
Alejandro Alonso 389a6499f4 Merge pull request #86039 from airspeedswift/nonescapable-hashable
Allow Hashable: ~Escapable
2026-04-28 10:31:35 -07:00
Guillaume Lessard 5c86698290 [test] acknowledge api and abi changes 2026-04-22 15:55:04 -07:00
Alejandro Alonso 345b12277e Fix some tests since typed throws adoption 2026-04-21 14:30:03 -07:00
Ben Cohen 8832c55107 Change reduce to take initial and partial value consuming 2026-04-21 12:57:39 -07:00
Clinton Nkwocha 5ece334724 Reapply #87698 and fix overload resolution for Sequence+AsyncSequence types. (#88442)
Since generalizing Sequence methods for typed throws, overload
resolution in an async context prefers the corresponding AsyncSequence
methods which cannot be generalized yet. To fix this, all rethrowing
Sequence methods (except withContiguousStorageIfAvailable) are now
duplicated in a new extension (`extension AsyncSequence where Self:
Sequence`).

_See also: #88221_
2026-04-17 12:28:03 +01:00
Clinton Nkwocha 8a51f7a706 Revert "[stdlib] Generalize Sequence algorithms for typed throws (#87698)" (#88269)
This reverts commit f2798f8ff4.
2026-04-03 10:36:31 +01:00
Guillaume Lessard 167887af40 Merge pull request #88047 from glessard/deduplicate-optional-init
[stdlib] merge two initializers of Optional
2026-03-24 10:46:38 -07:00
Guillaume Lessard d5afae8716 [test] adjust api digester lists 2026-03-23 22:52:46 -07:00
Clinton Nkwocha f2798f8ff4 [stdlib] Generalize Sequence algorithms for typed throws (#87698)
Generalizes the following `Sequence` methods for typed throws:
`min(by:)`, `max(by:)`, `starts(with:by:)`, `elementsEqual(_:by:)`,
`lexicographicallyPrecedes(_:by:)`, `contains(where:)`,
`allSatisfy(_:)`, `reduce(_:_:)`, `reduce(into:_:)`, `flatMap(_:)`,
`compactMap(_:)`.
2026-03-17 07:32:33 +00:00
Clinton Nkwocha 2385488c84 Generalize String functions for typed throws (#87495)
Generalizes `String`:
- `init(unsafeUninitializedCapacity:initializingUTF8With:)`
- `withCString(_:)`
- `withCString(encodedAs:_:)`
- `withUTF8(_:)`
- `_withNFCCodeUnits(_:)`

and `Substring`:
  - `withCString(_:)`
  - `withCString(encodedAs:_:)`
  - `withUTF8(_:)`

for typed throws.
2026-03-10 11:27:06 +00:00
Allan Shortlidge bf1edd6a87 APIDigester: Add support for anyAppleOS availability.
Resolves rdar://170663253.
2026-03-05 06:27:34 -08:00
Alex Hoppen 80abc59471 Merge pull request #87020 from glessard/filter-closures-typed-throws
[stdlib] Generalize the `filter(_:)` functions for typed throws
2026-02-13 18:08:50 +01:00
Clinton Nkwocha 2e8977fe5c [stdlib] Typed Throws Adoption for Several Dictionary APIs (#86894)
Adopts typed throws for several Dictionary APIs: mapValues, merge,
merging and init.

---------

Co-authored-by: Guillaume Lessard <guillaume.lessard@apple.com>
2026-02-10 11:47:33 +00:00
Guillaume Lessard 5249cd1437 [test] acknowledge differences to api-digester 2026-02-09 14:43:25 -08:00
Ben Cohen 5ac2d2497a Allow Comparable: ~Escapable (#85891)
Builds on #85854
2025-12-16 10:17:58 -08:00
Ben Cohen 512d5efd55 Allow Hashable: ~Escapable 2025-12-14 16:39:26 -08:00
Ben Cohen 9dd9e96e1d Allow Hashable: ~Copyable (#85748)
Builds on #85746 which covers Equatable.
2025-12-11 14:47:36 -08:00
Ben Cohen 58f661cfba Allow Equatable: ~Escapable (#85854)
Adds `~Escapable` to #85746
2025-12-08 09:50:50 -08:00
Ben Cohen 0f99458900 Allow Comparable: ~Copyable (#85747)
Builds on #85746 which covers Equatable
2025-12-05 08:37:36 -08:00
Ben Cohen fbb420f38d Allow Equatable: ~Copyable (#85746)
Under review
[here](https://forums.swift.org/t/se-0499-support-copyable-escapable-in-simple-standard-library-protocols/83297).
Multi-part version of #85079.
2025-12-03 05:45:38 -08:00
Anthony Latsis e101d0aa58 APIDigester: Sort conformances when dumping sdk
See https://github.com/swiftlang/swift/pull/84193 for context.
2025-09-12 14:28:34 +01:00
Guillaume Lessard adae6a4b73 [test] acknowledge source-compatible API changes 2025-07-25 09:29:25 -07:00
Guillaume Lessard 401eef5472 [test] adjust api-digester data 2025-06-06 08:21:49 -07:00
Anthony Latsis 1d6ed11e46 AST: Quote attributes more consistently in DiagnosticsModuleDiffer.def 2025-04-22 18:23:40 +01:00
Guillaume Lessard ee50c3ec3a [test] amend api digester exceptions 2025-04-14 10:48:42 -07:00
Karoy Lorentey 192b404947 [stdlib] Work around ~Escapable breaking Optional.init syntax 2025-03-24 12:16:19 -07:00
Karoy Lorentey 21169d12e8 Reinstate generalization of Optional.unsafelyUnwrapped 2025-03-24 12:16:16 -07:00
Karoy Lorentey 6ead0d8cd6 [stdlib] Postpone generalizing Result.flatMapError 2025-03-24 12:16:13 -07:00
Karoy Lorentey c2d33b4f71 [stdlib] Take out generalization of Optional.unsafelyUnwrapped for now 2025-03-24 12:16:08 -07:00
Karoy Lorentey 801385ad49 [stdlib] Generalize the signature of type(of:)
`func type(of:)` is wholly magical, but it does have a signature in the stdlib (mostly for documentation purposes), and it currently requires its input to be copyable and escapable.

`type(of:)` is actually usable on all entities, so it seems desirable to update its signature to reflect this.

Additionally, this seems like a good time to mark its exported symbol obsolete. I don’t expect anyone would ever link to it (unless there is/was a bug), so in theory we could also silently remove it — but explicitly marking it as legacy ABI seems the least risky option.
2025-03-24 12:16:06 -07:00
Karoy Lorentey 7cd98c31d4 [test] Update stability expectations 2025-03-24 12:16:04 -07:00
Karoy Lorentey 538f2742ef [stdlib] Roll back generalization of the nil-coalescing operator ??
We cannot currently express its proper lifetime semantics: its result’s lifetime should depend on the intersection of the lifetime of the left argument and the lifetime of the result of the right argument.

`@lifetime(optional, defaultValue.result)` is what we want, but the `.result` part is not currently expressible. (Tying the dependency on the closure argument itself may be a viable option, but we aren’t confident enough to ship it like that yet.)
2025-03-24 12:16:01 -07:00
Karoy Lorentey 989ea16a0d [test] api-digester: Add false positives for newly generalized properties 2025-03-24 12:15:59 -07:00
Karoy Lorentey b41d6aa63a [test] Ritually confess these changes 2025-03-24 12:15:53 -07:00
Guillaume Lessard 063b0581e3 [test] ritual acts of contrition 2025-03-10 08:54:07 -07:00
Doug Gregor e24598bca1 Use a marker protocol SendableMetatype to model T.Type: Sendable
Introduce a marker protocol SendableMetatype that is used to indicate
when the metatype of a type will conform to Sendable. Specifically,
`T: SendableMetatype` implies `T.Type: Sendable`. When strict
metatype sendability is enabled, metatypes are only sendable when `T:
SendableMetatype`.

All nominal types implicitly conform to `SendableMetatype`, as do the
various builtin types, function types, etc. The `Sendable` marker
protocol now inherits from `SendableMetatype`, so that `T: Sendable`
implies `T.Type: Sendable`.

Thank you Slava for the excellent idea!
2025-02-13 22:48:05 -08:00
Doug Gregor 88b28c3ff0 Update stdlib API stability now that @unsafe addition isn't considered "breaking" 2025-01-23 07:47:20 -08:00
Doug Gregor 62d8659b15 Update API/ABI stability checker output for correctly-printed ''rethrows'
We used to treat 'rethrows' like an attribute, printing it as
'@rethrows', which was incorrect. That's fixed now, so update the
API/ABI checker tests to account for that.
2024-12-15 08:21:10 -08:00
Hamish Knight 289092b9ec [api-digester] Avoid modeling ParenType
This isn't a useful node to record.
2024-10-24 15:13:06 +01:00
Doug Gregor af49172b55 Mark Range.init(uncheckedBounds:) and ClosedRange.init(uncheckedBounds:) as @unsafe 2024-09-30 15:20:36 -07:00
Mike Ash 3937ceecc7 [Stdlib] Mark CVaListPointer as @unsafe.
rdar://135604375
2024-09-10 14:49:38 -04:00
Doug Gregor 5412a8a04c Move baseline updates over to the architecture-independent file 2024-08-19 22:14:09 -07:00
Doug Gregor 7e831f248b Update API test for addition of @unsafe 2024-08-19 14:33:58 -07:00
Doug Gregor 2e9ab88c4a Genereralize standard library ABI stability test for arm64 macOS
... and now that it is fixed for the platform I'm developing odd, add the
missing entries for typed throws on withUnsafe(Mutable)BufferPointer.
2024-08-16 21:28:30 -07:00
Doug Gregor 25bb3110aa Enable API stability checking for standard library on arm64
This test was only enabled for x86_64.
2024-08-16 13:04:03 -07:00
Kavon Farvardin 545844ce8f ASTPrinter: fix nested signatures with inverses
A generic signature's `getInnermostGenericParams` will find the generic
parameters in the innermost scope. That's not quite right for printing
inverses, since we don't want to print an inverse for `T` when emitting
the generic signature of `f` below:

```swift
    struct S<T: ~Copyable, E> {
        func f() where E == Never {}
    }
```

Since `f` has its own generic signature, but doesn't define any generic
parameters, it shouldn't have an inverse emitted. The solution here is
to filter inverses by depth of the generic parameter.

We also want to print _all_ of the inverses in other situations, rather
than just the innermost ones. This aids in debugging and other
tools like the API digester.

resolves rdar://130179698
2024-06-25 12:06:23 -07:00