| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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 class X { | 7 class X { |
| 8 call() => 42; | 8 call() => 42; |
| 9 } | 9 } |
| 10 | 10 |
| 11 class XX extends X { | 11 class XX extends X { |
| 12 XX.named(); | 12 XX.named(); |
| 13 } | 13 } |
| 14 | 14 |
| 15 class Y { | 15 class Y { |
| 16 call(int x) => 87 + x; | 16 call(int x) => 87 + x; |
| 17 | 17 |
| 18 static int staticMethod(int x) => x + 1; | 18 static int staticMethod(int x) => x + 1; |
| 19 } | 19 } |
| 20 | 20 |
| 21 class Z<T> { | 21 class Z<T> { |
| 22 final T value; | 22 final T value; |
| 23 Z(this.value); | 23 Z(this.value); |
| 24 call() => value; | 24 T call() => value; |
| 25 | 25 |
| 26 static int staticMethod(int x) => x + 1; | 26 static int staticMethod(int x) => x + 1; |
| 27 } | 27 } |
| 28 | 28 |
| 29 typedef F(int x); | 29 typedef F(int x); |
| 30 typedef G(String y); | 30 typedef G(String y); |
| 31 typedef H(); | 31 typedef H(); |
| 32 typedef T I<T>(); |
| 32 | 33 |
| 33 main() { | 34 main() { |
| 34 X x = new X(); | 35 X x = new X(); |
| 35 Function f = x; // Should pass checked mode test | 36 Function f = x; // Should pass checked mode test |
| 36 Y y = new Y(); | 37 Y y = new Y(); |
| 37 Function g = y; // Should pass checked mode test | 38 Function g = y; // Should pass checked mode test |
| 38 F f0 = y; // Should pass checked mode test | 39 F f0 = y; // Should pass checked mode test |
| 39 F f1 = x; //# 00: dynamic type error, static type warning | 40 F f1 = x; //# 00: dynamic type error, static type warning |
| 40 G g0 = y; //# 01: dynamic type error, static type warning | 41 G g0 = y; //# 01: dynamic type error, static type warning |
| 41 | 42 |
| 42 Expect.equals(f(), 42); | 43 Expect.equals(f(), 42); |
| 43 Expect.equals(g(100), 187); | 44 Expect.equals(g(100), 187); |
| 44 | 45 |
| 45 var z = new Z<int>(123); | 46 var z = new Z<int>(123); |
| 46 Expect.equals(z(), 123); | 47 Expect.equals(z(), 123); |
| 47 // TODO(jmesserly): this test doesn't work yet. | 48 Expect.equals((z as dynamic)(), 123); |
| 48 // Expect.equals((z as dynamic)(), 123); | |
| 49 | 49 |
| 50 Expect.equals(Y.staticMethod(6), 7); | 50 Expect.equals(Y.staticMethod(6), 7); |
| 51 Expect.equals(Z.staticMethod(6), 7); | 51 Expect.equals(Z.staticMethod(6), 7); |
| 52 | 52 |
| 53 var xx = new XX.named(); | 53 var xx = new XX.named(); |
| 54 Expect.equals(xx(), 42); | 54 Expect.equals(xx(), 42); |
| 55 | 55 |
| 56 H xx2 = new XX.named(); | 56 H xx2 = new XX.named(); |
| 57 Expect.equals(xx2(), 42); | 57 Expect.equals(xx2(), 42); |
| 58 } | 58 } |
| OLD | NEW |