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

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

Issue 1965213003: simplify constructors, fixes #564 (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 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
« no previous file with comments | « test/codegen/expect/constructors.js ('k') | test/codegen/expect/expect.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 dart_library.library('covariance', null, /* Imports */[ 1 dart_library.library('covariance', null, /* Imports */[
2 'dart_sdk' 2 'dart_sdk'
3 ], function(exports, dart_sdk) { 3 ], function(exports, dart_sdk) {
4 'use strict'; 4 'use strict';
5 const core = dart_sdk.core; 5 const core = dart_sdk.core;
6 const dart = dart_sdk.dart; 6 const dart = dart_sdk.dart;
7 const dartx = dart_sdk.dartx; 7 const dartx = dart_sdk.dartx;
8 const covariance = Object.create(null); 8 const covariance = Object.create(null);
9 const _t = Symbol('_t'); 9 const _t = Symbol('_t');
10 covariance.Foo$ = dart.generic(T => { 10 covariance.Foo$ = dart.generic(T => {
11 class Foo extends core.Object { 11 class Foo extends core.Object {
12 Foo() { 12 new() {
13 this[_t] = null; 13 this[_t] = null;
14 } 14 }
15 add(t) { 15 add(t) {
16 dart.as(t, T); 16 dart.as(t, T);
17 this[_t] = t; 17 this[_t] = t;
18 } 18 }
19 forEach(fn) { 19 forEach(fn) {
20 fn(this[_t]); 20 fn(this[_t]);
21 } 21 }
22 } 22 }
23 dart.setSignature(Foo, { 23 dart.setSignature(Foo, {
24 methods: () => ({ 24 methods: () => ({
25 add: [dart.dynamic, [T]], 25 add: [dart.dynamic, [T]],
26 forEach: [dart.dynamic, [dart.functionType(dart.void, [T])]] 26 forEach: [dart.dynamic, [dart.functionType(dart.void, [T])]]
27 }) 27 })
28 }); 28 });
29 return Foo; 29 return Foo;
30 }); 30 });
31 covariance.Foo = covariance.Foo$(); 31 covariance.Foo = covariance.Foo$();
32 covariance.Bar = class Bar extends covariance.Foo$(core.int) { 32 covariance.Bar = class Bar extends covariance.Foo$(core.int) {
33 Bar() { 33 new() {
34 super.Foo(); 34 super.new();
35 } 35 }
36 add(x) { 36 add(x) {
37 core.print(`Bar.add got ${x}`); 37 core.print(`Bar.add got ${x}`);
38 super.add(x); 38 super.add(x);
39 } 39 }
40 }; 40 };
41 dart.setSignature(covariance.Bar, { 41 dart.setSignature(covariance.Bar, {
42 methods: () => ({add: [dart.dynamic, [core.int]]}) 42 methods: () => ({add: [dart.dynamic, [core.int]]})
43 }); 43 });
44 covariance.main = function() { 44 covariance.main = function() {
45 let foo = new covariance.Bar(); 45 let foo = new covariance.Bar();
46 foo.add('hi'); 46 foo.add('hi');
47 }; 47 };
48 dart.fn(covariance.main); 48 dart.fn(covariance.main);
49 // Exports: 49 // Exports:
50 exports.covariance = covariance; 50 exports.covariance = covariance;
51 }); 51 });
OLDNEW
« no previous file with comments | « test/codegen/expect/constructors.js ('k') | test/codegen/expect/expect.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698