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

Side by Side Diff: test/codegen/expect/fieldtest.js

Issue 1138793002: Tag closures with their types (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Address jmesserly's comments Created 5 years, 7 months 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
OLDNEW
1 var fieldtest = dart.defineLibrary(fieldtest, {}); 1 var fieldtest = dart.defineLibrary(fieldtest, {});
2 var core = dart.import(core); 2 var core = dart.import(core);
3 (function(exports, core) { 3 (function(exports, core) {
4 'use strict'; 4 'use strict';
5 class A extends core.Object { 5 class A extends core.Object {
6 A() { 6 A() {
7 this.x = 42; 7 this.x = 42;
8 } 8 }
9 } 9 }
10 dart.setSignature(A, {});
10 let B$ = dart.generic(function(T) { 11 let B$ = dart.generic(function(T) {
11 class B extends core.Object { 12 class B extends core.Object {
12 B() { 13 B() {
13 this.x = null; 14 this.x = null;
14 this.y = null; 15 this.y = null;
15 this.z = null; 16 this.z = null;
16 } 17 }
17 } 18 }
19 dart.setSignature(B, {});
18 return B; 20 return B;
19 }); 21 });
20 let B = B$(); 22 let B = B$();
21 // Function foo: (A) → int
22 function foo(a) { 23 function foo(a) {
23 core.print(a.x); 24 core.print(a.x);
24 return a.x; 25 return a.x;
25 } 26 }
26 // Function bar: (dynamic) → int 27 dart.fn(foo, core.int, [A]);
27 function bar(a) { 28 function bar(a) {
28 core.print(dart.dload(a, 'x')); 29 core.print(dart.dload(a, 'x'));
29 return dart.as(dart.dload(a, 'x'), core.int); 30 return dart.as(dart.dload(a, 'x'), core.int);
30 } 31 }
31 // Function baz: (A) → dynamic 32 dart.fn(bar, core.int, [dart.dynamic]);
32 function baz(a) { 33 function baz(a) {
33 return a.x; 34 return a.x;
34 } 35 }
35 // Function compute: () → int 36 dart.fn(baz, dart.dynamic, [A]);
36 function compute() { 37 function compute() {
37 return 123; 38 return 123;
38 } 39 }
40 dart.fn(compute, core.int, []);
39 dart.defineLazyProperties(exports, { 41 dart.defineLazyProperties(exports, {
40 get y() { 42 get y() {
41 return dart.notNull(compute()) + 444; 43 return dart.notNull(compute()) + 444;
42 }, 44 },
43 set y(_) {} 45 set y(_) {}
44 }); 46 });
45 dart.copyProperties(exports, { 47 dart.copyProperties(exports, {
46 get q() { 48 get q() {
47 return 'life, ' + 'the universe ' + 'and everything'; 49 return 'life, ' + 'the universe ' + 'and everything';
48 }, 50 },
49 get z() { 51 get z() {
50 return 42; 52 return 42;
51 }, 53 },
52 set z(value) { 54 set z(value) {
53 exports.y = dart.as(value, core.int); 55 exports.y = dart.as(value, core.int);
54 } 56 }
55 }); 57 });
56 class BaseWithGetter extends core.Object { 58 class BaseWithGetter extends core.Object {
57 get foo() { 59 get foo() {
58 return 1; 60 return 1;
59 } 61 }
60 } 62 }
63 dart.setSignature(BaseWithGetter, {});
61 class Derived extends BaseWithGetter { 64 class Derived extends BaseWithGetter {
62 Derived() { 65 Derived() {
63 this.foo = 2; 66 this.foo = 2;
64 this.bar = 3; 67 this.bar = 3;
65 } 68 }
66 } 69 }
67 dart.virtualField(Derived, 'foo'); 70 dart.virtualField(Derived, 'foo');
71 dart.setSignature(Derived, {});
68 let Generic$ = dart.generic(function(T) { 72 let Generic$ = dart.generic(function(T) {
69 class Generic extends core.Object { 73 class Generic extends core.Object {
70 foo(t) { 74 foo(t) {
71 dart.as(t, T); 75 dart.as(t, T);
72 return core.print(dart.notNull(Generic$().bar) + dart.notNull(t)); 76 return core.print(dart.notNull(Generic$().bar) + dart.notNull(t));
73 } 77 }
74 } 78 }
79 dart.setSignature(Generic, {
80 methods: () => ({foo: dart.functionType(dart.dynamic, [T])})
81 });
75 return Generic; 82 return Generic;
76 }); 83 });
77 let Generic = Generic$(); 84 let Generic = Generic$();
78 Generic.bar = 'hello'; 85 Generic.bar = 'hello';
79 // Function main: () → void
80 function main() { 86 function main() {
81 let a = new A(); 87 let a = new A();
82 foo(a); 88 foo(a);
83 bar(a); 89 bar(a);
84 core.print(baz(a)); 90 core.print(baz(a));
85 core.print(new (Generic$(core.String))().foo(' world')); 91 core.print(new (Generic$(core.String))().foo(' world'));
86 } 92 }
93 dart.fn(main, dart.void, []);
87 // Exports: 94 // Exports:
88 exports.A = A; 95 exports.A = A;
89 exports.B$ = B$; 96 exports.B$ = B$;
90 exports.B = B; 97 exports.B = B;
91 exports.foo = foo; 98 exports.foo = foo;
92 exports.bar = bar; 99 exports.bar = bar;
93 exports.baz = baz; 100 exports.baz = baz;
94 exports.compute = compute; 101 exports.compute = compute;
95 exports.BaseWithGetter = BaseWithGetter; 102 exports.BaseWithGetter = BaseWithGetter;
96 exports.Derived = Derived; 103 exports.Derived = Derived;
97 exports.Generic$ = Generic$; 104 exports.Generic$ = Generic$;
98 exports.Generic = Generic; 105 exports.Generic = Generic;
99 exports.main = main; 106 exports.main = main;
100 })(fieldtest, core); 107 })(fieldtest, core);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698