Skip to content

Commit 9d32ea0

Browse files
author
John Messerly
committed
fixes #147, add this and super to isStateless
[email protected] Review URL: https://codereview.chromium.org/1117373002
1 parent c58318a commit 9d32ea0

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

pkg/dev_compiler/lib/runtime/dart/collection.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,17 +1626,17 @@ var collection;
16261626
[core.$add](element) {
16271627
dart.as(element, E);
16281628
this[core.$set]((() => {
1629-
let o = this, x = o[core.$length];
1630-
o[core.$length] = dart.notNull(x) + 1;
1629+
let x = this[core.$length];
1630+
this[core.$length] = dart.notNull(x) + 1;
16311631
return x;
16321632
}).bind(this)(), element);
16331633
}
16341634
[core.$addAll](iterable) {
16351635
dart.as(iterable, core.Iterable$(E));
16361636
for (let element of iterable) {
16371637
this[core.$set]((() => {
1638-
let o = this, x = o[core.$length];
1639-
o[core.$length] = dart.notNull(x) + 1;
1638+
let x = this[core.$length];
1639+
this[core.$length] = dart.notNull(x) + 1;
16401640
return x;
16411641
}).bind(this)(), element);
16421642
}
@@ -1645,8 +1645,7 @@ var collection;
16451645
for (let i = 0; dart.notNull(i) < dart.notNull(this[core.$length]); i = dart.notNull(i) + 1) {
16461646
if (dart.equals(this[core.$get](i), element)) {
16471647
this[core.$setRange](i, dart.notNull(this[core.$length]) - 1, this, dart.notNull(i) + 1);
1648-
let o = this;
1649-
o[core.$length] = dart.notNull(o[core.$length]) - 1;
1648+
this[core.$length] = dart.notNull(this[core.$length]) - 1;
16501649
return true;
16511650
}
16521651
}
@@ -1739,8 +1738,7 @@ var collection;
17391738
core.RangeError.checkValidRange(start, end, this[core.$length]);
17401739
let length = dart.notNull(end) - dart.notNull(start);
17411740
this[core.$setRange](start, dart.notNull(this[core.$length]) - dart.notNull(length), this, end);
1742-
let o = this;
1743-
o[core.$length] = dart.notNull(o[core.$length]) - dart.notNull(length);
1741+
this[core.$length] = dart.notNull(this[core.$length]) - dart.notNull(length);
17441742
}
17451743
[core.$fillRange](start, end, fill) {
17461744
if (fill === void 0)
@@ -1853,8 +1851,7 @@ var collection;
18531851
}
18541852
if (!(typeof index == 'number'))
18551853
throw new core.ArgumentError(index);
1856-
let o = this;
1857-
o[core.$length] = dart.notNull(o[core.$length]) + 1;
1854+
this[core.$length] = dart.notNull(this[core.$length]) + 1;
18581855
this[core.$setRange](dart.notNull(index) + 1, this[core.$length], this, index);
18591856
this[core.$set](index, element);
18601857
}
@@ -1871,8 +1868,7 @@ var collection;
18711868
iterable = iterable[core.$toList]();
18721869
}
18731870
let insertionLength = iterable[core.$length];
1874-
let o = this;
1875-
o[core.$length] = dart.notNull(o[core.$length]) + dart.notNull(insertionLength);
1871+
this[core.$length] = dart.notNull(this[core.$length]) + dart.notNull(insertionLength);
18761872
this[core.$setRange](dart.notNull(index) + dart.notNull(insertionLength), this[core.$length], this, index);
18771873
this[core.$setAll](index, iterable);
18781874
}

pkg/dev_compiler/lib/runtime/dart/convert.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1578,7 +1578,7 @@ var convert;
15781578
return new _Utf8StringSinkAdapter(this, this[_stringSink], allowMalformed);
15791579
}
15801580
asStringSink() {
1581-
return new ClosableStringSink.fromStringSink(this[_stringSink], dart.bind(this, 'close'));
1581+
return new ClosableStringSink.fromStringSink(this[_stringSink], this.close.bind(this));
15821582
}
15831583
}
15841584
class _StringCallbackSink extends _StringSinkConversionSink {

pkg/dev_compiler/lib/src/codegen/side_effect_analysis.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import 'package:analyzer/src/generated/element.dart';
2828
/// correctness of a `true` value. However it may return `false` for things
2929
/// that are in fact, stateless.
3030
bool isStateless(Expression node, [AstNode context]) {
31+
// `this` and `super` cannot be reassigned.
32+
if (node is ThisExpression || node is SuperExpression) return true;
3133
if (node is SimpleIdentifier) {
3234
var e = node.staticElement;
3335
if (e is PropertyAccessorElement) e = e.variable;

0 commit comments

Comments
 (0)