OLD | NEW |
1 | |
2 // 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 |
3 // 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 |
4 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
5 | 4 |
6 library covariant_override_test; | 5 library covariant_override_test; |
7 | 6 |
8 // This test contains cases where `covariant` is used as intended. | 7 // This test contains cases where `covariant` is used as intended. |
9 | 8 |
10 abstract class A { | 9 abstract class A { |
11 A(this.f1, this.f2, this.f3); | 10 A(this.f1, this.f2, this.f3); |
(...skipping 21 matching lines...) Expand all Loading... |
33 covariant Object f1; | 32 covariant Object f1; |
34 | 33 |
35 // Normal usage on field, "ad hoc": subclass requests covariance. | 34 // Normal usage on field, "ad hoc": subclass requests covariance. |
36 Object f2; | 35 Object f2; |
37 | 36 |
38 // Syntactic special case. | 37 // Syntactic special case. |
39 Object f3; | 38 Object f3; |
40 } | 39 } |
41 | 40 |
42 abstract class B extends A { | 41 abstract class B extends A { |
43 B(num f1, num f2, num f3): super(f1, f2, f3); | 42 B(num f1, num f2, num f3) : super(f1, f2, f3); |
44 | 43 |
45 void m1(num n); | 44 void m1(num n); |
46 void m2(covariant num n); | 45 void m2(covariant num n); |
47 void m3(covariant n); | 46 void m3(covariant n); |
48 void m4([num n]); | 47 void m4([num n]); |
49 void m5([covariant num n]); | 48 void m5([covariant num n]); |
50 void m6([covariant n]); | 49 void m6([covariant n]); |
51 void m7({num arg}); | 50 void m7({num arg}); |
52 void m8({covariant num arg}); | 51 void m8({covariant num arg}); |
53 void m9({covariant arg}); | 52 void m9({covariant arg}); |
54 void set f1(num n); | 53 void set f1(num n); |
55 void set f2(covariant num n); | 54 void set f2(covariant num n); |
56 void set f3(covariant n); | 55 void set f3(covariant n); |
57 } | 56 } |
58 | 57 |
59 class C extends B { | 58 class C extends B { |
60 C(int f1, int f2, int f3): super(f1, f2, f3); | 59 C(int f1, int f2, int f3) : super(f1, f2, f3); |
61 | 60 |
62 void m1(int i) {} | 61 void m1(int i) {} |
63 void m2(int i) {} | 62 void m2(int i) {} |
64 void m3(int i) {} | 63 void m3(int i) {} |
65 void m4([int i]) {} | 64 void m4([int i]) {} |
66 void m5([int i]) {} | 65 void m5([int i]) {} |
67 void m6([int i]) {} | 66 void m6([int i]) {} |
68 void m7({int arg}) {} | 67 void m7({int arg}) {} |
69 void m8({int arg}) {} | 68 void m8({int arg}) {} |
70 void m9({int arg}) {} | 69 void m9({int arg}) {} |
71 void set f1(int i) {} | 70 void set f1(int i) {} |
(...skipping 11 matching lines...) Expand all Loading... |
83 a.m4(42); | 82 a.m4(42); |
84 a.m5(42); | 83 a.m5(42); |
85 a.m6(42); | 84 a.m6(42); |
86 a.m7(arg: 42); | 85 a.m7(arg: 42); |
87 a.m8(arg: 42); | 86 a.m8(arg: 42); |
88 a.m9(arg: 42); | 87 a.m9(arg: 42); |
89 a.f1 = 42; | 88 a.f1 = 42; |
90 a.f2 = 42; | 89 a.f2 = 42; |
91 a.f3 = 42; | 90 a.f3 = 42; |
92 } | 91 } |
OLD | NEW |