OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 topLevelMethod() => 't'; |
| 6 |
| 7 const topLevelFieldForTopLevelMethod = topLevelMethod; |
| 8 const topLevelFieldForStaticMethod = A.staticMethod; |
| 9 |
| 10 class A { |
| 11 final Function closure; |
| 12 const A(this.closure); |
| 13 const A.defaultTopLevel([this.closure = topLevelMethod]); |
| 14 const A.defaultStatic([this.closure = staticMethod]); |
| 15 const A.defaultStatic2([this.closure = A.staticMethod]); |
| 16 run() => closure(); |
| 17 |
| 18 static staticMethod() => 's'; |
| 19 static const staticFieldForStaticMethod = staticMethod; |
| 20 static const staticFieldForTopLevelMethod = topLevelMethod; |
| 21 } |
| 22 |
| 23 main() { |
| 24 Expect.equals('t', (const A(topLevelMethod)).run()); |
| 25 Expect.equals('s', (const A(A.staticMethod)).run()); |
| 26 Expect.equals('t', (const A.defaultTopLevel()).run()); |
| 27 Expect.equals('s', (const A.defaultStatic()).run()); |
| 28 Expect.equals('s', (const A.defaultStatic2()).run()); |
| 29 Expect.equals('t', (new A.defaultTopLevel()).run()); |
| 30 Expect.equals('s', (new A.defaultStatic()).run()); |
| 31 Expect.equals('s', (new A.defaultStatic2()).run()); |
| 32 Expect.equals('t', topLevelFieldForTopLevelMethod()); |
| 33 Expect.equals('s', topLevelFieldForStaticMethod()); |
| 34 Expect.equals('t', A.staticFieldForTopLevelMethod()); |
| 35 Expect.equals('s', A.staticFieldForStaticMethod()); |
| 36 |
| 37 var map = const {'t': topLevelMethod, 's': A.staticMethod }; |
| 38 Expect.equals('t', map['t']()); |
| 39 Expect.equals('s', map['s']()); |
| 40 } |
OLD | NEW |