Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: sdk/lib/async/zone.dart

Issue 2858843002: Loosen type check on runZoned errorHandler (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.async; 5 part of dart.async;
6 6
7 typedef R ZoneCallback<R>(); 7 typedef R ZoneCallback<R>();
8 typedef R ZoneUnaryCallback<R, T>(T arg); 8 typedef R ZoneUnaryCallback<R, T>(T arg);
9 typedef R ZoneBinaryCallback<R, T1, T2>(T1 arg1, T2 arg2); 9 typedef R ZoneBinaryCallback<R, T1, T2>(T1 arg1, T2 arg2);
10 10
(...skipping 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after
1431 * new Future(() { throw "asynchronous error"; }); 1431 * new Future(() { throw "asynchronous error"; });
1432 * }, onError: print); // Will print "asynchronous error". 1432 * }, onError: print); // Will print "asynchronous error".
1433 */ 1433 */
1434 R runZoned<R>(R body(), 1434 R runZoned<R>(R body(),
1435 {Map zoneValues, ZoneSpecification zoneSpecification, Function onError}) { 1435 {Map zoneValues, ZoneSpecification zoneSpecification, Function onError}) {
1436 HandleUncaughtErrorHandler errorHandler; 1436 HandleUncaughtErrorHandler errorHandler;
1437 if (onError != null) { 1437 if (onError != null) {
1438 errorHandler = (Zone self, ZoneDelegate parent, Zone zone, error, 1438 errorHandler = (Zone self, ZoneDelegate parent, Zone zone, error,
1439 StackTrace stackTrace) { 1439 StackTrace stackTrace) {
1440 try { 1440 try {
1441 if (onError is ZoneBinaryCallback<R, Object, StackTrace>) { 1441 if (onError is ZoneBinaryCallback<dynamic, Object, StackTrace>) {
vsm 2017/05/03 01:35:48 We're failing this is-check now when onError is a
Lasse Reichstein Nielsen 2017/05/03 05:55:26 This is another case where `void` as a type parame
floitsch 2017/05/03 09:48:11 Agreed with Lasse: There should at the very least
vsm 2017/05/03 12:29:56 Done.
1442 return self.parent.runBinary(onError, error, stackTrace); 1442 return self.parent.runBinary(onError, error, stackTrace);
1443 } 1443 }
1444 return self.parent.runUnary(onError, error); 1444 return self.parent.runUnary(onError, error);
1445 } catch (e, s) { 1445 } catch (e, s) {
1446 if (identical(e, error)) { 1446 if (identical(e, error)) {
1447 return parent.handleUncaughtError(zone, error, stackTrace); 1447 return parent.handleUncaughtError(zone, error, stackTrace);
1448 } else { 1448 } else {
1449 return parent.handleUncaughtError(zone, e, s); 1449 return parent.handleUncaughtError(zone, e, s);
1450 } 1450 }
1451 } 1451 }
1452 }; 1452 };
1453 } 1453 }
1454 if (zoneSpecification == null) { 1454 if (zoneSpecification == null) {
1455 zoneSpecification = 1455 zoneSpecification =
1456 new ZoneSpecification(handleUncaughtError: errorHandler); 1456 new ZoneSpecification(handleUncaughtError: errorHandler);
1457 } else if (errorHandler != null) { 1457 } else if (errorHandler != null) {
1458 zoneSpecification = new ZoneSpecification.from(zoneSpecification, 1458 zoneSpecification = new ZoneSpecification.from(zoneSpecification,
1459 handleUncaughtError: errorHandler); 1459 handleUncaughtError: errorHandler);
1460 } 1460 }
1461 Zone zone = Zone.current 1461 Zone zone = Zone.current
1462 .fork(specification: zoneSpecification, zoneValues: zoneValues); 1462 .fork(specification: zoneSpecification, zoneValues: zoneValues);
1463 if (onError != null) { 1463 if (onError != null) {
1464 return zone.runGuarded(body); 1464 return zone.runGuarded(body);
1465 } else { 1465 } else {
1466 return zone.run(body); 1466 return zone.run(body);
1467 } 1467 }
1468 } 1468 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698