OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 // Testing that the reserved word `void` is allowed to occur as a type, not | 5 // Testing that the reserved word `void` is allowed to occur as a type. |
6 // just as a return type. | 6 |
| 7 import 'package:expect/expect.dart'; |
7 | 8 |
8 class A<T> { | 9 class A<T> { |
9 final T t; | 10 T t; |
10 const A(this.t); | 11 const A(this.t); |
11 } | 12 } |
12 | 13 |
13 const void x1 = null; | 14 const void x1 = null; |
14 const A<void> x2 = const A<void>(null); | 15 const A<void> x2 = const A<void>(null); |
15 | 16 |
16 final void x3 = null; | 17 final void x3 = null; |
17 final A<void> x4 = new A<void>(null); | 18 final A<void> x4 = new A<void>(null); |
18 | 19 |
19 void x5 = null, x6; | 20 void x5 = null, x6; |
20 A<void> x7 = new A<void>(null), x8; | 21 A<void> x7 = new A<void>(null), x8; |
21 | 22 |
22 void get g1 => null; | 23 void get g1 => null; |
23 A<void> get g2 => new A<void>(null); | 24 A<void> get g2 => new A<void>(null); |
24 void set s1(void x) => null; | 25 void set s1(void x) => null; |
25 void set s2(A<void> x) => null; | 26 void set s2(A<void> x) => null; |
26 void m1(void x, [void y]) => null; | 27 void m1(void x, [void y]) => null; |
27 void m2(void x, {void y}) => null; | 28 void m2(void x, {void y}) => null; |
28 A<void> m3(A<void> x, [A<void> y]) => new A<void>(null); | 29 A<void> m3(A<void> x, [A<void> y]) => new A<void>(null); |
29 A<void> m4(A<void> x, {A<void> y}) => new A<void>(null); | 30 A<void> m4(A<void> x, {A<void> y}) => new A<void>(null); |
30 | 31 |
31 class B<S, T> implements A<void> { void get t => null; } | 32 class B<S, T> {} |
32 | 33 |
33 class C extends A<void> with B<void, A<void>> { | 34 class C extends A<void> with B<void, A<void>> implements A<void> { |
34 C(): super(null); | |
35 | |
36 static final void x1 = null; | 35 static final void x1 = null; |
37 static final A<void> x2 = new A<void>(null); | 36 static final A<void> x2 = new A<void>(null); |
38 | 37 |
39 static const void x3 = null; | 38 static const void x3 = null; |
40 static const A<void> x4 = const A<void>(null); | 39 static const A<void> x4 = const A<void>(null); |
41 | 40 |
42 final void x5 = null; | 41 final void x5 = null, x6; |
43 final A<void> x6 = new A<void>(null); | 42 final A<void> x7 = new A<void>(null), x8; |
44 | 43 |
45 static void x7 = null, x8; | 44 static void x9 = null, x10; |
46 static A<void> x9 = new A<void>(null), x10; | 45 static A<void> x11 = new A<void>(null), x12; |
47 | 46 |
48 covariant void x11 = null, x12; | 47 covariant void x13 = null, x14; |
49 covariant A<void> x13 = new A<void>(null), x14; | 48 covariant A<void> x15 = new A<void>(null), x16; |
50 | 49 |
51 static void get g1 => null; | 50 static void get g1 => null; |
52 static A<void> get g2 => new A<void>(null); | 51 static A<void> get g2 => new A<void>(null); |
53 static void set s1(void x) => null; | 52 static void set s1(void x) => null; |
54 static void set s2(A<void> x) => null; | 53 static void set s2(A<void> x) => null; |
55 static void m1(void x, [void y]) => null; | 54 static void m1(void x, [void y]) => null; |
56 static void m2(void x, {void y}) => null; | 55 static void m2(void x, {void y}) => null; |
57 static A<void> m3(A<void> x, [A<void> y]) => null; | 56 static A<void> m3(A<void> x, [A<void> y]) => null; |
58 static A<void> m4(A<void> x, {A<void> y}) => null; | 57 static A<void> m4(A<void> x, {A<void> y}) => null; |
59 | 58 |
60 void get g3 => null; | 59 void get g3 => null; |
61 A<void> get g4 => new A<void>(null); | 60 A<void> get g4 => new A<void>(null); |
62 void set s3(void x) => null; | 61 void set s3(void x) => null; |
63 void set s4(A<void> x) => null; | 62 void set s4(A<void> x) => null; |
64 void m5(void x, [void y]) => null; | 63 void m5(void x, [void y]) => null; |
65 void m6(void x, {void y}) => null; | 64 void m6(void x, {void y}) => null; |
66 A<void> m7(A<void> x, [A<void> y]) => null; | 65 A<void> m7(A<void> x, [A<void> y]) => null; |
67 A<void> m8(A<void> x, {A<void> y}) => null; | 66 A<void> m8(A<void> x, {A<void> y}) => null; |
68 | 67 |
69 // Ensure that all members are used, and use `void` in expressions. | 68 // Ensure that all members are used, and use `void` in expressions. |
70 void run() { | 69 void run() { |
71 var ignore = [ | 70 var ignore = [x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, |
72 x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, // | 71 x15, x16, g1, g2, g3, g4]; |
73 g1, g2, g3, g4, | |
74 ]; | |
75 | 72 |
76 s1 = null; | 73 s1 = null; |
77 s2 = new A<void>(null); | 74 s2 = new A<void>(null); |
78 s3 = null; | 75 s3 = null; |
79 s4 = new A<void>(null); | 76 s4 = new A<void>(null); |
80 m1(null, null); | 77 m1(null, null); |
81 m2(null, y: null); | 78 m2(null, y: null); |
82 m3(null, new A<void>(null)); | 79 m3(null, new A<void>(null)); |
83 m4(null, y: new A<void>(null)); | 80 m4(null, y: new A<void>(null)); |
84 m5(null, null); | 81 m5(null, null); |
(...skipping 14 matching lines...) Expand all Loading... |
99 var ignore = [x1, x2, x3, x4, x5, x6, x7, x8, g1, g2]; | 96 var ignore = [x1, x2, x3, x4, x5, x6, x7, x8, g1, g2]; |
100 | 97 |
101 s1 = null; | 98 s1 = null; |
102 s2 = new A<void>(null); | 99 s2 = new A<void>(null); |
103 m1(null, null); | 100 m1(null, null); |
104 m2(null, y: null); | 101 m2(null, y: null); |
105 m3(null, null); | 102 m3(null, null); |
106 m4(null, y: null); | 103 m4(null, y: null); |
107 new C().run(); | 104 new C().run(); |
108 } | 105 } |
OLD | NEW |