Skip to content

Commit 6eed033

Browse files
committed
Improve validation of task action implementation tool identifier types
This is an absolute requirement for correct behavior; it should not only be an assertion. Include a verbose and descriptive error message to clearly communicate the issue.
1 parent 524037f commit 6eed033

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Sources/SWBTaskExecution/BuildDescription.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -984,13 +984,17 @@ package final class BuildDescriptionBuilder {
984984
let inputs = amendedInputsForTask(task, inputs)
985985
let outputs = amendedOutputsForTask(task, outputs)
986986

987-
processTaskLock.withLock {
987+
try processTaskLock.withLock {
988988
// Record the custom tool type.
989989
// FIXME: This cast is unfortunate.
990990
let execTask = task.execTask as! Task
991-
assert(execTask.action != nil)
992-
assert(taskActionMap[tool] == nil || taskActionMap[tool]! == type(of: execTask.action!))
993-
taskActionMap[tool] = type(of: execTask.action!)
991+
guard let execTaskAction = execTask.action else {
992+
throw StubError.error("INTERNAL ERROR: custom command with tool identifier '\(tool)' is missing a task action implementation")
993+
}
994+
if let existingTaskAction = taskActionMap[tool], existingTaskAction != type(of: execTaskAction) {
995+
throw StubError.error("INTERNAL ERROR: task action implementation types \(existingTaskAction) and \(type(of: execTaskAction)) have conflicting tool identifier '\(tool)'; tool identifiers must be globally unique across all task action implementation types")
996+
}
997+
taskActionMap[tool] = type(of: execTaskAction)
994998
}
995999

9961000
// Add the command definition.

0 commit comments

Comments
 (0)