OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 class C<T> { | 7 class C<T> { |
8 final x; | 8 final x; |
9 C([this.x]); | 9 C([this.x]); |
10 | 10 |
11 static staticFunction(bool b) => | 11 static staticFunction(bool b) => |
12 b ? T : // //# 00: compile-time error | 12 b ? T : // //# 00: compile-time error |
13 null; | 13 null; |
14 factory C.factoryConstructor(bool b) => new C( | 14 factory C.factoryConstructor(bool b) => new C( |
15 b ? T : // //# 01: ok | 15 b ? T : // //# 01: ok |
16 null); | 16 null); |
17 C.redirectingConstructor(bool b) : this( | 17 C.redirectingConstructor(bool b) : this( |
18 b ? T : // //# 02: ok | 18 b ? T : // //# 02: ok |
19 null); | 19 null); |
20 C.ordinaryConstructor(bool b) : x = | 20 C.ordinaryConstructor(bool b) |
| 21 : x = |
21 b ? T : // //# 03: ok | 22 b ? T : // //# 03: ok |
22 null; | 23 null; |
23 } | 24 } |
24 | 25 |
25 main() { | 26 main() { |
26 Expect.equals(null, C.staticFunction(false)); | 27 Expect.equals(null, C.staticFunction(false)); |
27 Expect.equals(null, new C.factoryConstructor(false).x); | 28 Expect.equals(null, new C.factoryConstructor(false).x); |
28 Expect.equals(null, new C.redirectingConstructor(false).x); | 29 Expect.equals(null, new C.redirectingConstructor(false).x); |
29 Expect.equals(null, new C.ordinaryConstructor(false).x); | 30 Expect.equals(null, new C.ordinaryConstructor(false).x); |
30 } | 31 } |
OLD | NEW |