OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Test the semantics of static members mixed with instance members. | 5 // Test the semantics of static members mixed with instance members. |
6 | 6 |
7 // Following are relevant quotes from Dart Programming Language | 7 // Following are relevant quotes from Dart Programming Language |
8 // Specification, Draft Version 0.10, June 7, 2012. | 8 // Specification, Draft Version 0.10, June 7, 2012. |
9 | 9 |
10 // 7 Classes: | 10 // 7 Classes: |
(...skipping 20 matching lines...) Expand all Loading... |
31 // 7.7 Static Variables | 31 // 7.7 Static Variables |
32 | 32 |
33 // "Static variables are variables whose declarations are immediately | 33 // "Static variables are variables whose declarations are immediately |
34 // contained within a class declaration and that are declared | 34 // contained within a class declaration and that are declared |
35 // static. The static variables of a class C are those static | 35 // static. The static variables of a class C are those static |
36 // variables declared by C." | 36 // variables declared by C." |
37 | 37 |
38 // "A static variable declaration of one of the forms static T v;, | 38 // "A static variable declaration of one of the forms static T v;, |
39 // static T v = e; , static const T v = e; or static final T v = e; | 39 // static T v = e; , static const T v = e; or static final T v = e; |
40 // always induces an implicit static getter function (7.2) with | 40 // always induces an implicit static getter function (7.2) with |
41 // signature static T get v() whose invocation evaluates as described | 41 // signature static T get v whose invocation evaluates as described |
42 // below (7.7.1)." | 42 // below (7.7.1)." |
43 | 43 |
44 m() => 'top level'; | 44 m() => 'top level'; |
45 | 45 |
46 class Super { | 46 class Super { |
47 // No error from hiding. | 47 // No error from hiding. |
48 static m() => 'super'; | 48 static m() => 'super'; |
49 | 49 |
50 static var i = 'super'; | 50 static var i = 'super'; |
51 | 51 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 Expect.equals('sub', Sub.m()); | 89 Expect.equals('sub', Sub.m()); |
90 Expect.equals('super', Super.i); | 90 Expect.equals('super', Super.i); |
91 Expect.equals('sub', Sub.i); | 91 Expect.equals('sub', Sub.i); |
92 Expect.equals('super', Super.i2); | 92 Expect.equals('super', Super.i2); |
93 Expect.equals('sub', Sub.i2()); | 93 Expect.equals('sub', Sub.i2()); |
94 Expect.equals('super', new Super().instanceMethod()); | 94 Expect.equals('super', new Super().instanceMethod()); |
95 Expect.equals('sub', new Sub().instanceMethod()); | 95 Expect.equals('sub', new Sub().instanceMethod()); |
96 Expect.equals('super', new Super().instanceMethod2()); | 96 Expect.equals('super', new Super().instanceMethod2()); |
97 Expect.equals('super', new Sub().instanceMethod2()); | 97 Expect.equals('super', new Sub().instanceMethod2()); |
98 } | 98 } |
OLD | NEW |