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

Commit 42df558

Browse files
author
John Messerly
committed
restore arrow function bind this workaround
to help out #266 it seems io.js is using a V8 build from right before this was fixed [email protected] Review URL: https://codereview.chromium.org/1263593003 .
1 parent 23de692 commit 42df558

14 files changed

+182
-138
lines changed

lib/runtime/dart/_isolate_helper.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,11 +1277,11 @@ dart_library.library('dart/_isolate_helper', null, /* Imports */[
12771277
isolate.handleControlMessage(msg);
12781278
return;
12791279
}
1280-
exports._globalState.topEventLoop.enqueue(isolate, dart.fn(() => {
1280+
exports._globalState.topEventLoop.enqueue(isolate, dart.fn((() => {
12811281
if (!dart.notNull(this[_receivePort][_isClosed])) {
12821282
this[_receivePort][_add](msg);
12831283
}
1284-
}), `receive ${message}`);
1284+
}).bind(this)), `receive ${message}`);
12851285
}
12861286
['=='](other) {
12871287
return dart.is(other, _NativeJsSendPort) && dart.equals(this[_receivePort], dart.dload(other, _receivePort));
@@ -1471,9 +1471,9 @@ dart_library.library('dart/_isolate_helper', null, /* Imports */[
14711471
this[_handle] = null;
14721472
if (dart.notNull(hasTimer())) {
14731473
enterJsAsync();
1474-
this[_handle] = self.setInterval(dart.fn(() => {
1474+
this[_handle] = self.setInterval(dart.fn((() => {
14751475
callback(this);
1476-
}), milliseconds);
1476+
}).bind(this)), milliseconds);
14771477
} else {
14781478
dart.throw(new core.UnsupportedError("Periodic timer."));
14791479
}

lib/runtime/dart/async.js

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -651,9 +651,9 @@ dart_library.library('dart/async', null, /* Imports */[
651651
return;
652652
}
653653
elementIndex = dart.notNull(elementIndex) + 1;
654-
}, dart.dynamic, [T]), {onError: dart.bind(future, _completeError), onDone: dart.fn(() => {
654+
}, dart.dynamic, [T]), {onError: dart.bind(future, _completeError), onDone: dart.fn((() => {
655655
future[_completeError](core.RangeError.index(index, this, "index", null, elementIndex));
656-
}), cancelOnError: true});
656+
}).bind(this)), cancelOnError: true});
657657
return future;
658658
}
659659
timeout(timeLimit, opts) {
@@ -980,10 +980,10 @@ dart_library.library('dart/async', null, /* Imports */[
980980
this[_onDone] = dart.fn(() => {
981981
result[_complete](futureValue);
982982
});
983-
this[_onError] = dart.fn((error, stackTrace) => {
983+
this[_onError] = dart.fn(((error, stackTrace) => {
984984
this.cancel();
985985
result[_completeError](error, dart.as(stackTrace, core.StackTrace));
986-
});
986+
}).bind(this));
987987
return result;
988988
}
989989
get [_isInputPaused]() {
@@ -2336,9 +2336,9 @@ dart_library.library('dart/async', null, /* Imports */[
23362336
[_addListener](listener) {
23372337
dart.assert(listener[_nextListener] == null);
23382338
if (dart.notNull(this[_isComplete])) {
2339-
this[_zone].scheduleMicrotask(dart.fn(() => {
2339+
this[_zone].scheduleMicrotask(dart.fn((() => {
23402340
_Future$()._propagateToListeners(this, listener);
2341-
}));
2341+
}).bind(this)));
23422342
} else {
23432343
listener[_nextListener] = dart.as(this[_resultOrListeners], _FutureListener);
23442344
this[_resultOrListeners] = listener;
@@ -2420,9 +2420,9 @@ dart_library.library('dart/async', null, /* Imports */[
24202420
let coreFuture = dart.as(typedFuture, _Future$(T));
24212421
if (dart.notNull(coreFuture[_isComplete]) && dart.notNull(coreFuture[_hasError])) {
24222422
this[_markPendingCompletion]();
2423-
this[_zone].scheduleMicrotask(dart.fn(() => {
2423+
this[_zone].scheduleMicrotask(dart.fn((() => {
24242424
_Future$()._chainCoreFuture(coreFuture, this);
2425-
}));
2425+
}).bind(this)));
24262426
} else {
24272427
_Future$()._chainCoreFuture(coreFuture, this);
24282428
}
@@ -2434,16 +2434,16 @@ dart_library.library('dart/async', null, /* Imports */[
24342434
let typedValue = dart.as(value, T);
24352435
}
24362436
this[_markPendingCompletion]();
2437-
this[_zone].scheduleMicrotask(dart.fn(() => {
2437+
this[_zone].scheduleMicrotask(dart.fn((() => {
24382438
this[_completeWithValue](value);
2439-
}));
2439+
}).bind(this)));
24402440
}
24412441
[_asyncCompleteError](error, stackTrace) {
24422442
dart.assert(!dart.notNull(this[_isComplete]));
24432443
this[_markPendingCompletion]();
2444-
this[_zone].scheduleMicrotask(dart.fn(() => {
2444+
this[_zone].scheduleMicrotask(dart.fn((() => {
24452445
this[_completeError](error, stackTrace);
2446-
}));
2446+
}).bind(this)));
24472447
}
24482448
static _propagateToListeners(source, listeners) {
24492449
while (true) {
@@ -3185,9 +3185,9 @@ dart_library.library('dart/async', null, /* Imports */[
31853185
this[_varData] = subscription;
31863186
}
31873187
subscription[_setPendingEvents](pendingEvents);
3188-
subscription[_guardCallback](dart.fn(() => {
3188+
subscription[_guardCallback](dart.fn((() => {
31893189
_runGuarded(this[_onListen]);
3190-
}));
3190+
}).bind(this)));
31913191
return dart.as(subscription, StreamSubscription$(T));
31923192
}
31933193
[_recordCancel](subscription) {
@@ -3457,9 +3457,9 @@ dart_library.library('dart/async', null, /* Imports */[
34573457
this.addStreamFuture[_asyncComplete](null);
34583458
return null;
34593459
}
3460-
return cancel.whenComplete(dart.fn(() => {
3460+
return cancel.whenComplete(dart.fn((() => {
34613461
this.addStreamFuture[_asyncComplete](null);
3462-
}));
3462+
}).bind(this)));
34633463
}
34643464
complete() {
34653465
this.addStreamFuture[_asyncComplete](null);
@@ -3532,7 +3532,7 @@ dart_library.library('dart/async', null, /* Imports */[
35323532
let _ = new _BufferingStreamSubscription(onData, onError, onDone, cancelOnError);
35333533
_[_setPendingEvents](this[_pending]());
35343534
return _;
3535-
})(), StreamSubscription$(T));
3535+
}).bind(this)(), StreamSubscription$(T));
35363536
}
35373537
}
35383538
dart.setSignature(_GeneratedStreamImpl, {
@@ -3562,13 +3562,13 @@ dart_library.library('dart/async', null, /* Imports */[
35623562
this[_state] = _PendingEvents._STATE_SCHEDULED;
35633563
return;
35643564
}
3565-
scheduleMicrotask(dart.fn(() => {
3565+
scheduleMicrotask(dart.fn((() => {
35663566
let oldState = this[_state];
35673567
this[_state] = _PendingEvents._STATE_UNSCHEDULED;
35683568
if (oldState == _PendingEvents._STATE_CANCELED)
35693569
return;
35703570
this.handleNext(dispatch);
3571-
}));
3571+
}).bind(this)));
35723572
this[_state] = _PendingEvents._STATE_SCHEDULED;
35733573
}
35743574
cancelSchedule() {
@@ -5253,25 +5253,25 @@ dart_library.library('dart/async', null, /* Imports */[
52535253
bindCallback(f, opts) {
52545254
let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true;
52555255
if (dart.notNull(runGuarded)) {
5256-
return dart.fn(() => this.runGuarded(f));
5256+
return dart.fn((() => this.runGuarded(f)).bind(this));
52575257
} else {
5258-
return dart.fn(() => this.run(f));
5258+
return dart.fn((() => this.run(f)).bind(this));
52595259
}
52605260
}
52615261
bindUnaryCallback(f, opts) {
52625262
let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true;
52635263
if (dart.notNull(runGuarded)) {
5264-
return dart.fn(arg => this.runUnaryGuarded(f, arg));
5264+
return dart.fn((arg => this.runUnaryGuarded(f, arg)).bind(this));
52655265
} else {
5266-
return dart.fn(arg => this.runUnary(f, arg));
5266+
return dart.fn((arg => this.runUnary(f, arg)).bind(this));
52675267
}
52685268
}
52695269
bindBinaryCallback(f, opts) {
52705270
let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true;
52715271
if (dart.notNull(runGuarded)) {
5272-
return dart.fn((arg1, arg2) => this.runBinaryGuarded(f, arg1, arg2));
5272+
return dart.fn(((arg1, arg2) => this.runBinaryGuarded(f, arg1, arg2)).bind(this));
52735273
} else {
5274-
return dart.fn((arg1, arg2) => this.runBinary(f, arg1, arg2));
5274+
return dart.fn(((arg1, arg2) => this.runBinary(f, arg1, arg2)).bind(this));
52755275
}
52765276
}
52775277
get(key) {
@@ -5525,27 +5525,27 @@ dart_library.library('dart/async', null, /* Imports */[
55255525
let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true;
55265526
let registered = this.registerCallback(f);
55275527
if (dart.notNull(runGuarded)) {
5528-
return dart.fn(() => this.runGuarded(registered));
5528+
return dart.fn((() => this.runGuarded(registered)).bind(this));
55295529
} else {
5530-
return dart.fn(() => this.run(registered));
5530+
return dart.fn((() => this.run(registered)).bind(this));
55315531
}
55325532
}
55335533
bindUnaryCallback(f, opts) {
55345534
let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true;
55355535
let registered = this.registerUnaryCallback(f);
55365536
if (dart.notNull(runGuarded)) {
5537-
return dart.fn(arg => this.runUnaryGuarded(registered, arg));
5537+
return dart.fn((arg => this.runUnaryGuarded(registered, arg)).bind(this));
55385538
} else {
5539-
return dart.fn(arg => this.runUnary(registered, arg));
5539+
return dart.fn((arg => this.runUnary(registered, arg)).bind(this));
55405540
}
55415541
}
55425542
bindBinaryCallback(f, opts) {
55435543
let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true;
55445544
let registered = this.registerBinaryCallback(f);
55455545
if (dart.notNull(runGuarded)) {
5546-
return dart.fn((arg1, arg2) => this.runBinaryGuarded(registered, arg1, arg2));
5546+
return dart.fn(((arg1, arg2) => this.runBinaryGuarded(registered, arg1, arg2)).bind(this));
55475547
} else {
5548-
return dart.fn((arg1, arg2) => this.runBinary(registered, arg1, arg2));
5548+
return dart.fn(((arg1, arg2) => this.runBinary(registered, arg1, arg2)).bind(this));
55495549
}
55505550
}
55515551
get(key) {

lib/runtime/dart/collection.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ dart_library.library('dart/collection', null, /* Imports */[
196196
let _ = core.List$(E).new();
197197
_[dartx.length] = this.length;
198198
return _;
199-
})() : core.List$(E).new(this.length);
199+
}).bind(this)() : core.List$(E).new(this.length);
200200
let i = 0;
201201
for (let element of this)
202202
result[dartx.set]((() => {
@@ -480,7 +480,7 @@ dart_library.library('dart/collection', null, /* Imports */[
480480
let _ = this[_newSet]();
481481
_.addAll(this);
482482
return _;
483-
})();
483+
}).bind(this)();
484484
}
485485
}
486486
dart.setSignature(_HashSetBase, {
@@ -1424,7 +1424,7 @@ dart_library.library('dart/collection', null, /* Imports */[
14241424
}
14251425
addAll(entries) {
14261426
dart.as(entries, core.Iterable$(E));
1427-
entries[dartx.forEach](dart.fn(entry => this[_insertAfter](this[_previous], dart.as(entry, E)), dart.void, [dart.dynamic]));
1427+
entries[dartx.forEach](dart.fn((entry => this[_insertAfter](this[_previous], dart.as(entry, E))).bind(this), dart.void, [dart.dynamic]));
14281428
}
14291429
remove(entry) {
14301430
dart.as(entry, E);
@@ -1842,7 +1842,7 @@ dart_library.library('dart/collection', null, /* Imports */[
18421842
let x = this.length;
18431843
this.length = dart.notNull(x) + 1;
18441844
return x;
1845-
})(), element);
1845+
}).bind(this)(), element);
18461846
}
18471847
addAll(iterable) {
18481848
dart.as(iterable, core.Iterable$(E));
@@ -1851,7 +1851,7 @@ dart_library.library('dart/collection', null, /* Imports */[
18511851
let x = this.length;
18521852
this.length = dart.notNull(x) + 1;
18531853
return x;
1854-
})(), element);
1854+
}).bind(this)(), element);
18551855
}
18561856
}
18571857
remove(element) {
@@ -3598,11 +3598,11 @@ dart_library.library('dart/collection', null, /* Imports */[
35983598
}
35993599
addAll(other) {
36003600
dart.as(other, core.Map$(K, V));
3601-
other.forEach(dart.fn((key, value) => {
3601+
other.forEach(dart.fn(((key, value) => {
36023602
dart.as(key, K);
36033603
dart.as(value, V);
36043604
this.set(key, value);
3605-
}, dart.dynamic, [K, V]));
3605+
}).bind(this), dart.dynamic, [K, V]));
36063606
}
36073607
get isEmpty() {
36083608
return this[_root] == null;
@@ -4161,7 +4161,7 @@ dart_library.library('dart/collection', null, /* Imports */[
41614161
return new (HashMapKeyIterable$(K))(this);
41624162
}
41634163
get values() {
4164-
return _internal.MappedIterable$(K, V).new(this.keys, dart.fn(each => this.get(each), V, [dart.dynamic]));
4164+
return _internal.MappedIterable$(K, V).new(this.keys, dart.fn((each => this.get(each)).bind(this), V, [dart.dynamic]));
41654165
}
41664166
containsKey(key) {
41674167
if (dart.notNull(_HashMap$()._isStringKey(key))) {
@@ -4182,15 +4182,15 @@ dart_library.library('dart/collection', null, /* Imports */[
41824182
return dart.notNull(this[_findBucketIndex](bucket, key)) >= 0;
41834183
}
41844184
containsValue(value) {
4185-
return this[_computeKeys]()[dartx.any](dart.fn(each => dart.equals(this.get(each), value), core.bool, [dart.dynamic]));
4185+
return this[_computeKeys]()[dartx.any](dart.fn((each => dart.equals(this.get(each), value)).bind(this), core.bool, [dart.dynamic]));
41864186
}
41874187
addAll(other) {
41884188
dart.as(other, core.Map$(K, V));
4189-
other.forEach(dart.fn((key, value) => {
4189+
other.forEach(dart.fn(((key, value) => {
41904190
dart.as(key, K);
41914191
dart.as(value, V);
41924192
this.set(key, value);
4193-
}, dart.dynamic, [K, V]));
4193+
}).bind(this), dart.dynamic, [K, V]));
41944194
}
41954195
get(key) {
41964196
if (dart.notNull(_HashMap$()._isStringKey(key))) {
@@ -4637,7 +4637,7 @@ dart_library.library('dart/collection', null, /* Imports */[
46374637
return new (LinkedHashMapKeyIterable$(K))(this);
46384638
}
46394639
get values() {
4640-
return _internal.MappedIterable$(K, V).new(this.keys, dart.fn(each => this.get(each), V, [dart.dynamic]));
4640+
return _internal.MappedIterable$(K, V).new(this.keys, dart.fn((each => this.get(each)).bind(this), V, [dart.dynamic]));
46414641
}
46424642
containsKey(key) {
46434643
if (dart.notNull(_LinkedHashMap$()._isStringKey(key))) {
@@ -4664,15 +4664,15 @@ dart_library.library('dart/collection', null, /* Imports */[
46644664
return dart.notNull(this[_findBucketIndex](bucket, key)) >= 0;
46654665
}
46664666
containsValue(value) {
4667-
return this.keys[dartx.any](dart.fn(each => dart.equals(this.get(each), value), core.bool, [dart.dynamic]));
4667+
return this.keys[dartx.any](dart.fn((each => dart.equals(this.get(each), value)).bind(this), core.bool, [dart.dynamic]));
46684668
}
46694669
addAll(other) {
46704670
dart.as(other, core.Map$(K, V));
4671-
other.forEach(dart.fn((key, value) => {
4671+
other.forEach(dart.fn(((key, value) => {
46724672
dart.as(key, K);
46734673
dart.as(value, V);
46744674
this.set(key, value);
4675-
}, dart.dynamic, [K, V]));
4675+
}).bind(this), dart.dynamic, [K, V]));
46764676
}
46774677
get(key) {
46784678
if (dart.notNull(_LinkedHashMap$()._isStringKey(key))) {

0 commit comments

Comments
 (0)