Files
sdk/pkg/dev_compiler/test/dart_codegen/expect/async/timer.dart
T
Leaf Petersen 7321b609d5 Inference casts to dynamic, fuzzy types handled
During inference, allow sub-expressions of type dynamic to be cast to the inferred type.

This CL also adds special case support for the case where we are trying to infer a type for a closure literal with a fuzzy type - often these closures are already well-typed (or easily inferable) if we eliminate the fuzziness.

This gets rid of two of the static errors on angular hello world, along with most of the InferableClosure warnings (turning them into InferredTypeClosure infos).

Most of the remaining InferableClosure cases are function literals with block function bodies, which I don't handle in general yet.

BUG=
R=vsm@google.com

Review URL: https://codereview.chromium.org/1059763003
2015-04-03 15:36:27 -07:00

24 lines
1.1 KiB
Dart

part of dart.async;
abstract class Timer {factory Timer(Duration duration, void callback()) {
if (Zone.current == Zone.ROOT) {
return Zone.current.createTimer(duration, callback);
}
return Zone.current.createTimer(duration, Zone.current.bindCallback(callback, runGuarded: true));
}
factory Timer.periodic(Duration duration, void callback(Timer timer)) {
if (Zone.current == Zone.ROOT) {
return Zone.current.createPeriodicTimer(duration, callback);
}
return Zone.current.createPeriodicTimer(duration, ((__x97) => DEVC$RT.cast(__x97, __t95, __t93, "CompositeCast", """line 80, column 19 of dart:async/timer.dart: """, __x97 is __t93, false))(Zone.current.bindUnaryCallback(callback, runGuarded: true)));
}
static void run(void callback()) {
new Timer(Duration.ZERO, callback);
}
void cancel();
bool get isActive;
external static Timer _createTimer(Duration duration, void callback());
external static Timer _createPeriodicTimer(Duration duration, void callback(Timer timer));
}
typedef void __t93(Timer __u94);
typedef dynamic __t95(dynamic __u96);