| 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 | 6 |
| 7 // Test the semantics of static members mixed with instance members. | 7 // Test the semantics of static members mixed with instance members. |
| 8 | 8 |
| 9 // Following are relevant quotes from Dart Programming Language | 9 // Following are relevant quotes from Dart Programming Language |
| 10 // Specification, Draft Version 0.10, June 7, 2012. | 10 // Specification, Draft Version 0.10, June 7, 2012. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 class Sub extends Super { | 61 class Sub extends Super { |
| 62 // According to 7.6, static methods are not inherited. | 62 // According to 7.6, static methods are not inherited. |
| 63 static m() => 'sub'; | 63 static m() => 'sub'; |
| 64 | 64 |
| 65 // According to 7.7, static variables are not inherited. | 65 // According to 7.7, static variables are not inherited. |
| 66 static var i = 'sub'; | 66 static var i = 'sub'; |
| 67 | 67 |
| 68 // According to 7.1, instance methods include those of the | 68 // According to 7.1, instance methods include those of the |
| 69 // superclass, and according to 7, it is a compile-time to have an | 69 // superclass, and according to 7, it is a compile-time to have an |
| 70 // instance method and static method with the same name. | 70 // instance method and static method with the same name. |
| 71 static /// 03: compile-time error | 71 static //# 03: compile-time error |
| 72 instanceMethod() => m(); | 72 instanceMethod() => m(); |
| 73 | 73 |
| 74 // According to 7.7, static variables are not inherited. | 74 // According to 7.7, static variables are not inherited. |
| 75 static i2() => m(); | 75 static i2() => m(); |
| 76 | 76 |
| 77 // According to 7.1, instance methods include those of the | 77 // According to 7.1, instance methods include those of the |
| 78 // superclass, and according to 7, it is a compile-time to have an | 78 // superclass, and according to 7, it is a compile-time to have an |
| 79 // instance method and static method with the same | 79 // instance method and static method with the same |
| 80 // name. Furthermore, according to 7.7 a static variable induces an | 80 // name. Furthermore, according to 7.7 a static variable induces an |
| 81 // implicit getter function (a static method). | 81 // implicit getter function (a static method). |
| 82 static var instanceMethod2; /// 05: compile-time error | 82 static var instanceMethod2; //# 05: compile-time error |
| 83 | 83 |
| 84 foo() => 'foo'; | 84 foo() => 'foo'; |
| 85 } | 85 } |
| 86 | 86 |
| 87 main() { | 87 main() { |
| 88 Expect.equals('foo', new Sub().foo()); | 88 Expect.equals('foo', new Sub().foo()); |
| 89 Expect.equals('top level', m()); | 89 Expect.equals('top level', m()); |
| 90 Expect.equals('super', Super.m()); | 90 Expect.equals('super', Super.m()); |
| 91 Expect.equals('sub', Sub.m()); | 91 Expect.equals('sub', Sub.m()); |
| 92 Expect.equals('super', Super.i); | 92 Expect.equals('super', Super.i); |
| 93 Expect.equals('sub', Sub.i); | 93 Expect.equals('sub', Sub.i); |
| 94 Expect.equals('super', Super.i2); | 94 Expect.equals('super', Super.i2); |
| 95 Expect.equals('sub', Sub.i2()); | 95 Expect.equals('sub', Sub.i2()); |
| 96 Expect.equals('super', new Super().instanceMethod()); | 96 Expect.equals('super', new Super().instanceMethod()); |
| 97 Expect.equals('sub', new Sub().instanceMethod()); | 97 Expect.equals('sub', new Sub().instanceMethod()); |
| 98 Expect.equals('super', new Super().instanceMethod2()); | 98 Expect.equals('super', new Super().instanceMethod2()); |
| 99 Expect.equals('super', new Sub().instanceMethod2()); | 99 Expect.equals('super', new Sub().instanceMethod2()); |
| 100 } | 100 } |
| OLD | NEW |