From 1ce79a695e5c62ca6360272f999a50426935b0fd Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Thu, 4 Jul 2024 10:37:23 -0700 Subject: [PATCH] Unimplemented improvements (#86) * Use parameter pack in place of generic arguments with limit of 5 * Fix test assertion providing proper argument of invocation * wip * wip * wip --------- Co-authored-by: AgapovOne --- .../{ => Articles}/GettingStarted.md | 0 .../Extensions/Deprecations.md | 22 + .../Extensions/Unimplemented.md | 7 + .../Extensions/UnimplementedPlaceholder.md | 12 + .../Extensions/XCTExpectFailure.md | 7 + .../Documentation.docc/Extensions/XCTFail.md | 11 + .../Documentation.docc/Unimplemented.md | 25 - .../UnimplementedPlaceholder.md | 35 - .../Documentation.docc/XCTUnimplemented.md | 21 - .../XCTUnimplementedPlaceholder.md | 29 - .../XCTestDynamicOverlay.md | 12 +- .../Internal/Deprecations.swift | 555 ++---- .../Internal/GeneratePlaceholder.swift | 71 - .../XCTestDynamicOverlay/Unimplemented.swift | 1495 +---------------- .../GeneratePlaceholderTests.swift | 1 + .../TestHelpers.swift | 2 + .../UnimplementedTests.swift | 15 +- 17 files changed, 276 insertions(+), 2044 deletions(-) rename Sources/XCTestDynamicOverlay/Documentation.docc/{ => Articles}/GettingStarted.md (100%) create mode 100644 Sources/XCTestDynamicOverlay/Documentation.docc/Extensions/Deprecations.md create mode 100644 Sources/XCTestDynamicOverlay/Documentation.docc/Extensions/Unimplemented.md create mode 100644 Sources/XCTestDynamicOverlay/Documentation.docc/Extensions/UnimplementedPlaceholder.md create mode 100644 Sources/XCTestDynamicOverlay/Documentation.docc/Extensions/XCTExpectFailure.md create mode 100644 Sources/XCTestDynamicOverlay/Documentation.docc/Extensions/XCTFail.md delete mode 100644 Sources/XCTestDynamicOverlay/Documentation.docc/Unimplemented.md delete mode 100644 Sources/XCTestDynamicOverlay/Documentation.docc/UnimplementedPlaceholder.md delete mode 100644 Sources/XCTestDynamicOverlay/Documentation.docc/XCTUnimplemented.md delete mode 100644 Sources/XCTestDynamicOverlay/Documentation.docc/XCTUnimplementedPlaceholder.md delete mode 100644 Sources/XCTestDynamicOverlay/Internal/GeneratePlaceholder.swift diff --git a/Sources/XCTestDynamicOverlay/Documentation.docc/GettingStarted.md b/Sources/XCTestDynamicOverlay/Documentation.docc/Articles/GettingStarted.md similarity index 100% rename from Sources/XCTestDynamicOverlay/Documentation.docc/GettingStarted.md rename to Sources/XCTestDynamicOverlay/Documentation.docc/Articles/GettingStarted.md diff --git a/Sources/XCTestDynamicOverlay/Documentation.docc/Extensions/Deprecations.md b/Sources/XCTestDynamicOverlay/Documentation.docc/Extensions/Deprecations.md new file mode 100644 index 00000000..c1bad779 --- /dev/null +++ b/Sources/XCTestDynamicOverlay/Documentation.docc/Extensions/Deprecations.md @@ -0,0 +1,22 @@ +# Deprecations + +Review unsupported APIs and their replacements. + +## Overview + +Avoid using deprecated APIs in your app. + +## Topics + +### Unimplemented dependencies + +- ``unimplemented(_:file:fileID:line:)-7w4sd`` +- ``unimplemented(_:file:fileID:line:)-dh05`` +- ``unimplemented(_:file:fileID:line:)-74vrh`` +- ``XCTUnimplemented(_:)-36h59`` +- ``XCTUnimplemented(_:)-8fvli`` +- ``XCTUnimplemented(_:file:line:)-7xjl4`` +- ``XCTUnimplemented(_:file:line:)-69z9t`` +- ``XCTUnimplemented(_:placeholder:)-9rrxn`` +- ``XCTUnimplemented(_:placeholder:)-71986`` +- ``XCTUnimplementedFailure`` diff --git a/Sources/XCTestDynamicOverlay/Documentation.docc/Extensions/Unimplemented.md b/Sources/XCTestDynamicOverlay/Documentation.docc/Extensions/Unimplemented.md new file mode 100644 index 00000000..cc2dd978 --- /dev/null +++ b/Sources/XCTestDynamicOverlay/Documentation.docc/Extensions/Unimplemented.md @@ -0,0 +1,7 @@ +# ``XCTestDynamicOverlay/unimplemented(_:fileID:line:)-7znj2`` + +## Topics + +### Overloads + +- ``XCTestDynamicOverlay/unimplemented(_:fileID:line:)-9kphk`` diff --git a/Sources/XCTestDynamicOverlay/Documentation.docc/Extensions/UnimplementedPlaceholder.md b/Sources/XCTestDynamicOverlay/Documentation.docc/Extensions/UnimplementedPlaceholder.md new file mode 100644 index 00000000..618b3054 --- /dev/null +++ b/Sources/XCTestDynamicOverlay/Documentation.docc/Extensions/UnimplementedPlaceholder.md @@ -0,0 +1,12 @@ +# ``XCTestDynamicOverlay/unimplemented(_:placeholder:fileID:line:)-70bno`` + +## Topics + +### Overloads + +- ``XCTestDynamicOverlay/unimplemented(_:placeholder:fileID:line:)-41gxp`` +- ``XCTestDynamicOverlay/unimplemented(_:placeholder:fileID:line:)-9tt2k`` + +### Failure + +- ``UnimplementedFailure`` diff --git a/Sources/XCTestDynamicOverlay/Documentation.docc/Extensions/XCTExpectFailure.md b/Sources/XCTestDynamicOverlay/Documentation.docc/Extensions/XCTExpectFailure.md new file mode 100644 index 00000000..e61eea12 --- /dev/null +++ b/Sources/XCTestDynamicOverlay/Documentation.docc/Extensions/XCTExpectFailure.md @@ -0,0 +1,7 @@ +# ``XCTestDynamicOverlay/XCTExpectFailure(_:enabled:strict:failingBlock:issueMatcher:)`` + +## Topics + +### Overloads + +- ``XCTExpectFailure(_:enabled:strict:issueMatcher:)`` diff --git a/Sources/XCTestDynamicOverlay/Documentation.docc/Extensions/XCTFail.md b/Sources/XCTestDynamicOverlay/Documentation.docc/Extensions/XCTFail.md new file mode 100644 index 00000000..c28f131d --- /dev/null +++ b/Sources/XCTestDynamicOverlay/Documentation.docc/Extensions/XCTFail.md @@ -0,0 +1,11 @@ +# ``XCTestDynamicOverlay/XCTFail(_:file:line:)`` + +## Topics + +### Overloads + +- ``XCTFail(_:)`` + +### Context + +- ``XCTFailContext`` diff --git a/Sources/XCTestDynamicOverlay/Documentation.docc/Unimplemented.md b/Sources/XCTestDynamicOverlay/Documentation.docc/Unimplemented.md deleted file mode 100644 index 7ce64720..00000000 --- a/Sources/XCTestDynamicOverlay/Documentation.docc/Unimplemented.md +++ /dev/null @@ -1,25 +0,0 @@ -# ``XCTestDynamicOverlay/unimplemented(_:fileID:line:)-5098a`` - -## Topics - -### Failure - -- ``UnimplementedFailure`` - -### Overloads - -- ``unimplemented(_:fileID:line:)-5po3t`` -- ``unimplemented(_:fileID:line:)-75xnz`` -- ``unimplemented(_:fileID:line:)-8czxo`` -- ``unimplemented(_:fileID:line:)-161a`` -- ``unimplemented(_:fileID:line:)-6cyz2`` -- ``unimplemented(_:fileID:line:)-5iwue`` -- ``unimplemented(_:fileID:line:)-3dnau`` -- ``unimplemented(_:fileID:line:)-2ndsd`` -- ``unimplemented(_:fileID:line:)-38aet`` -- ``unimplemented(_:fileID:line:)-9b7um`` -- ``unimplemented(_:fileID:line:)-85v19`` - -### Deprecations - -- ``XCTUnimplemented(_:)-3obl5`` diff --git a/Sources/XCTestDynamicOverlay/Documentation.docc/UnimplementedPlaceholder.md b/Sources/XCTestDynamicOverlay/Documentation.docc/UnimplementedPlaceholder.md deleted file mode 100644 index 306247f8..00000000 --- a/Sources/XCTestDynamicOverlay/Documentation.docc/UnimplementedPlaceholder.md +++ /dev/null @@ -1,35 +0,0 @@ -# ``XCTestDynamicOverlay/unimplemented(_:placeholder:fileID:line:)-7jrdo`` - -## Topics - -### Overloads - -- ``unimplemented(_:placeholder:fileID:line:)-9tt2k`` -- ``unimplemented(_:file:fileID:line:)-74vrh`` -- ``unimplemented(_:placeholder:fileID:line:)-63r9c`` -- ``unimplemented(_:file:fileID:line:)-7naoc`` -- ``unimplemented(_:placeholder:fileID:line:)-1d7ul`` -- ``unimplemented(_:file:fileID:line:)-dpc1`` -- ``unimplemented(_:file:fileID:line:)-4of0j`` -- ``unimplemented(_:placeholder:fileID:line:)-2l156`` -- ``unimplemented(_:file:fileID:line:)-3i70x`` -- ``unimplemented(_:placeholder:fileID:line:)-4l5m5`` -- ``unimplemented(_:file:fileID:line:)-53i23`` -- ``unimplemented(_:placeholder:fileID:line:)-29ki5`` -- ``unimplemented(_:file:fileID:line:)-8k8ag`` -- ``unimplemented(_:placeholder:fileID:line:)-1wuvu`` -- ``unimplemented(_:file:fileID:line:)-4ac84`` -- ``unimplemented(_:placeholder:fileID:line:)-5yn0z`` -- ``unimplemented(_:file:fileID:line:)-25iai`` -- ``unimplemented(_:placeholder:fileID:line:)-6zh67`` -- ``unimplemented(_:file:fileID:line:)-kf0z`` -- ``unimplemented(_:placeholder:fileID:line:)-1lxib`` -- ``unimplemented(_:file:fileID:line:)-226zs`` -- ``unimplemented(_:placeholder:fileID:line:)-jdwj`` -- ``unimplemented(_:file:fileID:line:)-33j2q`` -- ``unimplemented(_:placeholder:fileID:line:)-49o3h`` -- ``unimplemented(_:file:fileID:line:)-2c0df`` - -### Deprecations - -- ``XCTUnimplemented(_:placeholder:)-1ho66`` diff --git a/Sources/XCTestDynamicOverlay/Documentation.docc/XCTUnimplemented.md b/Sources/XCTestDynamicOverlay/Documentation.docc/XCTUnimplemented.md deleted file mode 100644 index f4bc30d1..00000000 --- a/Sources/XCTestDynamicOverlay/Documentation.docc/XCTUnimplemented.md +++ /dev/null @@ -1,21 +0,0 @@ -# ``XCTestDynamicOverlay/XCTUnimplemented(_:)-3obl5`` - -## Topics - -### Failure - -- ``XCTUnimplementedFailure`` - -### Overloads - -- ``XCTUnimplemented(_:)-1jjkb`` -- ``XCTUnimplemented(_:)-1tmq0`` -- ``XCTUnimplemented(_:)-4iv80`` -- ``XCTUnimplemented(_:)-2hloh`` -- ``XCTUnimplemented(_:)-6skqm`` -- ``XCTUnimplemented(_:)-9llzg`` -- ``XCTUnimplemented(_:)-1osc7`` -- ``XCTUnimplemented(_:)-26rd5`` -- ``XCTUnimplemented(_:)-7j8g3`` -- ``XCTUnimplemented(_:)-1qks2`` -- ``XCTUnimplemented(_:)-6r8mf`` diff --git a/Sources/XCTestDynamicOverlay/Documentation.docc/XCTUnimplementedPlaceholder.md b/Sources/XCTestDynamicOverlay/Documentation.docc/XCTUnimplementedPlaceholder.md deleted file mode 100644 index a3fbbc36..00000000 --- a/Sources/XCTestDynamicOverlay/Documentation.docc/XCTUnimplementedPlaceholder.md +++ /dev/null @@ -1,29 +0,0 @@ -# ``XCTestDynamicOverlay/XCTUnimplemented(_:placeholder:)-1ho66`` - -## Topics - -### Overloads - -- ``XCTUnimplemented(_:placeholder:)-2e3z9`` -- ``XCTUnimplemented(_:file:line:)-3d9bq`` -- ``XCTUnimplemented(_:placeholder:)-7zq1m`` -- ``XCTUnimplemented(_:file:line:)-2v7cw`` -- ``XCTUnimplemented(_:file:line:)-5k1u`` -- ``XCTUnimplemented(_:placeholder:)-f6km`` -- ``XCTUnimplemented(_:file:line:)-9nzey`` -- ``XCTUnimplemented(_:placeholder:)-55i4t`` -- ``XCTUnimplemented(_:file:line:)-3okct`` -- ``XCTUnimplemented(_:placeholder:)-8sn8`` -- ``XCTUnimplemented(_:file:line:)-s7bl`` -- ``XCTUnimplemented(_:placeholder:)-1nulk`` -- ``XCTUnimplemented(_:file:line:)-1x268`` -- ``XCTUnimplemented(_:placeholder:)-mbpz`` -- ``XCTUnimplemented(_:file:line:)-6qpy4`` -- ``XCTUnimplemented(_:placeholder:)-437q7`` -- ``XCTUnimplemented(_:file:line:)-8c1gm`` -- ``XCTUnimplemented(_:placeholder:)-k1by`` -- ``XCTUnimplemented(_:file:line:)-63m0r`` -- ``XCTUnimplemented(_:placeholder:)-r87l`` -- ``XCTUnimplemented(_:file:line:)-4njow`` -- ``XCTUnimplemented(_:placeholder:)-6e4ct`` -- ``XCTUnimplemented(_:file:line:)-8w02g`` diff --git a/Sources/XCTestDynamicOverlay/Documentation.docc/XCTestDynamicOverlay.md b/Sources/XCTestDynamicOverlay/Documentation.docc/XCTestDynamicOverlay.md index 34f55f51..ac9a117e 100644 --- a/Sources/XCTestDynamicOverlay/Documentation.docc/XCTestDynamicOverlay.md +++ b/Sources/XCTestDynamicOverlay/Documentation.docc/XCTestDynamicOverlay.md @@ -59,10 +59,14 @@ to prevent App Store rejections due to runtime loading of symbols. ### Overlays -- ``XCTFail(_:)`` - ``XCTFail(_:file:line:)`` +- ``XCTExpectFailure(_:enabled:strict:failingBlock:issueMatcher:)`` -### Unimplemented Dependencies +### Unimplemented dependencies -- ``unimplemented(_:placeholder:fileID:line:)-7jrdo`` -- ``unimplemented(_:fileID:line:)-5098a`` +- ``unimplemented(_:placeholder:fileID:line:)-70bno`` +- ``unimplemented(_:fileID:line:)-7znj2`` + +### Deprecated interfaces + +- diff --git a/Sources/XCTestDynamicOverlay/Internal/Deprecations.swift b/Sources/XCTestDynamicOverlay/Internal/Deprecations.swift index 78dbb14b..9d228b55 100644 --- a/Sources/XCTestDynamicOverlay/Internal/Deprecations.swift +++ b/Sources/XCTestDynamicOverlay/Internal/Deprecations.swift @@ -1,448 +1,201 @@ -// MARK: (Parameters) -> Result +// NB: Deprecated after 1.1.2 @_disfavoredOverload -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - placeholder: @autoclosure @escaping @Sendable () -> Result -) -> @Sendable () -> Result { - unimplemented(description(), placeholder: placeholder()) -} - -@_disfavoredOverload -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( +@available(*, deprecated, renamed: "unimplemented(_:placeholder:)") +public func unimplemented( _ description: @autoclosure @escaping @Sendable () -> String = "", file: StaticString = #file, + fileID: StaticString = #fileID, line: UInt = #line -) -> @Sendable () -> Result { - unimplemented(description(), file: file, line: line) +) -> Result { + let description = description() + _fail(description, nil, fileID: fileID, line: line) + do { + return try _generatePlaceholder() + } catch { + _unimplementedFatalError(description, file: file, line: line) + } } -@_disfavoredOverload -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - placeholder: @autoclosure @escaping @Sendable () -> Result -) -> @Sendable (A) -> Result { - unimplemented(description(), placeholder: placeholder()) -} - -@_disfavoredOverload -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( +@available(*, deprecated, renamed: "unimplemented(_:placeholder:)") +public func unimplemented( _ description: @autoclosure @escaping @Sendable () -> String = "", file: StaticString = #file, + fileID: StaticString = #fileID, line: UInt = #line -) -> @Sendable (A) -> Result { - unimplemented(description(), file: file, line: line) +) -> @Sendable (repeat each A) -> Result { + return { (arg: repeat each A) in + let description = description() + _fail(description, (repeat (each arg)), fileID: fileID, line: line) + do { + return try _generatePlaceholder() + } catch { + _unimplementedFatalError(description, file: file, line: line) + } + } } -@_disfavoredOverload -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - placeholder: @autoclosure @escaping @Sendable () -> Result -) -> @Sendable (A, B) -> Result { - unimplemented(description(), placeholder: placeholder()) -} - -@_disfavoredOverload -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - file: StaticString = #file, - line: UInt = #line -) -> @Sendable (A, B) -> Result { - unimplemented(description(), file: file, line: line) -} - -@_disfavoredOverload -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - placeholder: @autoclosure @escaping @Sendable () -> Result -) -> @Sendable (A, B, C) -> Result { - unimplemented(description(), placeholder: placeholder()) -} - -@_disfavoredOverload -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( +@available(*, deprecated, renamed: "unimplemented(_:placeholder:)") +public func unimplemented( _ description: @autoclosure @escaping @Sendable () -> String = "", file: StaticString = #file, + fileID: StaticString = #fileID, line: UInt = #line -) -> @Sendable (A, B, C) -> Result { - unimplemented(description(), file: file, line: line) -} - -@_disfavoredOverload -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( +) -> @Sendable (repeat each A) async -> Result { + return { (arg: repeat each A) in + let description = description() + _fail(description, (repeat (each arg)), fileID: fileID, line: line) + do { + return try _generatePlaceholder() + } catch { + _unimplementedFatalError(description, file: file, line: line) + } + } +} + +@available(*, deprecated) +private func _unimplementedFatalError(_ message: String, file: StaticString, line: UInt) -> Never { + fatalError( + """ + unimplemented(\(message.isEmpty ? "" : message.debugDescription)) + + To suppress this crash, provide an explicit "placeholder". + """, + file: file, + line: line + ) +} + +@available(*, deprecated) +extension _DefaultInitializable { fileprivate static var placeholder: Self { Self() } } +extension AdditiveArithmetic { fileprivate static var placeholder: Self { .zero } } +extension ExpressibleByArrayLiteral { fileprivate static var placeholder: Self { [] } } +extension ExpressibleByBooleanLiteral { fileprivate static var placeholder: Self { false } } +extension ExpressibleByDictionaryLiteral { fileprivate static var placeholder: Self { [:] } } +extension ExpressibleByFloatLiteral { fileprivate static var placeholder: Self { 0.0 } } +extension ExpressibleByIntegerLiteral { fileprivate static var placeholder: Self { 0 } } +extension ExpressibleByUnicodeScalarLiteral { fileprivate static var placeholder: Self { " " } } +extension RangeReplaceableCollection { fileprivate static var placeholder: Self { Self() } } + +@available(*, deprecated) +private protocol _OptionalProtocol { static var none: Self { get } } +@available(*, deprecated) +extension Optional: _OptionalProtocol {} +@available(*, deprecated) +private func _optionalPlaceholder() throws -> Result { + if let result = (Result.self as? _OptionalProtocol.Type) { + return result.none as! Result + } + throw PlaceholderGenerationFailure() +} + +@available(*, deprecated) +private func _placeholder() -> Result? { + switch Result.self { + case let type as _DefaultInitializable.Type: return type.placeholder as? Result + case is Void.Type: return () as? Result + case let type as any RangeReplaceableCollection.Type: return type.placeholder as? Result + case let type as any AdditiveArithmetic.Type: return type.placeholder as? Result + case let type as any ExpressibleByArrayLiteral.Type: return type.placeholder as? Result + case let type as any ExpressibleByBooleanLiteral.Type: return type.placeholder as? Result + case let type as any ExpressibleByDictionaryLiteral.Type: return type.placeholder as? Result + case let type as any ExpressibleByFloatLiteral.Type: return type.placeholder as? Result + case let type as any ExpressibleByIntegerLiteral.Type: return type.placeholder as? Result + case let type as any ExpressibleByUnicodeScalarLiteral.Type: return type.placeholder as? Result + default: return nil + } +} + +@available(*, deprecated) +private func _rawRepresentable() -> Result? { + func posiblePlaceholder(for type: T.Type) -> T? { + (_placeholder() as T.RawValue?).flatMap(T.init(rawValue:)) + } + + return (Result.self as? any RawRepresentable.Type).flatMap { + posiblePlaceholder(for: $0) as? Result + } +} + +@available(*, deprecated) +private func _caseIterable() -> Result? { + func firstCase(for type: T.Type) -> Result? { + T.allCases.first as? Result + } + + return (Result.self as? any CaseIterable.Type).flatMap { + firstCase(for: $0) + } +} + +@available(*, deprecated) +struct PlaceholderGenerationFailure: Error {} +@available(*, deprecated) +func _generatePlaceholder() throws -> Result { + if let result = _placeholder() as Result? { + return result + } + + if let result = _rawRepresentable() as Result? { + return result + } + + if let result = _caseIterable() as Result? { + return result + } + + return try _optionalPlaceholder() +} + +@_disfavoredOverload +@available(*, deprecated, renamed: "unimplemented") +public func XCTUnimplemented( _ description: @autoclosure @escaping @Sendable () -> String = "", placeholder: @autoclosure @escaping @Sendable () -> Result -) -> @Sendable (A, B, C, D) -> Result { +) -> @Sendable (repeat each A) -> Result { unimplemented(description(), placeholder: placeholder()) } @_disfavoredOverload -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( +@available(*, deprecated, renamed: "unimplemented") +public func XCTUnimplemented( _ description: @autoclosure @escaping @Sendable () -> String = "", file: StaticString = #file, line: UInt = #line -) -> @Sendable (A, B, C, D) -> Result { +) -> @Sendable (repeat each A) -> Result { unimplemented(description(), file: file, line: line) } -@_disfavoredOverload -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - placeholder: @autoclosure @escaping @Sendable () -> Result -) -> @Sendable (A, B, C, D, E) -> Result { - unimplemented(description(), placeholder: placeholder()) -} - -@_disfavoredOverload -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - file: StaticString = #file, - line: UInt = #line -) -> @Sendable (A, B, C, D, E) -> Result { - unimplemented(description(), file: file, line: line) -} - -// MARK: (Parameters) throws -> Result - -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "" -) -> @Sendable () throws -> Result { - unimplemented(description()) -} - -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "" -) -> @Sendable (A) throws -> Result { - unimplemented(description()) -} - -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( +@available(*, deprecated, renamed: "unimplemented") +public func XCTUnimplemented( _ description: @autoclosure @escaping @Sendable () -> String = "" -) -> @Sendable (A, B) throws -> Result { +) -> @Sendable (repeat each A) throws -> Result { unimplemented(description()) } -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "" -) -> @Sendable (A, B, C) throws -> Result { - unimplemented(description()) -} - -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "" -) -> @Sendable (A, B, C, D) throws -> Result { - unimplemented(description()) -} - -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "" -) -> @Sendable (A, B, C, D, E) throws -> Result { - unimplemented(description()) -} - -// MARK: (Parameters) async -> Result - -@_disfavoredOverload -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - placeholder: @autoclosure @escaping @Sendable () -> Result -) -> @Sendable () async -> Result { - unimplemented(description(), placeholder: placeholder()) -} - -@_disfavoredOverload -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - file: StaticString = #file, - line: UInt = #line -) -> @Sendable () async -> Result { - unimplemented(description(), file: file, line: line) -} - -/// Returns a closure that generates a failure when invoked. -/// -/// - Parameters: -/// - description: An optional description of the unimplemented closure, for inclusion in test -/// results. -/// - placeholder: An optional placeholder value returned from the closure. If omitted and a -/// default value (like `()` for `Void`) cannot be returned, calling the closure will fatal -/// error instead. -/// - Returns: A closure that generates a failure when invoked. -@_disfavoredOverload -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( +@available(*, deprecated, renamed: "unimplemented") +public func XCTUnimplemented( _ description: @autoclosure @escaping @Sendable () -> String = "", placeholder: @autoclosure @escaping @Sendable () -> Result -) -> @Sendable (A) async -> Result { +) -> @Sendable (repeat each A) async -> Result { unimplemented(description(), placeholder: placeholder()) } -@_disfavoredOverload -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - file: StaticString = #file, - line: UInt = #line -) -> @Sendable (A) async -> Result { - unimplemented(description(), file: file, line: line) -} - -@_disfavoredOverload -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - placeholder: @autoclosure @escaping @Sendable () -> Result -) -> @Sendable (A, B) async -> Result { - unimplemented(description(), placeholder: placeholder()) -} - -@_disfavoredOverload -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( +@available(*, deprecated, renamed: "unimplemented") +public func XCTUnimplemented( _ description: @autoclosure @escaping @Sendable () -> String = "", file: StaticString = #file, line: UInt = #line -) -> @Sendable (A, B) async -> Result { +) -> @Sendable (repeat each A) async -> Result { unimplemented(description(), file: file, line: line) } -@_disfavoredOverload -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - placeholder: @autoclosure @escaping @Sendable () -> Result -) -> @Sendable (A, B, C) async -> Result { - unimplemented(description(), placeholder: placeholder()) -} - -@_disfavoredOverload -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - file: StaticString = #file, - line: UInt = #line -) -> @Sendable (A, B, C) async -> Result { - unimplemented(description(), file: file, line: line) -} - -@_disfavoredOverload -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - placeholder: @autoclosure @escaping @Sendable () -> Result -) -> @Sendable (A, B, C, D) async -> Result { - unimplemented(description(), placeholder: placeholder()) -} - -@_disfavoredOverload -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - file: StaticString = #file, - line: UInt = #line -) -> @Sendable (A, B, C, D) async -> Result { - unimplemented(description(), file: file, line: line) -} - -@_disfavoredOverload -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - placeholder: @autoclosure @escaping @Sendable () -> Result -) -> @Sendable (A, B, C, D, E) async -> Result { - unimplemented(description(), placeholder: placeholder()) -} - -@_disfavoredOverload -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - file: StaticString = #file, - line: UInt = #line -) -> @Sendable (A, B, C, D, E) async -> Result { - unimplemented(description(), file: file, line: line) -} - -// MARK: (Parameters) async throws -> Result - -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "" -) -> @Sendable () async throws -> Result { - unimplemented(description()) -} - -/// Returns a closure that generates a failure when invoked. -/// -/// - Parameter description: An optional description of the unimplemented closure, for inclusion in -/// test results. -/// - Returns: A closure that generates a failure and throws an error when invoked. -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "" -) -> @Sendable (A) async throws -> Result { - unimplemented(description()) -} - -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "" -) -> @Sendable (A, B) async throws -> Result { - unimplemented(description()) -} - -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "" -) -> @Sendable (A, B, C) async throws -> Result { - unimplemented(description()) -} - -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "" -) -> @Sendable (A, B, C, D) async throws -> Result { - unimplemented(description()) -} - -@available(iOS, deprecated: 9999, renamed: "unimplemented") -@available(macOS, deprecated: 9999, renamed: "unimplemented") -@available(tvOS, deprecated: 9999, renamed: "unimplemented") -@available(watchOS, deprecated: 9999, renamed: "unimplemented") -public func XCTUnimplemented( +@available(*, deprecated, renamed: "unimplemented") +public func XCTUnimplemented( _ description: @autoclosure @escaping @Sendable () -> String = "" -) -> @Sendable (A, B, C, D, E) async throws -> Result { +) -> @Sendable (repeat each A) async throws -> Result { unimplemented(description()) } -/// An error thrown from ``XCTUnimplemented(_:)-3obl5``. -@available(iOS, deprecated: 9999, renamed: "UnimplementedFailure") -@available(macOS, deprecated: 9999, renamed: "UnimplementedFailure") -@available(tvOS, deprecated: 9999, renamed: "UnimplementedFailure") -@available(watchOS, deprecated: 9999, renamed: "UnimplementedFailure") +@available(*, deprecated, renamed: "UnimplementedFailure") public typealias XCTUnimplementedFailure = UnimplementedFailure diff --git a/Sources/XCTestDynamicOverlay/Internal/GeneratePlaceholder.swift b/Sources/XCTestDynamicOverlay/Internal/GeneratePlaceholder.swift deleted file mode 100644 index 27bcf7c9..00000000 --- a/Sources/XCTestDynamicOverlay/Internal/GeneratePlaceholder.swift +++ /dev/null @@ -1,71 +0,0 @@ -extension _DefaultInitializable { fileprivate static var placeholder: Self { Self() } } -extension AdditiveArithmetic { fileprivate static var placeholder: Self { .zero } } -extension ExpressibleByArrayLiteral { fileprivate static var placeholder: Self { [] } } -extension ExpressibleByBooleanLiteral { fileprivate static var placeholder: Self { false } } -extension ExpressibleByDictionaryLiteral { fileprivate static var placeholder: Self { [:] } } -extension ExpressibleByFloatLiteral { fileprivate static var placeholder: Self { 0.0 } } -extension ExpressibleByIntegerLiteral { fileprivate static var placeholder: Self { 0 } } -extension ExpressibleByUnicodeScalarLiteral { fileprivate static var placeholder: Self { " " } } -extension RangeReplaceableCollection { fileprivate static var placeholder: Self { Self() } } - -private protocol _OptionalProtocol { static var none: Self { get } } -extension Optional: _OptionalProtocol {} -private func _optionalPlaceholder() throws -> Result { - if let result = (Result.self as? _OptionalProtocol.Type) { - return result.none as! Result - } - throw PlaceholderGenerationFailure() -} - -private func _placeholder() -> Result? { - switch Result.self { - case let type as _DefaultInitializable.Type: return type.placeholder as? Result - case is Void.Type: return () as? Result - case let type as any RangeReplaceableCollection.Type: return type.placeholder as? Result - case let type as any AdditiveArithmetic.Type: return type.placeholder as? Result - case let type as any ExpressibleByArrayLiteral.Type: return type.placeholder as? Result - case let type as any ExpressibleByBooleanLiteral.Type: return type.placeholder as? Result - case let type as any ExpressibleByDictionaryLiteral.Type: return type.placeholder as? Result - case let type as any ExpressibleByFloatLiteral.Type: return type.placeholder as? Result - case let type as any ExpressibleByIntegerLiteral.Type: return type.placeholder as? Result - case let type as any ExpressibleByUnicodeScalarLiteral.Type: return type.placeholder as? Result - default: return nil - } -} - -private func _rawRepresentable() -> Result? { - func posiblePlaceholder(for type: T.Type) -> T? { - (_placeholder() as T.RawValue?).flatMap(T.init(rawValue:)) - } - - return (Result.self as? any RawRepresentable.Type).flatMap { - posiblePlaceholder(for: $0) as? Result - } -} - -private func _caseIterable() -> Result? { - func firstCase(for type: T.Type) -> Result? { - T.allCases.first as? Result - } - - return (Result.self as? any CaseIterable.Type).flatMap { - firstCase(for: $0) - } -} - -struct PlaceholderGenerationFailure: Error {} -func _generatePlaceholder() throws -> Result { - if let result = _placeholder() as Result? { - return result - } - - if let result = _rawRepresentable() as Result? { - return result - } - - if let result = _caseIterable() as Result? { - return result - } - - return try _optionalPlaceholder() -} diff --git a/Sources/XCTestDynamicOverlay/Unimplemented.swift b/Sources/XCTestDynamicOverlay/Unimplemented.swift index 9477e4d3..df56e956 100644 --- a/Sources/XCTestDynamicOverlay/Unimplemented.swift +++ b/Sources/XCTestDynamicOverlay/Unimplemented.swift @@ -1,1481 +1,84 @@ -// MARK: (Parameters) -> Result - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - placeholder: @autoclosure @escaping @Sendable () -> Result, - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable () -> Result { - return { - _fail(description(), nil, fileID: fileID, line: line) - return placeholder() - } -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - file: StaticString = #file, - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable () -> Result { - return { - let description = description() - _fail(description, nil, fileID: fileID, line: line) - do { - return try _generatePlaceholder() - } catch { - _unimplementedFatalError(description, file: file, line: line) - } - } -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@_disfavoredOverload -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - placeholder: @autoclosure @escaping @Sendable () -> Result, - fileID: StaticString = #fileID, - line: UInt = #line -) -> Result { - _fail(description(), nil, fileID: fileID, line: line) - return placeholder() -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@_disfavoredOverload -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - file: StaticString = #file, - fileID: StaticString = #fileID, - line: UInt = #line -) -> Result { - let description = description() - _fail(description, nil, fileID: fileID, line: line) - do { - return try _generatePlaceholder() - } catch { - _unimplementedFatalError(description, file: file, line: line) - } -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - placeholder: @autoclosure @escaping @Sendable () -> Result, - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable (A) -> Result { - return { - _fail(description(), $0, fileID: fileID, line: line) - return placeholder() - } -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - file: StaticString = #file, - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable (A) -> Result { - return { - let description = description() - _fail(description, $0, fileID: fileID, line: line) - do { - return try _generatePlaceholder() - } catch { - _unimplementedFatalError(description, file: file, line: line) - } - } -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - placeholder: @autoclosure @escaping @Sendable () -> Result, - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable (A, B) -> Result { - return { - _fail(description(), ($0, $1), fileID: fileID, line: line) - return placeholder() - } -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - file: StaticString = #file, - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable (A, B) -> Result { - return { - let description = description() - _fail(description, ($0, $1), fileID: fileID, line: line) - do { - return try _generatePlaceholder() - } catch { - _unimplementedFatalError(description, file: file, line: line) - } - } -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - placeholder: @autoclosure @escaping @Sendable () -> Result, - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable (A, B, C) -> Result { - return { - _fail(description(), ($0, $1, $2), fileID: fileID, line: line) - return placeholder() - } -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - file: StaticString = #file, - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable (A, B, C) -> Result { - return { - let description = description() - _fail(description, ($0, $1, $2), fileID: fileID, line: line) - do { - return try _generatePlaceholder() - } catch { - _unimplementedFatalError(description, file: file, line: line) - } - } -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - placeholder: @autoclosure @escaping @Sendable () -> Result, - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable (A, B, C, D) -> Result { - return { - _fail(description(), ($0, $1, $2, $3), fileID: fileID, line: line) - return placeholder() - } -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - file: StaticString = #file, - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable (A, B, C, D) -> Result { - return { - let description = description() - _fail(description, ($0, $1, $2, $3), fileID: fileID, line: line) - do { - return try _generatePlaceholder() - } catch { - _unimplementedFatalError(description, file: file, line: line) - } - } -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( +/// Returns a closure that reports an issue when invoked. +/// +/// - Parameters: +/// - description: An optional description of the unimplemented closure. +/// - placeholder: A placeholder value returned from the closure when left unimplemented. +/// - Returns: A closure that reports an issue when invoked. +public func unimplemented( _ description: @autoclosure @escaping @Sendable () -> String = "", - placeholder: @autoclosure @escaping @Sendable () -> Result, + placeholder: @autoclosure @escaping @Sendable () -> Result = (), fileID: StaticString = #fileID, line: UInt = #line -) -> @Sendable (A, B, C, D, E) -> Result { - return { - _fail(description(), ($0, $1, $2, $3, $4), fileID: fileID, line: line) +) -> @Sendable (repeat each A) -> Result { + return { (arg: repeat each A) in + _fail(description(), (repeat each arg), fileID: fileID, line: line) return placeholder() } } -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - file: StaticString = #file, - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable (A, B, C, D, E) -> Result { - return { - let description = description() - _fail(description, ($0, $1, $2, $3, $4), fileID: fileID, line: line) - do { - return try _generatePlaceholder() - } catch { - _unimplementedFatalError(description, file: file, line: line) - } - } -} - -// MARK: (Parameters) throws -> Result - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable () throws -> Result { - return { - let description = description() - _fail(description, nil, fileID: fileID, line: line) - throw UnimplementedFailure(description: description) - } -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable (A) throws -> Result { - return { - let description = description() - _fail(description, $0, fileID: fileID, line: line) - throw UnimplementedFailure(description: description) - } -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable (A, B) throws -> Result { - return { - let description = description() - _fail(description, ($0, $1), fileID: fileID, line: line) - throw UnimplementedFailure(description: description) - } -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable (A, B, C) throws -> Result { - return { - let description = description() - _fail(description, ($0, $1, $2), fileID: fileID, line: line) - throw UnimplementedFailure(description: description) - } -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable (A, B, C, D) throws -> Result { - return { - let description = description() - _fail(description, ($0, $1, $2, $3), fileID: fileID, line: line) - throw UnimplementedFailure(description: description) - } -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( +/// Returns a throwing closure that reports an issue and throws an error when invoked. +/// +/// - Parameter description: An optional description of the unimplemented closure. +/// - Returns: A throwing closure that reports an issue and throws an error when invoked. +public func unimplemented( _ description: @autoclosure @escaping @Sendable () -> String = "", fileID: StaticString = #fileID, line: UInt = #line -) -> @Sendable (A, B, C, D, E) throws -> Result { - return { +) -> @Sendable (repeat each A) throws -> Result { + return { (arg: repeat each A) in let description = description() - _fail(description, ($0, $1, $2, $3, $4), fileID: fileID, line: line) + _fail(description, (repeat (each arg)), fileID: fileID, line: line) throw UnimplementedFailure(description: description) } } -// MARK: (Parameters) async -> Result - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - placeholder: @autoclosure @escaping @Sendable () -> Result, - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable () async -> Result { - return { - _fail(description(), nil, fileID: fileID, line: line) - return placeholder() - } -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - file: StaticString = #file, - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable () async -> Result { - return { - let description = description() - _fail(description, nil, fileID: fileID, line: line) - do { - return try _generatePlaceholder() - } catch { - _unimplementedFatalError(description, file: file, line: line) - } - } -} - -/// Returns a closure that generates a failure when invoked. +/// Returns an asynchronous closure that reports an issue when invoked. /// /// - Parameters: -/// - description: An optional description of the unimplemented closure, for inclusion in test -/// results. -/// - placeholder: An optional placeholder value returned from the closure. If omitted and a -/// default value (like `()` for `Void`) cannot be returned, calling the closure will fatal -/// error instead. -/// - Returns: A closure that generates a failure when invoked. -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - placeholder: @autoclosure @escaping @Sendable () -> Result, - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable (A) async -> Result { - return { - _fail(description(), $0, fileID: fileID, line: line) - return placeholder() - } -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - file: StaticString = #file, - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable (A) async -> Result { - return { - let description = description() - _fail(description, $0, fileID: fileID, line: line) - do { - return try _generatePlaceholder() - } catch { - _unimplementedFatalError(description, file: file, line: line) - } - } -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - placeholder: @autoclosure @escaping @Sendable () -> Result, - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable (A, B) async -> Result { - return { - _fail(description(), ($0, $1), fileID: fileID, line: line) - return placeholder() - } -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - file: StaticString = #file, - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable (A, B) async -> Result { - return { - let description = description() - _fail(description, ($0, $1), fileID: fileID, line: line) - do { - return try _generatePlaceholder() - } catch { - _unimplementedFatalError(description, file: file, line: line) - } - } -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( +/// - description: An optional description of the unimplemented closure. +/// - placeholder: A placeholder value returned from the closure when left unimplemented. +/// - Returns: An asynchronous closure that reports an issue when invoked. +public func unimplemented( _ description: @autoclosure @escaping @Sendable () -> String = "", - placeholder: @autoclosure @escaping @Sendable () -> Result, + placeholder: @autoclosure @escaping @Sendable () -> Result = (), fileID: StaticString = #fileID, line: UInt = #line -) -> @Sendable (A, B, C) async -> Result { - return { - _fail(description(), ($0, $1, $2), fileID: fileID, line: line) +) -> @Sendable (repeat each A) async -> Result { + return { (arg: repeat each A) in + _fail(description(), (repeat (each arg)), fileID: fileID, line: line) return placeholder() } } -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - file: StaticString = #file, - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable (A, B, C) async -> Result { - return { - let description = description() - _fail(description, ($0, $1, $2), fileID: fileID, line: line) - do { - return try _generatePlaceholder() - } catch { - _unimplementedFatalError(description, file: file, line: line) - } - } -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - placeholder: @autoclosure @escaping @Sendable () -> Result, - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable (A, B, C, D) async -> Result { - return { - _fail(description(), ($0, $1, $2, $3), fileID: fileID, line: line) - return placeholder() - } -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - file: StaticString = #file, - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable (A, B, C, D) async -> Result { - return { - let description = description() - _fail(description, ($0, $1, $2, $3), fileID: fileID, line: line) - do { - return try _generatePlaceholder() - } catch { - _unimplementedFatalError(description, file: file, line: line) - } - } -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - placeholder: @autoclosure @escaping @Sendable () -> Result, - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable (A, B, C, D, E) async -> Result { - return { - _fail(description(), ($0, $1, $2, $3, $4), fileID: fileID, line: line) - return placeholder() - } -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - file: StaticString = #file, - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable (A, B, C, D, E) async -> Result { - return { - let description = description() - _fail(description, ($0, $1, $2, $3, $4), fileID: fileID, line: line) - do { - return try _generatePlaceholder() - } catch { - _unimplementedFatalError(description, file: file, line: line) - } - } -} - -// MARK: (Parameters) async throws -> Result - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable () async throws -> Result { - return { - let description = description() - _fail(description, nil, fileID: fileID, line: line) - throw UnimplementedFailure(description: description) - } -} - -/// Returns a closure that generates a failure when invoked. +/// Returns a throwing, asynchronous closure that reports an issue and throws an error when invoked. /// -/// - Parameter description: An optional description of the unimplemented closure, for inclusion in -/// test results. -/// - Returns: A closure that generates a failure and throws an error when invoked. -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( +/// - Parameter description: An optional description of the unimplemented closure. +/// - Returns: A throwing, asynchronous closure that reports an issue and throws an error when +/// invoked. +public func unimplemented( _ description: @autoclosure @escaping @Sendable () -> String = "", fileID: StaticString = #fileID, line: UInt = #line -) -> @Sendable (A) async throws -> Result { - return { +) -> @Sendable (repeat each A) async throws -> Result { + return { (arg: repeat each A) in let description = description() - _fail(description, $0, fileID: fileID, line: line) + _fail(description, (repeat (each arg)), fileID: fileID, line: line) throw UnimplementedFailure(description: description) } } -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable (A, B) async throws -> Result { - return { - let description = description() - _fail(description, ($0, $1), fileID: fileID, line: line) - throw UnimplementedFailure(description: description) - } -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable (A, B, C) async throws -> Result { - return { - let description = description() - _fail(description, ($0, $1, $2), fileID: fileID, line: line) - throw UnimplementedFailure(description: description) - } -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( - _ description: @autoclosure @escaping @Sendable () -> String = "", - fileID: StaticString = #fileID, - line: UInt = #line -) -> @Sendable (A, B, C, D) async throws -> Result { - return { - let description = description() - _fail(description, ($0, $1, $2, $3), fileID: fileID, line: line) - throw UnimplementedFailure(description: description) - } -} - -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -public func unimplemented( +@_disfavoredOverload +public func unimplemented( _ description: @autoclosure @escaping @Sendable () -> String = "", + placeholder: @autoclosure @escaping @Sendable () -> Result = (), fileID: StaticString = #fileID, line: UInt = #line -) -> @Sendable (A, B, C, D, E) async throws -> Result { - return { - let description = description() - _fail(description, ($0, $1, $2, $3, $4), fileID: fileID, line: line) - throw UnimplementedFailure(description: description) - } +) -> Result { + _fail(description(), nil, fileID: fileID, line: line) + return placeholder() } -/// An error thrown from ``XCTUnimplemented(_:)-3obl5``. -@available( - iOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - macOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - tvOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) -@available( - watchOS, - deprecated: 9999, - message: - "'unimplemented' has been deprecated in favor of '@DependencyClient' and '@DependencyEndpoint' from the 'swift-dependencies' package. See https://github.com/pointfreeco/swift-dependencies for more information." -) +/// An error thrown from throwing `unimplemented` closures. public struct UnimplementedFailure: Error { public let description: String } @@ -1505,15 +108,3 @@ func _fail(_ description: String, _ parameters: Any?, fileID: StaticString, line """ ) } - -func _unimplementedFatalError(_ message: String, file: StaticString, line: UInt) -> Never { - fatalError( - """ - unimplemented(\(message.isEmpty ? "" : message.debugDescription)) - - To suppress this crash, provide an explicit "placeholder". - """, - file: file, - line: line - ) -} diff --git a/Tests/XCTestDynamicOverlayTests/GeneratePlaceholderTests.swift b/Tests/XCTestDynamicOverlayTests/GeneratePlaceholderTests.swift index 81bf605c..367f8eff 100644 --- a/Tests/XCTestDynamicOverlayTests/GeneratePlaceholderTests.swift +++ b/Tests/XCTestDynamicOverlayTests/GeneratePlaceholderTests.swift @@ -8,6 +8,7 @@ #endif final class GeneratePlaceholderTests: XCTestCase { + @available(*, deprecated) func testShouldGeneratePlaceholder() async throws { let bool: () -> Bool = unimplemented("bool") XCTAssertEqual(XCTExpectFailure(failingBlock: bool), false) diff --git a/Tests/XCTestDynamicOverlayTests/TestHelpers.swift b/Tests/XCTestDynamicOverlayTests/TestHelpers.swift index 07106f51..0f80dfe6 100644 --- a/Tests/XCTestDynamicOverlayTests/TestHelpers.swift +++ b/Tests/XCTestDynamicOverlayTests/TestHelpers.swift @@ -37,6 +37,7 @@ func MyXCTFail(_ message: String) { } #endif +@available(*, deprecated) struct Client { var p00: () -> Int var p01: () throws -> Int @@ -102,6 +103,7 @@ struct User { let id: UUID } @MainActor let f04: (String, Int, Double, [Int]) -> Int = unimplemented("f04", placeholder: 42) @MainActor let f05: (String, Int, Double, [Int], User) -> Int = unimplemented("f05", placeholder: 42) +@available(*, deprecated) private struct Autoclosing { init( _: @autoclosure () -> Int = unimplemented(), diff --git a/Tests/XCTestDynamicOverlayTests/UnimplementedTests.swift b/Tests/XCTestDynamicOverlayTests/UnimplementedTests.swift index 8c8b76a4..27c554dc 100644 --- a/Tests/XCTestDynamicOverlayTests/UnimplementedTests.swift +++ b/Tests/XCTestDynamicOverlayTests/UnimplementedTests.swift @@ -10,7 +10,10 @@ Unimplemented: f00 … Defined at: - XCTestDynamicOverlayTests/TestHelpers.swift:98 + XCTestDynamicOverlayTests/TestHelpers.swift:99 + + Invoked with: + () """ } @@ -21,7 +24,7 @@ Unimplemented: f01 … Defined at: - XCTestDynamicOverlayTests/TestHelpers.swift:99 + XCTestDynamicOverlayTests/TestHelpers.swift:100 Invoked with: "" @@ -35,7 +38,7 @@ Unimplemented: f02 … Defined at: - XCTestDynamicOverlayTests/TestHelpers.swift:100 + XCTestDynamicOverlayTests/TestHelpers.swift:101 Invoked with: ("", 42) @@ -49,7 +52,7 @@ Unimplemented: f03 … Defined at: - XCTestDynamicOverlayTests/TestHelpers.swift:101 + XCTestDynamicOverlayTests/TestHelpers.swift:102 Invoked with: ("", 42, 1.2) @@ -63,7 +66,7 @@ Unimplemented: f04 … Defined at: - XCTestDynamicOverlayTests/TestHelpers.swift:102 + XCTestDynamicOverlayTests/TestHelpers.swift:103 Invoked with: ("", 42, 1.2, [1, 2]) @@ -79,7 +82,7 @@ Unimplemented: f05 … Defined at: - XCTestDynamicOverlayTests/TestHelpers.swift:103 + XCTestDynamicOverlayTests/TestHelpers.swift:104 Invoked with: ("", 42, 1.2, [1, 2], XCTestDynamicOverlayTests.User(id: DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF))