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

Commit 94d823b

Browse files
author
John Messerly
committed
additional SDK fixes. This gets all of them, once we upgrade to new analyzer
there's still a lot of warnings, those are next up [email protected] Review URL: https://codereview.chromium.org/1347153005 .
1 parent 9baaa46 commit 94d823b

File tree

8 files changed

+62
-94
lines changed

8 files changed

+62
-94
lines changed

lib/runtime/dart/_native_typed_data.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ dart_library.library('dart/_native_typed_data', null, /* Imports */[
1212
'use strict';
1313
let dartx = dart.dartx;
1414
class NativeByteBuffer extends core.Object {
15-
NativeByteBuffer() {
16-
this.lengthInBytes = null;
17-
}
1815
get runtimeType() {
1916
return typed_data.ByteBuffer;
2017
}
@@ -474,17 +471,10 @@ dart_library.library('dart/_native_typed_data', null, /* Imports */[
474471
});
475472
dart.defineExtensionMembers(NativeFloat64x2List, ['get', 'set', 'sublist', 'length']);
476473
class NativeTypedData extends core.Object {
477-
NativeTypedData() {
478-
this.buffer = null;
479-
this.lengthInBytes = null;
480-
this.offsetInBytes = null;
481-
this.elementSizeInBytes = null;
482-
}
483474
[_invalidIndex](index, length) {
484475
if (dart.notNull(index) < 0 || dart.notNull(index) >= dart.notNull(length)) {
485476
if (dart.is(this, core.List)) {
486-
let list = this;
487-
if (dart.equals(length, list.length)) {
477+
if (dart.equals(length, dart.dload(this, 'length'))) {
488478
dart.throw(core.RangeError.index(index, this));
489479
}
490480
}
@@ -711,9 +701,6 @@ dart_library.library('dart/_native_typed_data', null, /* Imports */[
711701
NativeByteData[dart.metadata] = () => [dart.const(new _js_helper.Native("DataView"))];
712702
let _setRangeFast = Symbol('_setRangeFast');
713703
class NativeTypedArray extends NativeTypedData {
714-
NativeTypedArray() {
715-
super.NativeTypedData();
716-
}
717704
[_setRangeFast](start, end, source, skipCount) {
718705
let targetLength = this.length;
719706
this[_checkIndex](start, dart.notNull(targetLength) + 1);

lib/runtime/dart/async.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ dart_library.library('dart/async', null, /* Imports */[
164164
let onListen = (function() {
165165
let add = dart.bind(controller, 'add');
166166
dart.assert(dart.is(controller, _StreamController) || dart.is(controller, _BroadcastStreamController));
167-
let eventSink = controller;
168-
let addError = eventSink[_addError];
167+
let eventSink = dart.as(controller, _EventSink$(T));
168+
let addError = dart.bind(eventSink, _addError);
169169
subscription = this.listen(dart.fn(event => {
170170
dart.as(event, T);
171171
let newValue = null;
@@ -183,7 +183,7 @@ dart_library.library('dart/async', null, /* Imports */[
183183
} else {
184184
controller.add(newValue);
185185
}
186-
}, dart.dynamic, [T]), {onError: dart.as(addError, core.Function), onDone: dart.bind(controller, 'close')});
186+
}, dart.dynamic, [T]), {onError: addError, onDone: dart.bind(controller, 'close')});
187187
}).bind(this);
188188
dart.fn(onListen, dart.void, []);
189189
if (dart.notNull(this.isBroadcast)) {
@@ -207,7 +207,7 @@ dart_library.library('dart/async', null, /* Imports */[
207207
let subscription = null;
208208
let onListen = (function() {
209209
dart.assert(dart.is(controller, _StreamController) || dart.is(controller, _BroadcastStreamController));
210-
let eventSink = controller;
210+
let eventSink = dart.as(controller, _EventSink$(T));
211211
subscription = this.listen(dart.fn(event => {
212212
dart.as(event, T);
213213
let newStream = null;
@@ -223,7 +223,7 @@ dart_library.library('dart/async', null, /* Imports */[
223223
subscription.pause();
224224
controller.addStream(newStream).whenComplete(dart.bind(subscription, 'resume'));
225225
}
226-
}, dart.dynamic, [T]), {onError: dart.as(eventSink[_addError], core.Function), onDone: dart.bind(controller, 'close')});
226+
}, dart.dynamic, [T]), {onError: dart.bind(eventSink, _addError), onDone: dart.bind(controller, 'close')});
227227
}).bind(this);
228228
dart.fn(onListen, dart.void, []);
229229
if (dart.notNull(this.isBroadcast)) {
@@ -674,8 +674,8 @@ dart_library.library('dart/async', null, /* Imports */[
674674
function onError(error, stackTrace) {
675675
timer.cancel();
676676
dart.assert(dart.is(controller, _StreamController) || dart.is(controller, _BroadcastStreamController));
677-
let eventSink = controller;
678-
dart.dcall(eventSink[_addError], error, stackTrace);
677+
let eventSink = dart.as(controller, _EventSink$(T));
678+
eventSink[_addError](error, stackTrace);
679679
timer = zone.createTimer(timeLimit, dart.as(timeout, dart.functionType(dart.void, [])));
680680
}
681681
dart.fn(onError, dart.void, [dart.dynamic, core.StackTrace]);
@@ -1393,16 +1393,17 @@ dart_library.library('dart/async', null, /* Imports */[
13931393
}
13941394
return dart.as(subscription, StreamSubscription$(T));
13951395
}
1396-
[_recordCancel](subscription) {
1397-
dart.as(subscription, StreamSubscription$(T));
1396+
[_recordCancel](sub) {
1397+
dart.as(sub, StreamSubscription$(T));
1398+
let subscription = dart.as(sub, _BroadcastSubscription$(T));
13981399
if (dart.notNull(core.identical(subscription[_next], subscription)))
13991400
return null;
14001401
dart.assert(!dart.notNull(core.identical(subscription[_next], subscription)));
1401-
if (dart.notNull(dart.as(subscription[_isFiring], core.bool))) {
1402-
dart.dcall(subscription[_setRemoveAfterFiring]);
1402+
if (dart.notNull(subscription[_isFiring])) {
1403+
subscription[_setRemoveAfterFiring]();
14031404
} else {
14041405
dart.assert(!dart.notNull(core.identical(subscription[_next], subscription)));
1405-
this[_removeListener](dart.as(subscription, _BroadcastSubscription$(T)));
1406+
this[_removeListener](subscription);
14061407
if (!dart.notNull(this[_isFiring]) && dart.notNull(this[_isEmpty])) {
14071408
this[_callOnCancel]();
14081409
}

lib/runtime/dart/collection.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3839,7 +3839,7 @@ dart_library.library('dart/collection', null, /* Imports */[
38393839
}
38403840
toSet() {
38413841
let setOrMap = this[_tree];
3842-
let set = new (SplayTreeSet$(K))(dart.as(setOrMap[_comparator], __CastType0), dart.as(setOrMap[_validKey], __CastType3));
3842+
let set = new (SplayTreeSet$(K))(setOrMap[_comparator], setOrMap[_validKey]);
38433843
set[_count] = this[_tree][_count];
38443844
set[_root] = set[_copyNode](this[_tree][_root]);
38453845
return set;
@@ -4126,12 +4126,6 @@ dart_library.library('dart/collection', null, /* Imports */[
41264126
return SplayTreeSet;
41274127
});
41284128
let SplayTreeSet = SplayTreeSet$();
4129-
let __CastType0$ = dart.generic(function(K) {
4130-
let __CastType0 = dart.typedef('__CastType0', () => dart.functionType(core.int, [K, K]));
4131-
return __CastType0;
4132-
});
4133-
let __CastType0 = __CastType0$();
4134-
let __CastType3 = dart.typedef('__CastType3', () => dart.functionType(core.bool, [core.Object]));
41354129
let _strings = Symbol('_strings');
41364130
let _nums = Symbol('_nums');
41374131
let _rest = Symbol('_rest');

tool/input_sdk/lib/async/broadcast_stream_controller.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ abstract class _BroadcastStreamController<T>
201201
return subscription;
202202
}
203203

204-
Future _recordCancel(StreamSubscription<T> subscription) {
204+
Future _recordCancel(StreamSubscription<T> sub) {
205+
var subscription = sub as _BroadcastSubscription<T>;
205206
// If already removed by the stream, don't remove it again.
206207
if (identical(subscription._next, subscription)) return null;
207208
assert(!identical(subscription._next, subscription));

tool/input_sdk/lib/async/stream.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ abstract class Stream<T> {
317317
final add = controller.add;
318318
assert(controller is _StreamController ||
319319
controller is _BroadcastStreamController);
320-
final eventSink = controller;
320+
final eventSink = controller as _EventSink<T>;
321321
final addError = eventSink._addError;
322322
subscription = this.listen(
323323
(T event) {
@@ -377,7 +377,7 @@ abstract class Stream<T> {
377377
void onListen() {
378378
assert(controller is _StreamController ||
379379
controller is _BroadcastStreamController);
380-
final eventSink = controller;
380+
final eventSink = controller as _EventSink<T>;
381381
subscription = this.listen(
382382
(T event) {
383383
Stream newStream;
@@ -1223,7 +1223,7 @@ abstract class Stream<T> {
12231223
timer.cancel();
12241224
assert(controller is _StreamController ||
12251225
controller is _BroadcastStreamController);
1226-
var eventSink = controller;
1226+
var eventSink = controller as _EventSink<T>;
12271227
eventSink._addError(error, stackTrace); // Avoid Zone error replacement.
12281228
timer = zone.createTimer(timeLimit, timeout);
12291229
}

tool/input_sdk/lib/collection/splay_tree.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ abstract class _SplayTree<K> {
6666
/** Comparison used to compare keys. */
6767
int _compare(K key1, K key2);
6868

69+
Comparator<K> get _comparator;
70+
71+
_Predicate<Object> get _validKey;
72+
6973
/**
7074
* Perform the splay operation for the given key. Moves the node with
7175
* the given key to the top of the tree. If no node has the given

tool/input_sdk/private/native_typed_data.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import 'dart:typed_data';
2121
@Native("ArrayBuffer")
2222
class NativeByteBuffer implements ByteBuffer {
2323
@JSName('byteLength')
24-
final int lengthInBytes;
24+
external int get lengthInBytes;
2525

2626
Type get runtimeType => ByteBuffer;
2727

@@ -424,32 +424,32 @@ class NativeTypedData implements TypedData {
424424
@Creates('NativeByteBuffer')
425425
// May be Null for IE's CanvasPixelArray.
426426
@Returns('NativeByteBuffer|Null')
427-
final ByteBuffer buffer;
427+
external ByteBuffer get buffer;
428428

429429
/**
430430
* Returns the length of this view, in bytes.
431431
*/
432432
@JSName('byteLength')
433-
final int lengthInBytes;
433+
external int get lengthInBytes;
434434

435435
/**
436436
* Returns the offset in bytes into the underlying byte buffer of this view.
437437
*/
438438
@JSName('byteOffset')
439-
final int offsetInBytes;
439+
external int get offsetInBytes;
440440

441441
/**
442442
* Returns the number of bytes in the representation of each element in this
443443
* list.
444444
*/
445445
@JSName('BYTES_PER_ELEMENT')
446-
final int elementSizeInBytes;
446+
external int get elementSizeInBytes;
447447

448448
void _invalidIndex(int index, int length) {
449449
if (index < 0 || index >= length) {
450450
if (this is List) {
451-
var list = this; // Typed as dynamic to avoid warning.
452-
if (length == list.length) {
451+
// Typed as dynamic to avoid warning.
452+
if (length == (this as dynamic).length) {
453453
throw new RangeError.index(index, this);
454454
}
455455
}

0 commit comments

Comments
 (0)