OLD | NEW |
1 library test; | 1 library test; |
2 import 'dart:js'; | 2 import 'dart:js'; |
3 | 3 |
4 | |
5 typedef void Callback({int i}); | 4 typedef void Callback({int i}); |
6 | 5 |
7 class Foo<T> { | 6 class Foo<T> { |
8 final int i; | 7 final int i; |
9 bool b; | 8 bool b; |
10 String s; | 9 String s; |
11 T v; | 10 T v; |
12 | 11 |
13 Foo(this.i, this.v); | 12 Foo(this.i, this.v); |
14 | 13 |
15 factory Foo.build() => new Foo(1, null); | 14 factory Foo.build() => new Foo(1, null); |
16 | 15 |
17 untyped_method(a, b) {} | 16 untyped_method(a, b) {} |
18 | 17 |
19 T pass(T t) => t; | 18 T pass(T t) => t; |
20 | 19 |
21 String typed_method( | 20 String typed_method( |
22 Foo foo, List list, | 21 Foo foo, List list, |
23 int i, num n, double d, bool b, String s, | 22 int i, num n, double d, bool b, String s, |
24 JsArray a, JsObject o, JsFunction f) { | 23 JsArray a, JsObject o, JsFunction f) { |
25 return ''; | 24 return ''; |
26 } | 25 } |
27 | 26 |
28 optional_params(a, [b, c]) {} | 27 optional_params(a, [b, c]) {} |
29 | 28 |
30 static named_params(a, {b, c}) {} | 29 static named_params(a, {b, c}) {} |
31 | 30 |
| 31 // Avoid colliding with Function.name & Function.length, as Closure fails to |
| 32 // lower these to ES6 (https://github.com/google/closure-compiler/issues/1460) |
| 33 static name() => 'Foo.name()'; |
| 34 static length() => 'Foo.length()'; |
| 35 |
| 36 static arguments() => 'Foo.arguments()'; |
| 37 static caller() => 'Foo.caller()'; |
| 38 static callee() => 'Foo.callee()'; |
| 39 |
32 nullary_method() {} | 40 nullary_method() {} |
33 | 41 |
34 function_params(int f(x, [y]), g(x, {String y, z}), Callback cb) { | 42 function_params(int f(x, [y]), g(x, {String y, z}), Callback cb) { |
35 cb(i: i); | 43 cb(i: i); |
36 } | 44 } |
37 | 45 |
38 String get prop => null; | 46 String get prop => null; |
39 set prop(String value) {} | 47 set prop(String value) {} |
40 | 48 |
41 static String get staticProp => null; | 49 static String get staticProp => null; |
42 static set staticProp(String value) {} | 50 static set staticProp(String value) {} |
43 | 51 |
44 static const String some_static_constant = "abc"; | 52 static const String some_static_constant = "abc"; |
45 static final String some_static_final = "abc"; | 53 static final String some_static_final = "abc"; |
46 static String some_static_var = "abc"; | 54 static String some_static_var = "abc"; |
47 } | 55 } |
48 | 56 |
49 class Bar {} | 57 class Bar {} |
50 | 58 |
51 class Baz extends Foo<int> with Bar { | 59 class Baz extends Foo<int> with Bar { |
52 Baz(int i) : super(i, 123); | 60 Baz(int i) : super(i, 123); |
53 } | 61 } |
54 | 62 |
55 void main(args) {} | 63 void main(args) { |
| 64 print(Foo.name()); |
| 65 print(Foo.length()); |
| 66 print(Foo.arguments()); |
| 67 print(Foo.caller()); |
| 68 print(Foo.callee()); |
| 69 } |
56 | 70 |
57 const String some_top_level_constant = "abc"; | 71 const String some_top_level_constant = "abc"; |
58 final String some_top_level_final = "abc"; | 72 final String some_top_level_final = "abc"; |
59 String some_top_level_var = "abc"; | 73 String some_top_level_var = "abc"; |
OLD | NEW |