OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 import 'dart:async'; | 5 import 'dart:async'; |
6 | 6 |
7 class Derived<T> implements Future<T> { | 7 class Derived<T> implements Future<T> { |
8 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 8 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
9 } | 9 } |
10 | 10 |
11 class FixedPoint<T> implements Future<FixedPoint<T>> { | 11 class FixedPoint<T> implements Future<FixedPoint<T>> { |
12 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 12 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
13 } | 13 } |
14 | 14 |
15 // TODO(vsm): Restore when https://github.com/dart-lang/sdk/issues/25611 | 15 // TODO(vsm): Restore when https://github.com/dart-lang/sdk/issues/25611 |
16 // is fixed. | 16 // is fixed. |
17 /* | 17 /* |
18 class Divergent<T> implements Future<Divergent<Divergent<T>>> { | 18 class Divergent<T> implements Future<Divergent<Divergent<T>>> { |
19 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 19 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
20 } | 20 } |
21 */ | 21 */ |
22 | 22 |
23 | |
24 test() async { | 23 test() async { |
25 // flatten(Derived<int>) = int | 24 // flatten(Derived<int>) = int |
26 int x = await new Derived<int>(); //# 01: runtime error | 25 int x = await new Derived<int>(); //# 01: runtime error |
27 Future<int> f() async => new Derived<int>(); //# 02: ok | 26 Future<int> f() async => new Derived<int>(); //# 02: ok |
28 Future<int> f() async { return new Derived<int>(); } //# 03: ok | 27 Future<int> f() async { return new Derived<int>(); } //# 03: ok |
29 Future<int> x = (() async => new Derived<int>())(); //# 04: runtime error | 28 Future<int> x = (() async => new Derived<int>())(); //# 04: runtime error |
30 | 29 |
31 // TODO(vsm): Restore when https://github.com/dart-lang/sdk/issues/25611 | 30 // TODO(vsm): Restore when https://github.com/dart-lang/sdk/issues/25611 |
32 // is fixed. | 31 // is fixed. |
33 /* | 32 /* |
34 // flatten(FixedPoint<int>) = FixedPoint<int> | 33 // flatten(FixedPoint<int>) = FixedPoint<int> |
35 FixedPoint<int> x = await new FixedPoint<int>(); //# 05: runtime error | 34 FixedPoint<int> x = await new FixedPoint<int>(); //# 05: runtime error |
36 Future<FixedPoint<int>> f() async => new FixedPoint<int>(); //# 06: ok | 35 Future<FixedPoint<int>> f() async => new FixedPoint<int>(); //# 06: ok |
37 Future<FixedPoint<int>> f() async { return new FixedPoint<int>(); } //# 07: ok | 36 Future<FixedPoint<int>> f() async { return new FixedPoint<int>(); } //# 07: ok |
38 Future<FixedPoint<int>> x = (() async => new FixedPoint<int>())(); //# 08: run
time error | 37 Future<FixedPoint<int>> x = (() async => new FixedPoint<int>())(); //# 08: run
time error |
39 | 38 |
40 // flatten(Divergent<int>) = Divergent<Divergent<int>> | 39 // flatten(Divergent<int>) = Divergent<Divergent<int>> |
41 Divergent<Divergent<int>> x = await new Divergent<int>(); //# 09: runtime erro
r | 40 Divergent<Divergent<int>> x = await new Divergent<int>(); //# 09: runtime erro
r |
42 Future<Divergent<Divergent<int>>> f() async => new Divergent<int>(); //# 10: o
k | 41 Future<Divergent<Divergent<int>>> f() async => new Divergent<int>(); //# 10: o
k |
43 Future<Divergent<Divergent<int>>> f() async { return new Divergent<int>(); } /
/# 11: ok | 42 Future<Divergent<Divergent<int>>> f() async { return new Divergent<int>(); } /
/# 11: ok |
44 Future<Divergent<Divergent<int>>> x = (() async => new Divergent<int>())(); //
# 12: runtime error | 43 Future<Divergent<Divergent<int>>> x = (() async => new Divergent<int>())(); //
# 12: runtime error |
45 */ | 44 */ |
46 } | 45 } |
47 | 46 |
48 main() { | 47 main() { |
49 test(); | 48 test(); |
50 } | 49 } |
OLD | NEW |