Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit 19f6daf

Browse files
author
John Messerly
committed
fixes #43, remove => workaround
[email protected] Review URL: https://codereview.chromium.org/1169473003
1 parent 70d1789 commit 19f6daf

File tree

10 files changed

+106
-135
lines changed

10 files changed

+106
-135
lines changed

lib/runtime/dart/_isolate_helper.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -857,11 +857,11 @@ var async = dart.import(async);
857857
}
858858
[_runHelper]() {
859859
if (exports.globalWindow != null) {
860-
let next = (() => {
860+
let next = () => {
861861
if (!dart.notNull(this.runIteration()))
862862
return;
863863
async.Timer.run(next);
864-
}).bind(this);
864+
};
865865
dart.fn(next);
866866
next();
867867
} else {
@@ -1279,11 +1279,11 @@ var async = dart.import(async);
12791279
isolate.handleControlMessage(msg);
12801280
return;
12811281
}
1282-
exports._globalState.topEventLoop.enqueue(isolate, dart.fn((() => {
1282+
exports._globalState.topEventLoop.enqueue(isolate, dart.fn(() => {
12831283
if (!dart.notNull(this[_receivePort][_isClosed])) {
12841284
this[_receivePort][_add](msg);
12851285
}
1286-
}).bind(this)), `receive ${message}`);
1286+
}), `receive ${message}`);
12871287
}
12881288
['=='](other) {
12891289
return dart.is(other, _NativeJsSendPort) && dart.notNull(dart.equals(this[_receivePort], dart.dload(other, _receivePort)));
@@ -1445,20 +1445,20 @@ var async = dart.import(async);
14451445
this[_inEventLoop] = false;
14461446
this[_handle] = null;
14471447
if (milliseconds == 0 && (!dart.notNull(hasTimer()) || dart.notNull(exports._globalState.isWorker))) {
1448-
let internalCallback = (() => {
1448+
let internalCallback = () => {
14491449
this[_handle] = null;
14501450
callback();
1451-
}).bind(this);
1451+
};
14521452
dart.fn(internalCallback, dart.void, []);
14531453
this[_handle] = 1;
14541454
exports._globalState.topEventLoop.enqueue(exports._globalState.currentContext, internalCallback, 'timer');
14551455
this[_inEventLoop] = true;
14561456
} else if (hasTimer()) {
1457-
let internalCallback = (() => {
1457+
let internalCallback = () => {
14581458
this[_handle] = null;
14591459
leaveJsAsync();
14601460
callback();
1461-
}).bind(this);
1461+
};
14621462
dart.fn(internalCallback, dart.void, []);
14631463
enterJsAsync();
14641464
this[_handle] = self.setTimeout(_js_helper.convertDartClosureToJS(internalCallback, 0), milliseconds);
@@ -1473,9 +1473,9 @@ var async = dart.import(async);
14731473
this[_handle] = null;
14741474
if (hasTimer()) {
14751475
enterJsAsync();
1476-
this[_handle] = self.setInterval(_js_helper.convertDartClosureToJS(dart.fn((() => {
1476+
this[_handle] = self.setInterval(_js_helper.convertDartClosureToJS(dart.fn(() => {
14771477
callback(this);
1478-
}).bind(this)), 0), milliseconds);
1478+
}), 0), milliseconds);
14791479
} else {
14801480
throw new core.UnsupportedError("Periodic timer.");
14811481
}

lib/runtime/dart/_js_helper.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ var _isolate_helper = dart.lazyImport(_isolate_helper);
142142
return new (_ConstantMapKeyIterable$(K))(this);
143143
}
144144
get values() {
145-
return _internal.MappedIterable$(K, V).new(this[_keys], dart.fn((key => dart.as(this[_fetch](key), V)).bind(this), V, [core.Object]));
145+
return _internal.MappedIterable$(K, V).new(this[_keys], dart.fn(key => dart.as(this[_fetch](key), V), V, [core.Object]));
146146
}
147147
}
148148
ConstantStringMap[dart.implements] = () => [_internal.EfficientLength];
@@ -1825,13 +1825,13 @@ var _isolate_helper = dart.lazyImport(_isolate_helper);
18251825
let _ = positions.keys[core.$toList]();
18261826
_[core.$sort]();
18271827
return _;
1828-
})()[core.$forEach](dart.fn((name => {
1828+
})()[core.$forEach](dart.fn(name => {
18291829
this.cachedSortedIndices[core.$set]((() => {
18301830
let x = index;
18311831
index = dart.notNull(x) + 1;
18321832
return x;
18331833
})(), positions.get(name));
1834-
}).bind(this), core.Object, [core.String]));
1834+
}, core.Object, [core.String]));
18351835
}
18361836
return dart.as(this.cachedSortedIndices[core.$get](unsortedIndex), core.int);
18371837
}

