Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(304)

Side by Side Diff: tests/language/covariant_override_test.dart

Issue 2626843003: Implement 'covariant' modifier for dart2js. (Closed)
Patch Set: Update status file for dartk. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/compiler/lib/src/tokens/keyword.dart ('k') | tests/language/covariant_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1
2 // 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
4 // BSD-style license that can be found in the LICENSE file.
5
6 library covariant_override_test;
7
8 // This test contains cases where `covariant` is used as intended.
9
10 abstract class A {
11 A(this.f1, this.f2, this.f3);
12
13 // Normal usage, "by design": superclass requests covariance.
14 void m1(covariant Object o);
15
16 // Normal usage, "ad hoc": subclass requests covariance.
17 void m2(Object o);
18
19 // Syntactic special case: omit the type in subclass.
20 void m3(Object o);
21
22 // Positional optional arguments.
23 void m4([covariant Object o]);
24 void m5([Object o]);
25 void m6([Object o]);
26
27 // Named arguments.
28 void m7({covariant Object arg});
29 void m8({Object arg});
30 void m9({Object arg});
31
32 // Normal usage on field, "by design": superclass requests covariance.
33 covariant Object f1;
34
35 // Normal usage on field, "ad hoc": subclass requests covariance.
36 Object f2;
37
38 // Syntactic special case.
39 Object f3;
40 }
41
42 abstract class B extends A {
43 B(num f1, num f2, num f3): super(f1, f2, f3);
44
45 void m1(num n);
46 void m2(covariant num n);
47 void m3(covariant n);
48 void m4([num n]);
49 void m5([covariant num n]);
50 void m6([covariant n]);
51 void m7({num arg});
52 void m8({covariant num arg});
53 void m9({covariant arg});
54 void set f1(num n);
55 void set f2(covariant num n);
56 void set f3(covariant n);
57 }
58
59 class C extends B {
60 C(int f1, int f2, int f3): super(f1, f2, f3);
61
62 void m1(int i) {}
63 void m2(int i) {}
64 void m3(int i) {}
65 void m4([int i]) {}
66 void m5([int i]) {}
67 void m6([int i]) {}
68 void m7({int arg}) {}
69 void m8({int arg}) {}
70 void m9({int arg}) {}
71 void set f1(int i) {}
72 void set f2(int i) {}
73 void set f3(int i) {}
74 }
75
76 main() {
77 // For Dart 1.x, `covariant` has no runtime semantics; we just ensure
78 // that the code is not unused, such that we know it will be parsed.
79 A a = new C(39, 40, 41);
80 a.m1(42);
81 a.m2(42);
82 a.m3(42);
83 a.m4(42);
84 a.m5(42);
85 a.m6(42);
86 a.m7(arg: 42);
87 a.m8(arg: 42);
88 a.m9(arg: 42);
89 a.f1 = 42;
90 a.f2 = 42;
91 a.f3 = 42;
92 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/tokens/keyword.dart ('k') | tests/language/covariant_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698