| Index: sdk/lib/_internal/compiler/implementation/lib/async_patch.dart
|
| diff --git a/sdk/lib/_internal/compiler/implementation/lib/async_patch.dart b/sdk/lib/_internal/compiler/implementation/lib/async_patch.dart
|
| index 0fccce2a432b6eb93bf2af79f0d317545e165f69..0e0a70d2e4620d53530b8b8eb24c3f0b2809d2d2 100644
|
| --- a/sdk/lib/_internal/compiler/implementation/lib/async_patch.dart
|
| +++ b/sdk/lib/_internal/compiler/implementation/lib/async_patch.dart
|
| @@ -6,16 +6,35 @@
|
|
|
| import 'dart:_isolate_helper' show TimerImpl;
|
|
|
| +typedef void _TimerCallback0();
|
| +typedef void _TimerCallback1(Timer timer);
|
| +
|
| patch class Timer {
|
| - patch factory Timer(int milliseconds, void callback(Timer timer)) {
|
| - return new TimerImpl(milliseconds, callback);
|
| + patch factory Timer(var duration, var callback) {
|
| + // TODO(floitsch): remove these checks when we remove the deprecated
|
| + // millisecond argument and the 1-argument callback. Also remove the
|
| + // int-test below.
|
| + if (callback is! _TimerCallback0 && callback is! _TimerCallback1) {
|
| + throw new ArgumentError(callback);
|
| + }
|
| + int milliseconds = duration is int ? duration : duration.inMilliseconds;
|
| + if (milliseconds < 0) milliseconds = 0;
|
| + Timer timer;
|
| + _TimerCallback0 zeroArgumentCallback =
|
| + callback is _TimerCallback0 ? callback : () => callback(timer);
|
| + timer = new TimerImpl(milliseconds, zeroArgumentCallback);
|
| + return timer;
|
| }
|
|
|
| /**
|
| * Creates a new repeating timer. The [callback] is invoked every
|
| * [milliseconds] millisecond until cancelled.
|
| */
|
| - patch factory Timer.repeating(int milliseconds, void callback(Timer timer)) {
|
| + patch factory Timer.repeating(var duration, void callback(Timer timer)) {
|
| + // TODO(floitsch): remove this check when we remove the deprecated
|
| + // millisecond argument.
|
| + int milliseconds = duration is int ? duration : duration.inMilliseconds;
|
| + if (milliseconds < 0) milliseconds = 0;
|
| return new TimerImpl.repeating(milliseconds, callback);
|
| }
|
| }
|
|
|