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

Side by Side Diff: pkg/dev_compiler/test/codegen/language/callable_test.dart

Issue 2560983002: Support callable classes where call is inherited (Closed)
Patch Set: Created 4 years 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/dev_compiler/lib/src/compiler/code_generator.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 {
12 XX.named();
13 }
14
11 class Y { 15 class Y {
12 call(int x) => 87 + x; 16 call(int x) => 87 + x;
13 17
14 static int staticMethod(int x) => x + 1; 18 static int staticMethod(int x) => x + 1;
15 } 19 }
16 20
17 class Z<T> { 21 class Z<T> {
18 final T value; 22 final T value;
19 Z(this.value); 23 Z(this.value);
20 call() => value; 24 call() => value;
21 25
22 static int staticMethod(int x) => x + 1; 26 static int staticMethod(int x) => x + 1;
23 } 27 }
24 28
25 typedef F(int x); 29 typedef F(int x);
26 typedef G(String y); 30 typedef G(String y);
31 typedef H();
27 32
28 main() { 33 main() {
29 X x = new X(); 34 X x = new X();
30 Function f = x; // Should pass checked mode test 35 Function f = x; // Should pass checked mode test
31 Y y = new Y(); 36 Y y = new Y();
32 Function g = y; // Should pass checked mode test 37 Function g = y; // Should pass checked mode test
33 F f0 = y; // Should pass checked mode test 38 F f0 = y; // Should pass checked mode test
34 F f1 = x; /// 00: dynamic type error, static type warning 39 F f1 = x; /// 00: dynamic type error, static type warning
35 G g0 = y; /// 01: dynamic type error, static type warning 40 G g0 = y; /// 01: dynamic type error, static type warning
36 41
37 Expect.equals(f(), 42); 42 Expect.equals(f(), 42);
38 Expect.equals(g(100), 187); 43 Expect.equals(g(100), 187);
39 44
40 var z = new Z<int>(123); 45 var z = new Z<int>(123);
41 Expect.equals(z(), 123); 46 Expect.equals(z(), 123);
42 // TODO(jmesserly): this test doesn't work yet. 47 // TODO(jmesserly): this test doesn't work yet.
43 // Expect.equals((z as dynamic)(), 123); 48 // Expect.equals((z as dynamic)(), 123);
44 49
45 Expect.equals(Y.staticMethod(6), 7); 50 Expect.equals(Y.staticMethod(6), 7);
46 Expect.equals(Z.staticMethod(6), 7); 51 Expect.equals(Z.staticMethod(6), 7);
52
53 var xx = new XX.named();
54 Expect.equals(xx(), 42);
55
56 H xx2 = new XX.named();
57 Expect.equals(xx2(), 42);
47 } 58 }
OLDNEW
« no previous file with comments | « pkg/dev_compiler/lib/src/compiler/code_generator.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698