OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 // In non strong-mode, `FutureOr<T>` is dynamic, even if `T` doesn't exist. | 5 // In non strong-mode, `FutureOr<T>` is dynamic, even if `T` doesn't exist. |
6 // `FutureOr<T>` can not be used as superclass, mixin, nor can it be | 6 // `FutureOr<T>` can not be used as superclass, mixin, nor can it be |
7 // implemented (as interface). | 7 // implemented (as interface). |
8 | 8 |
9 import 'dart:async'; | 9 import 'dart:async'; |
10 import 'package:expect/expect.dart'; | 10 import 'package:expect/expect.dart'; |
11 | 11 |
12 class A | 12 class A |
13 extends FutureOr<String> /// extends: compile-time error | 13 extends FutureOr<String> /// extends: compile-time error |
14 extends Object with FutureOr<bool> /// with: compile-time error | 14 extends Object with FutureOr<bool> /// with: compile-time error |
15 implements FutureOr<int> /// implements: compile-time error | 15 implements FutureOr<int> /// implements: compile-time error |
16 { | 16 { |
17 } | 17 } |
18 | 18 |
19 main() { | 19 main() { |
20 // FutureOr<T> should be treated like `dynamic`. Dynamically the `T` is | 20 // FutureOr<T> should be treated like `dynamic`. Dynamically the `T` is |
21 // completely ignored. It can be a malformed type. | 21 // completely ignored. It can be a malformed type. |
22 Expect.isTrue(499 is FutureOr<A>); /// 00: static type warning | 22 Expect.isTrue(499 is FutureOr<A>); |
23 Expect.isTrue(499 is FutureOr<Does<Not<Exist>>>); /// 01: static type warning | 23 Expect.isTrue(499 is FutureOr<Does<Not<Exist>>>); /// 00: static type warning |
| 24 Expect.isTrue(499 is FutureOr<A, A>); /// 01: static type warning |
24 | 25 |
25 var a = new A(); | 26 var a = new A(); |
26 Expect.isTrue(a.toString() is String); | 27 Expect.isTrue(a.toString() is String); |
27 } | 28 } |
OLD | NEW |