Skip to content

Commit 5ce6f68

Browse files
committed
remove mutations of params from gyb script
1 parent ed5906a commit 5ce6f68

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

stdlib/public/Concurrency/TaskGroup+addTask.swift.gyb

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,19 @@ import Swift
118118
% ]:
119119
%
120120
% for TYPE in TYPES:
121-
% OP_THROWS = "throws " if "Throwing" in TYPE else ""
122-
% IS_DISCARDING = "Discarding" in TYPE
123-
% IS_THROWING = "Throwing" in TYPE
121+
% IS_DISCARDING = 'Discarding' in TYPE
122+
% IS_THROWING = 'Throwing' in TYPE
124123
%
125-
% def replace_child_task_result(strings, is_discarding, is_throwing):
126-
% if is_discarding:
127-
% for i in range(len(strings)):
128-
% strings[i] = strings[i].replace("-> ChildTaskResult", "-> Void")
129-
% if not is_throwing:
130-
% for i in range(len(strings)):
131-
% strings[i] = strings[i].replace("throws", "/* non throwing task group*/")
132-
% replace_child_task_result(PARAMS, IS_DISCARDING, IS_THROWING)
124+
% def adjust_params_for_group_kind(params):
125+
% res = []
126+
% for p in params:
127+
% np = p
128+
% if IS_DISCARDING:
129+
% np = np.replace("-> ChildTaskResult", "-> Void")
130+
% if not IS_THROWING:
131+
% np = np.replace("throws", "")
132+
% res.append(np)
133+
% return res
133134
%
134135
% for METHOD_NAME in ADD_TASK_METHOD_VARIANT:
135136
%
@@ -161,8 +162,10 @@ extension ${TYPE} {
161162
/// Adds a child task to the group.
162163
% end
163164
///
165+
% if IS_THROWING:
164166
/// This method doesn't throw an error, even if the child task does.
165167
/// Instead, the corresponding call to `ThrowingTaskGroup.next()` rethrows that error.
168+
% end
166169
///
167170
/// - Parameters:
168171
% if HAS_TASK_NAME:
@@ -190,7 +193,7 @@ extension ${TYPE} {
190193
${"\n ".join(ALL_AVAILABILITY)}
191194
@_alwaysEmitIntoClient
192195
public mutating func ${METHOD_NAME}(
193-
${",\n ".join(PARAMS)}
196+
${",\n ".join(adjust_params_for_group_kind(PARAMS))}
194197
) ${ARROW_RETURN_TYPE}{
195198
% if IS_IMPL_UNAVAILABLE:
196199
fatalError("Unavailable in task-to-thread concurrency model")

0 commit comments

Comments
 (0)