Skip to content

Commit 65389a4

Browse files
committed
simplified job function to remove the static errors in the return type of the second overload
1 parent ea015ad commit 65389a4

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

.vscode/launch.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@
3838
"mainClass": "org.rascalmpl.shell.RascalShell",
3939
"projectName": "rascal",
4040
"vmArgs": "-Xss80m -Xmx2g -ea",
41-
"console": "integratedTerminal",
42-
"args": "--project |cwd:///|"
41+
"console": "integratedTerminal"
4342
},
4443
{
4544
"type": "java",

src/org/rascalmpl/library/util/Monitor.rsc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ with a parameterized workload and the same label as the job name.
100100
* additional work with ((jobTodo)) is still possible, but you have to repeat the right job label.
101101
}
102102
&T job(str label, &T (void (int worked) step) block, int totalWork=1) {
103+
if (void (void (int _) _) _ := block) {
104+
throw IllegalArgument(block, "`block` argument can not be used by job because it returns `void` and `job` must return something.");
105+
}
106+
103107
try {
104108
jobStart(label, totalWork=totalWork);
105109
return block(void (int worked) {
@@ -114,11 +118,6 @@ with a parameterized workload and the same label as the job name.
114118
}
115119
}
116120

117-
@synopsis{Captures accidental void closures to throw a better exception than `CallFailed`}
118-
(&T<:void) job(str label, (&T<:void) (void (int worked) step) block, int totalWork=1) {
119-
throw IllegalArgument(block, "`block` argument can not be used by job because it returns `void` and `job` must return something.");
120-
}
121-
122121
@synopsis{A job block guarantees a start and end, and provides easy access to the stepper interface.}
123122
@description{
124123
The convenience function that is passed to the block can be used inside the block to register steps

0 commit comments

Comments
 (0)