そういうことなのか。これはいけました。 @inlinable @discardableResult public func withTaskLocalValues<each Value, Result, Failure>( _ taskLocalValuesDuringOperation: repeat (TaskLocal<each Value>, each Value), operation: () throws(Failure) -> Result, file: String = #fileID, line: UInt = #line ) throws(Failure) -> Result { return try withoutActuallyEscaping(operation) { operation throws(Failure) -> Result in do { var op: () throws -> Result = operation for (taskLocal, valueDuringOperation) in repeat each taskLocalValuesDuringOperation { op = { [op] () throws -> Result in return try taskLocal.withValue(valueDuringOperation, operation: op, file: file, line: line) } } return try operation() } catch { throw error as! Failure } } }