lib/runtime/dart/async.js

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ var collection = dart.import(collection);
159159
dart.as(convert, dart.functionType(core.Object, [T]));
160160
let controller = null;
161161
let subscription = null;
162-
let onListen = (() => {
162+
let onListen = () => {
163163
let add = dart.bind(controller, 'add');
164164
dart.assert(dart.is(controller, _StreamController) || dart.is(controller, _BroadcastStreamController));
165165
let eventSink = controller;
@@ -182,7 +182,7 @@ var collection = dart.import(collection);
182182
controller.add(newValue);
183183
}
184184
}, core.Object, [T]), {onError: dart.as(addError, core.Function), onDone: dart.bind(controller, 'close')});
185-
}).bind(this);
185+
};
186186
dart.fn(onListen, dart.void, []);
187187
if (this.isBroadcast) {
188188
controller = StreamController.broadcast({onListen: onListen, onCancel: dart.fn(() => {
@@ -203,7 +203,7 @@ var collection = dart.import(collection);
203203
dart.as(convert, dart.functionType(Stream$(), [T]));
204204
let controller = null;
205205
let subscription = null;
206-
let onListen = (() => {
206+
let onListen = () => {
207207
dart.assert(dart.is(controller, _StreamController) || dart.is(controller, _BroadcastStreamController));
208208
let eventSink = controller;
209209
subscription = this.listen(dart.fn(event => {
@@ -222,7 +222,7 @@ var collection = dart.import(collection);
222222
controller.addStream(newStream).whenComplete(dart.bind(subscription, 'resume'));
223223
}
224224
}, core.Object, [T]), {onError: dart.as(eventSink[_addError], core.Function), onDone: dart.bind(controller, 'close')});
225-
}).bind(this);
225+
};
226226
dart.fn(onListen, dart.void, []);
227227
if (this.isBroadcast) {
228228
controller = StreamController.broadcast({onListen: onListen, onCancel: dart.fn(() => {
@@ -649,9 +649,9 @@ var collection = dart.import(collection);
649649
return;
650650
}
651651
elementIndex = dart.notNull(elementIndex) + 1;
652-
}, core.Object, [T]), {onError: dart.bind(future, _completeError), onDone: dart.fn((() => {
652+
}, core.Object, [T]), {onError: dart.bind(future, _completeError), onDone: dart.fn(() => {
653653
future[_completeError](core.RangeError.index(index, this, "index", null, elementIndex));
654-
}).bind(this)), cancelOnError: true});
654+
}), cancelOnError: true});
655655
return future;
656656
}
657657
timeout(timeLimit, opts) {
@@ -682,7 +682,7 @@ var collection = dart.import(collection);
682682
controller.close();
683683
};
684684
dart.fn(onDone, dart.void, []);
685-
let onListen = (() => {
685+
let onListen = () => {
686686
zone = Zone.current;
687687
if (onTimeout == null) {
688688
timeout = dart.fn(() => {
@@ -699,7 +699,7 @@ var collection = dart.import(collection);
699699
}
700700
subscription = this.listen(onData, {onError: onError, onDone: onDone});
701701
timer = zone.createTimer(timeLimit, dart.as(timeout, dart.functionType(dart.void, [])));
702-
}).bind(this);
702+
};
703703
dart.fn(onListen, dart.void, []);
704704
let onCancel = () => {
705705
timer.cancel();
@@ -978,10 +978,10 @@ var collection = dart.import(collection);
978978
this[_onDone] = dart.fn(() => {
979979
result[_complete](futureValue);
980980
});
981-
this[_onError] = dart.fn(((error, stackTrace) => {
981+
this[_onError] = dart.fn((error, stackTrace) => {
982982
this.cancel();
983983
result[_completeError](error, dart.as(stackTrace, core.StackTrace));
984-
}).bind(this));
984+
});
985985
return result;
986986
}
987987
get [_isInputPaused]() {
@@ -1102,7 +1102,7 @@ var collection = dart.import(collection);
11021102
dart.assert(!dart.notNull(this[_isPaused]));
11031103
dart.assert(!dart.notNull(this[_inCallback]));
11041104
let wasInputPaused = this[_isInputPaused];
1105-
let sendError = (() => {
1105+
let sendError = () => {
11061106
if (dart.notNull(this[_isCanceled]) && !dart.notNull(this[_waitsForCancel]))
11071107
return;
11081108
this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStreamSubscription$()._STATE_IN_CALLBACK);
@@ -1112,7 +1112,7 @@ var collection = dart.import(collection);
11121112
this[_zone].runUnaryGuarded(dart.as(this[_onError], __CastType25), error);
11131113
}
11141114
this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BufferingStreamSubscription$()._STATE_IN_CALLBACK);
1115-
}).bind(this);
1115+
};
11161116
dart.fn(sendError, dart.void, []);
11171117
if (this[_cancelOnError]) {
11181118
this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStreamSubscription$()._STATE_WAIT_FOR_CANCEL);
@@ -1131,13 +1131,13 @@ var collection = dart.import(collection);
11311131
dart.assert(!dart.notNull(this[_isCanceled]));
11321132
dart.assert(!dart.notNull(this[_isPaused]));
11331133
dart.assert(!dart.notNull(this[_inCallback]));
1134-
let sendDone = (() => {
1134+
let sendDone = () => {
11351135
if (!dart.notNull(this[_waitsForCancel]))
11361136
return;
11371137
this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStreamSubscription$()._STATE_CANCELED) | dart.notNull(_BufferingStreamSubscription$()._STATE_CLOSED) | dart.notNull(_BufferingStreamSubscription$()._STATE_IN_CALLBACK);
11381138
this[_zone].runGuarded(this[_onDone]);
11391139
this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BufferingStreamSubscription$()._STATE_IN_CALLBACK);
1140-
}).bind(this);
1140+
};
11411141
dart.fn(sendDone, dart.void, []);
11421142
this[_cancel]();
11431143
this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStreamSubscription$()._STATE_WAIT_FOR_CANCEL);
@@ -2333,9 +2333,9 @@ var collection = dart.import(collection);
23332333
[_addListener](listener) {
23342334
dart.assert(listener[_nextListener] == null);
23352335
if (this[_isComplete]) {
2336-
this[_zone].scheduleMicrotask(dart.fn((() => {
2336+
this[_zone].scheduleMicrotask(dart.fn(() => {
23372337
_Future$()._propagateToListeners(this, listener);
2338-
}).bind(this)));
2338+
}));
23392339
} else {
23402340
listener[_nextListener] = dart.as(this[_resultOrListeners], _FutureListener);
23412341
this[_resultOrListeners] = listener;
@@ -2417,9 +2417,9 @@ var collection = dart.import(collection);
24172417
let coreFuture = dart.as(typedFuture, _Future$(T));
24182418
if (dart.notNull(coreFuture[_isComplete]) && dart.notNull(coreFuture[_hasError])) {
24192419
this[_markPendingCompletion]();
2420-
this[_zone].scheduleMicrotask(dart.fn((() => {
2420+
this[_zone].scheduleMicrotask(dart.fn(() => {
24212421
_Future$()._chainCoreFuture(coreFuture, this);
2422-
}).bind(this)));
2422+
}));
24232423
} else {
24242424
_Future$()._chainCoreFuture(coreFuture, this);
24252425
}
@@ -2431,16 +2431,16 @@ var collection = dart.import(collection);
24312431
let typedValue = dart.as(value, T);
24322432
}
24332433
this[_markPendingCompletion]();
2434-
this[_zone].scheduleMicrotask(dart.fn((() => {
2434+
this[_zone].scheduleMicrotask(dart.fn(() => {
24352435
this[_completeWithValue](value);
2436-
}).bind(this)));
2436+
}));
24372437
}
24382438
[_asyncCompleteError](error, stackTrace) {
24392439
dart.assert(!dart.notNull(this[_isComplete]));
24402440
this[_markPendingCompletion]();
2441-
this[_zone].scheduleMicrotask(dart.fn((() => {
2441+
this[_zone].scheduleMicrotask(dart.fn(() => {
24422442
this[_completeError](error, stackTrace);
2443-
}).bind(this)));
2443+
}));
24442444
}
24452445
static _propagateToListeners(source, listeners) {
24462446
while (true) {
@@ -3183,9 +3183,9 @@ var collection = dart.import(collection);
31833183
this[_varData] = subscription;
31843184
}
31853185
subscription[_setPendingEvents](pendingEvents);
3186-
subscription[_guardCallback](dart.fn((() => {
3186+
subscription[_guardCallback](dart.fn(() => {
31873187
_runGuarded(this[_onListen]);
3188-
}).bind(this)));
3188+
}));
31893189
return dart.as(subscription, StreamSubscription$(T));
31903190
}
31913191
[_recordCancel](subscription) {
@@ -3211,11 +3211,11 @@ var collection = dart.import(collection);
32113211
result = result.whenComplete(this[_onCancel]);
32123212
}
32133213
}
3214-
let complete = (() => {
3214+
let complete = () => {
32153215
if (dart.notNull(this[_doneFuture] != null) && dart.notNull(this[_doneFuture][_mayComplete])) {
32163216
this[_doneFuture][_asyncComplete](null);
32173217
}
3218-
}).bind(this);
3218+
};
32193219
dart.fn(complete, dart.void, []);
32203220
if (result != null) {
32213221
result = result.whenComplete(complete);
@@ -3447,9 +3447,9 @@ var collection = dart.import(collection);
34473447
this.addStreamFuture[_asyncComplete](null);
34483448
return null;
34493449
}
3450-
return cancel.whenComplete(dart.fn((() => {
3450+
return cancel.whenComplete(dart.fn(() => {
34513451
this.addStreamFuture[_asyncComplete](null);
3452-
}).bind(this)));
3452+
}));
34533453
}
34543454
complete() {
34553455
this.addStreamFuture[_asyncComplete](null);
@@ -3522,7 +3522,7 @@ var collection = dart.import(collection);
35223522
let _ = new _BufferingStreamSubscription(onData, onError, onDone, cancelOnError);
35233523
_[_setPendingEvents](this[_pending]());
35243524
return _;
3525-
}).bind(this)(), StreamSubscription$(T));
3525+
})(), StreamSubscription$(T));
35263526
}
35273527
}
35283528
dart.setSignature(_GeneratedStreamImpl, {
@@ -3552,13 +3552,13 @@ var collection = dart.import(collection);
35523552
this[_state] = _PendingEvents._STATE_SCHEDULED;
35533553
return;
35543554
}
3555-
scheduleMicrotask(dart.fn((() => {
3555+
scheduleMicrotask(dart.fn(() => {
35563556
let oldState = this[_state];
35573557
this[_state] = _PendingEvents._STATE_UNSCHEDULED;
35583558
if (oldState == _PendingEvents._STATE_CANCELED)
35593559
return;
35603560
this.handleNext(dispatch);
3561-
}).bind(this)));
3561+
}));
35623562
this[_state] = _PendingEvents._STATE_SCHEDULED;
35633563
}
35643564
cancelSchedule() {
@@ -5243,25 +5243,25 @@ var collection = dart.import(collection);
52435243
bindCallback(f, opts) {
52445244
let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true;
52455245
if (runGuarded) {
5246-
return dart.fn((() => this.runGuarded(f)).bind(this));
5246+
return dart.fn(() => this.runGuarded(f));
52475247
} else {
5248-
return dart.fn((() => this.run(f)).bind(this));
5248+
return dart.fn(() => this.run(f));
52495249
}
52505250
}
52515251
bindUnaryCallback(f, opts) {
52525252
let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true;
52535253
if (runGuarded) {
5254-
return dart.fn((arg => this.runUnaryGuarded(f, arg)).bind(this));
5254+
return dart.fn(arg => this.runUnaryGuarded(f, arg));
52555255
} else {
5256-
return dart.fn((arg => this.runUnary(f, arg)).bind(this));
5256+
return dart.fn(arg => this.runUnary(f, arg));
52575257
}
52585258
}
52595259
bindBinaryCallback(f, opts) {
52605260
let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true;
52615261
if (runGuarded) {
5262-
return dart.fn(((arg1, arg2) => this.runBinaryGuarded(f, arg1, arg2)).bind(this));
5262+
return dart.fn((arg1, arg2) => this.runBinaryGuarded(f, arg1, arg2));
52635263
} else {
5264-
return dart.fn(((arg1, arg2) => this.runBinary(f, arg1, arg2)).bind(this));
5264+
return dart.fn((arg1, arg2) => this.runBinary(f, arg1, arg2));
52655265
}
52665266
}
52675267
get(key) {
@@ -5515,27 +5515,27 @@ var collection = dart.import(collection);
55155515
let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true;
55165516
let registered = this.registerCallback(f);
55175517
if (runGuarded) {
5518-
return dart.fn((() => this.runGuarded(registered)).bind(this));
5518+
return dart.fn(() => this.runGuarded(registered));
55195519
} else {
5520-
return dart.fn((() => this.run(registered)).bind(this));
5520+
return dart.fn(() => this.run(registered));
55215521
}
55225522
}
55235523
bindUnaryCallback(f, opts) {
55245524
let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true;
55255525
let registered = this.registerUnaryCallback(f);
55265526
if (runGuarded) {
5527-
return dart.fn((arg => this.runUnaryGuarded(registered, arg)).bind(this));
5527+
return dart.fn(arg => this.runUnaryGuarded(registered, arg));
55285528
} else {
5529-
return dart.fn((arg => this.runUnary(registered, arg)).bind(this));
5529+
return dart.fn(arg => this.runUnary(registered, arg));
55305530
}
55315531
}
55325532
bindBinaryCallback(f, opts) {
55335533
let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true;
55345534
let registered = this.registerBinaryCallback(f);
55355535
if (runGuarded) {
5536-
return dart.fn(((arg1, arg2) => this.runBinaryGuarded(registered, arg1, arg2)).bind(this));
5536+
return dart.fn((arg1, arg2) => this.runBinaryGuarded(registered, arg1, arg2));
55375537
} else {
5538-
return dart.fn(((arg1, arg2) => this.runBinary(registered, arg1, arg2)).bind(this));
5538+
return dart.fn((arg1, arg2) => this.runBinary(registered, arg1, arg2));
55395539
}
55405540
}
55415541
get(key) {

0 commit comments

Comments
 (0)