Skip to content

Instantly share code, notes, and snippets.

@tgrapperon
Created December 29, 2022 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tgrapperon/c22463b389a371d40295163f636995ed to your computer and use it in GitHub Desktop.
Save tgrapperon/c22463b389a371d40295163f636995ed to your computer and use it in GitHub Desktop.
import XCTestDynamicOverlay
func f(_ f: @autoclosure () -> String) {}
func fa(_ f: @autoclosure () async -> String) async {}
func ft(_ f: @autoclosure () throws -> String) {}
func fat(_ f: @autoclosure () async throws -> String) async {}
func check() async throws {
f(unimplementedAutoclosure(placeholder: "")())
await fa(unimplementedAutoclosure(placeholder: "")())
ft(unimplementedAutoclosure(placeholder: "")())
await fat(unimplementedAutoclosure(placeholder: "")())
f(unimplementedAutoclosure()())
await fa(unimplementedAutoclosure()())
ft(unimplementedAutoclosure()())
await fat(unimplementedAutoclosure()())
}
public func unimplementedAutoclosure<Result>(
_ description: @autoclosure @escaping @Sendable () -> String = "",
placeholder: @autoclosure @escaping @Sendable () -> Result,
fileID: StaticString = #fileID,
line: UInt = #line
) -> @Sendable () -> Result {
unimplemented(description(), placeholder: placeholder(), fileID: fileID, line: line)
}
@_disfavoredOverload
public func unimplementedAutoclosure<Result>(
_ description: @autoclosure @escaping @Sendable () -> String = "",
placeholder: @autoclosure @escaping @Sendable () -> Result,
fileID: StaticString = #fileID,
line: UInt = #line
) -> @Sendable () async -> Result {
unimplemented(description(), placeholder: placeholder(), fileID: fileID, line: line)
}
@_disfavoredOverload
public func unimplementedAutoclosure<Result>(
_ description: @autoclosure @escaping @Sendable () -> String = "",
placeholder: @autoclosure @escaping @Sendable () -> Result,
fileID: StaticString = #fileID,
line: UInt = #line
) -> @Sendable () throws -> Result {
unimplemented(description(), placeholder: placeholder(), fileID: fileID, line: line)
}
@_disfavoredOverload
public func unimplementedAutoclosure<Result>(
_ description: @autoclosure @escaping @Sendable () -> String = "",
placeholder: @autoclosure @escaping @Sendable () -> Result,
fileID: StaticString = #fileID,
line: UInt = #line
) -> @Sendable () async throws -> Result {
unimplemented(description(), placeholder: placeholder(), fileID: fileID, line: line)
}
public func unimplementedAutoclosure<Result>(
_ description: @autoclosure @escaping @Sendable () -> String = "",
fileID: StaticString = #fileID,
line: UInt = #line
) -> @Sendable () -> Result {
unimplemented(description(), fileID: fileID, line: line)
}
@_disfavoredOverload
public func unimplementedAutoclosure<Result>(
_ description: @autoclosure @escaping @Sendable () -> String = "",
fileID: StaticString = #fileID,
line: UInt = #line
) -> @Sendable () async -> Result {
unimplemented(description(), fileID: fileID, line: line)
}
@_disfavoredOverload
public func unimplementedAutoclosure<Result>(
_ description: @autoclosure @escaping @Sendable () -> String = "",
fileID: StaticString = #fileID,
line: UInt = #line
) -> @Sendable () throws -> Result {
unimplemented(description(), fileID: fileID, line: line)
}
@_disfavoredOverload
public func unimplementedAutoclosure<Result>(
_ description: @autoclosure @escaping @Sendable () -> String = "",
fileID: StaticString = #fileID,
line: UInt = #line
) -> @Sendable () async throws -> Result {
unimplemented(description(), fileID: fileID, line: line)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment