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

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

Issue 1879373004: Implement modular compilation (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 8 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 dart_library.library('covariance', null, /* Imports */[ 1 dart_library.library('covariance', null, /* Imports */[
2 'dart/_runtime', 2 'dart_sdk'
3 'dart/core' 3 ], function(exports, dart_sdk) {
4 ], /* Lazy imports */[
5 ], function(exports, dart, core) {
6 'use strict'; 4 'use strict';
7 let dartx = dart.dartx; 5 const core = dart_sdk.core;
6 const dart = dart_sdk.dart;
7 const dartx = dart_sdk.dartx;
8 const covariance = Object.create(null);
8 const _t = Symbol('_t'); 9 const _t = Symbol('_t');
9 const Foo$ = dart.generic(function(T) { 10 covariance.Foo$ = dart.generic(T => {
10 class Foo extends core.Object { 11 class Foo extends core.Object {
11 Foo() { 12 Foo() {
12 this[_t] = null; 13 this[_t] = null;
13 } 14 }
14 add(t) { 15 add(t) {
15 dart.as(t, T); 16 dart.as(t, T);
16 this[_t] = t; 17 this[_t] = t;
17 } 18 }
18 forEach(fn) { 19 forEach(fn) {
19 dart.as(fn, dart.functionType(dart.void, [T])); 20 dart.as(fn, dart.functionType(dart.void, [T]));
20 fn(this[_t]); 21 fn(this[_t]);
21 } 22 }
22 } 23 }
23 dart.setSignature(Foo, { 24 dart.setSignature(Foo, {
24 methods: () => ({ 25 methods: () => ({
25 add: [dart.dynamic, [T]], 26 add: [dart.dynamic, [T]],
26 forEach: [dart.dynamic, [dart.functionType(dart.void, [T])]] 27 forEach: [dart.dynamic, [dart.functionType(dart.void, [T])]]
27 }) 28 })
28 }); 29 });
29 return Foo; 30 return Foo;
30 }); 31 });
31 let Foo = Foo$(); 32 covariance.Foo = covariance.Foo$();
32 class Bar extends Foo$(core.int) { 33 covariance.Bar = class Bar extends covariance.Foo$(core.int) {
33 Bar() { 34 Bar() {
34 super.Foo(); 35 super.Foo();
35 } 36 }
36 add(x) { 37 add(x) {
37 core.print(`Bar.add got ${x}`); 38 core.print(`Bar.add got ${x}`);
38 super.add(x); 39 super.add(x);
39 } 40 }
40 } 41 };
41 dart.setSignature(Bar, { 42 dart.setSignature(covariance.Bar, {
42 methods: () => ({add: [dart.dynamic, [core.int]]}) 43 methods: () => ({add: [dart.dynamic, [core.int]]})
43 }); 44 });
44 function main() { 45 covariance.main = function() {
45 let foo = new Bar(); 46 let foo = new covariance.Bar();
46 foo.add('hi'); 47 foo.add('hi');
47 } 48 };
48 dart.fn(main); 49 dart.fn(covariance.main);
49 // Exports: 50 // Exports:
50 exports.Foo$ = Foo$; 51 exports.covariance = covariance;
51 exports.Foo = Foo;
52 exports.Bar = Bar;
53 exports.main = main;
54 }); 52 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698