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

Side by Side Diff: test/codegen/expect/covariance.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 covariance = dart.defineLibrary(covariance, {}); 1 var covariance = dart.defineLibrary(covariance, {});
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 let _t = Symbol('_t'); 5 let _t = Symbol('_t');
6 let Foo$ = dart.generic(function(T) { 6 let Foo$ = dart.generic(function(T) {
7 class Foo extends core.Object { 7 class Foo extends core.Object {
8 Foo() { 8 Foo() {
9 this[_t] = null; 9 this[_t] = null;
10 } 10 }
11 add(t) { 11 add(t) {
12 dart.as(t, T); 12 dart.as(t, T);
13 this[_t] = t; 13 this[_t] = t;
14 } 14 }
15 forEach(fn) { 15 forEach(fn) {
16 dart.as(fn, dart.functionType(dart.void, [T])); 16 dart.as(fn, dart.functionType(dart.void, [T]));
17 fn(this[_t]); 17 fn(this[_t]);
18 } 18 }
19 } 19 }
20 dart.setSignature(Foo, {
21 methods: () => ({
22 add: dart.functionType(dart.dynamic, [T]),
23 forEach: dart.functionType(dart.dynamic, [dart.functionType(dart.void, [ T])])
24 })
25 });
20 return Foo; 26 return Foo;
21 }); 27 });
22 let Foo = Foo$(); 28 let Foo = Foo$();
23 class Bar extends Foo$(core.int) { 29 class Bar extends Foo$(core.int) {
24 Bar() { 30 Bar() {
25 super.Foo(); 31 super.Foo();
26 } 32 }
27 add(x) { 33 add(x) {
28 core.print(`Bar.add got ${x}`); 34 core.print(`Bar.add got ${x}`);
29 super.add(x); 35 super.add(x);
30 } 36 }
31 } 37 }
32 // Function main: () → dynamic 38 dart.setSignature(Bar, {
39 methods: () => ({add: dart.functionType(dart.dynamic, [core.int])})
40 });
33 function main() { 41 function main() {
34 let foo = new Bar(); 42 let foo = new Bar();
35 foo.add('hi'); 43 foo.add('hi');
36 } 44 }
45 dart.fn(main);
37 // Exports: 46 // Exports:
38 exports.Foo$ = Foo$; 47 exports.Foo$ = Foo$;
39 exports.Foo = Foo; 48 exports.Foo = Foo;
40 exports.Bar = Bar; 49 exports.Bar = Bar;
41 exports.main = main; 50 exports.main = main;
42 })(covariance, core); 51 })(covariance, core);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698