From 7fc2179c3109f8931c9070380d0463e5ab29efb5 Mon Sep 17 00:00:00 2001 From: Allan Shortlidge Date: Fri, 26 Apr 2024 16:32:29 -0700 Subject: [PATCH] stdlib: Fix more typed throws and non-copyable generics condfails. There were two categories of problem for older compilers that consume the stdlib `.swiftinterface`: - The `case .some(borrowing x)` syntax isn't accepted; use `_borrowing` - Various functions that addopted `~Copyable` generic constraints conflict with the `@usableFromInline` ABI stubs that were left in to preserve compatibility when the functions are printed with `~Copyable` constraints stripped. The stubs need to have different names to get out of the way. Resolves rdar://127132742 --- stdlib/public/core/LifetimeManager.swift | 6 ++++-- stdlib/public/core/Optional.swift | 4 ++-- stdlib/public/core/Result.swift | 8 +++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/stdlib/public/core/LifetimeManager.swift b/stdlib/public/core/LifetimeManager.swift index 5ff5fea99e088..50ce40a424f0c 100644 --- a/stdlib/public/core/LifetimeManager.swift +++ b/stdlib/public/core/LifetimeManager.swift @@ -29,8 +29,9 @@ public func withExtendedLifetime( } @_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 1) +@_silgen_name("$ss20withExtendedLifetimeyq_x_q_yKXEtKr0_lF") @usableFromInline -internal func withExtendedLifetime( +internal func __abi_withExtendedLifetime( _ x: T, _ body: () throws -> Result // FIXME: Typed throws rdar://126576356 ) rethrows -> Result { @@ -56,8 +57,9 @@ public func withExtendedLifetime( } @_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 1) +@_silgen_name("$ss20withExtendedLifetimeyq_x_q_xKXEtKr0_lF") @usableFromInline -internal func withExtendedLifetime( +internal func __abi_withExtendedLifetime( _ x: T, _ body: (T) throws -> Result // FIXME: Typed throws rdar://126576356 ) rethrows -> Result { defer { _fixLifetime(x) } diff --git a/stdlib/public/core/Optional.swift b/stdlib/public/core/Optional.swift index 361da5c19c823..7b9312c2a9c67 100644 --- a/stdlib/public/core/Optional.swift +++ b/stdlib/public/core/Optional.swift @@ -235,7 +235,7 @@ extension Optional where Wrapped: ~Copyable { ) throws(E) -> U? { #if $NoncopyableGenerics switch self { - case .some(borrowing y): + case .some(_borrowing y): return .some(try transform(y)) case .none: return .none @@ -316,7 +316,7 @@ extension Optional where Wrapped: ~Copyable { _ transform: (borrowing Wrapped) throws(E) -> U? ) throws(E) -> U? { switch self { - case .some(borrowing y): + case .some(_borrowing y): return try transform(y) case .none: return .none diff --git a/stdlib/public/core/Result.swift b/stdlib/public/core/Result.swift index 9ddbdb59f316e..0c1dd43eeae01 100644 --- a/stdlib/public/core/Result.swift +++ b/stdlib/public/core/Result.swift @@ -64,8 +64,9 @@ extension Result { } @_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 1) + @_silgen_name("$ss6ResultO3mapyAByqd__q_Gqd__xXElF") @usableFromInline - internal func map( + internal func __abi_map( _ transform: (Success) -> NewSuccess ) -> Result { switch self { @@ -205,8 +206,9 @@ extension Result { } @_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 1) + @_silgen_name("$ss6ResultO7flatMapyAByqd__q_GADxXElF") @usableFromInline - internal func flatMap( + internal func __abi_flatMap( _ transform: (Success) -> Result ) -> Result { switch self { @@ -272,7 +274,7 @@ extension Result { @_spi(SwiftStdlibLegacyABI) @available(swift, obsoleted: 1) @_silgen_name("$ss6ResultO12flatMapErroryAByxqd__GADq_XEs0D0Rd__lF") @usableFromInline - internal func flatMapError( + internal func __abi_flatMapError( _ transform: (Failure) -> Result ) -> Result { switch self {