Check function types in the correct order in runZoned.
A change made it check for a unary function type before a binary, so `(o, [stack])=>...` would not get a stack trace.
Fixes #33589
Bug: http://dartbug.com/33589
Change-Id: I69793eb74501c1f7fe07b6c90115b2f90f4d95df
Reviewed-on: https://dart-review.googlesource.com/61936
Reviewed-by: Florian Loitsch <floitsch@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
diff --git a/sdk/lib/async/zone.dart b/sdk/lib/async/zone.dart
index f875f0c..dad3151 100644
--- a/sdk/lib/async/zone.dart
+++ b/sdk/lib/async/zone.dart
@@ -1466,10 +1466,10 @@
}
void Function(Object) unaryOnError;
void Function(Object, StackTrace) binaryOnError;
- if (onError is void Function(Object)) {
- unaryOnError = onError;
- } else if (onError is void Function(Object, StackTrace)) {
+ if (onError is void Function(Object, StackTrace)) {
binaryOnError = onError;
+ } else if (onError is void Function(Object)) {
+ unaryOnError = onError;
} else {
throw new ArgumentError("onError callback must take either an Object "
"(the error), or both an Object (the error) and a StackTrace.");
diff --git a/tests/lib_2/async/run_zoned8_test.dart b/tests/lib_2/async/run_zoned8_test.dart
index 450eff6..fca3989 100644
--- a/tests/lib_2/async/run_zoned8_test.dart
+++ b/tests/lib_2/async/run_zoned8_test.dart
@@ -24,8 +24,9 @@
events.add(counter);
throw counter;
});
- }, onError: (e) {
+ }, onError: (e, [s]) {
events.add("error: $e");
+ Expect.isNotNull(s); // Regression test for http://dartbug.com/33589
});
done.future.whenComplete(() {