diff --git a/modules/change_detection/src/record.js b/modules/change_detection/src/record.js index 2911236ac0..33462044dd 100644 --- a/modules/change_detection/src/record.js +++ b/modules/change_detection/src/record.js @@ -42,7 +42,7 @@ export class ProtoRecord { dest) { this.recordRange = recordRange; - this.mode = mode; + this._mode = mode; this.funcOrValue = funcOrValue; this.arity = arity; this.dest = dest; @@ -52,6 +52,10 @@ export class ProtoRecord { // The concrete Record instantiated from this ProtoRecord this.recordInConstruction = null; } + + setIsImplicitReceiver() { + this._mode |= RECORD_FLAG_IMPLICIT_RECEIVER; + } } @@ -117,7 +121,7 @@ export class Record { return; } - this._mode = protoRecord.mode; + this._mode = protoRecord._mode; var type = this.type; @@ -160,6 +164,10 @@ export class Record { } } + get isImplicitReceiver() { + return (this._mode & RECORD_FLAG_IMPLICIT_RECEIVER) === RECORD_FLAG_IMPLICIT_RECEIVER; + } + static createMarker(rr:RecordRange) { return new Record(rr, null, null); } diff --git a/modules/change_detection/src/record_range.js b/modules/change_detection/src/record_range.js index 8de73aa024..9fbefa59ca 100644 --- a/modules/change_detection/src/record_range.js +++ b/modules/change_detection/src/record_range.js @@ -1,6 +1,7 @@ import { ProtoRecord, Record, + RECORD_FLAG_IMPLICIT_RECEIVER, RECORD_TYPE_CONST, RECORD_TYPE_INVOKE_CLOSURE, RECORD_TYPE_INVOKE_FORMATTER, @@ -245,8 +246,9 @@ export class RecordRange { for (var record:Record = this.headRecord; record != null; record = record.next) { - - record.updateContext(context); + if (record.isImplicitReceiver) { + record.updateContext(context); + } } } } @@ -287,7 +289,7 @@ class ProtoRecordCreator { } visitImplicitReceiver(ast:ImplicitReceiver, args) { - // do nothing + throw new BaseException('Should never visit an implicit receiver'); } visitLiteralPrimitive(ast:LiteralPrimitive, dest) { @@ -310,7 +312,11 @@ class ProtoRecordCreator { visitAccessMember(ast:AccessMember, dest) { var record = this.construct(RECORD_TYPE_PROPERTY, ast.getter, 0, dest); - ast.receiver.visit(this, new Destination(record, null)); + if (ast.receiver instanceof ImplicitReceiver) { + record.setIsImplicitReceiver(); + } else { + ast.receiver.visit(this, new Destination(record, null)); + } this.add(record); } @@ -324,10 +330,14 @@ class ProtoRecordCreator { visitMethodCall(ast:MethodCall, dest) { var record = this.construct(RECORD_TYPE_INVOKE_METHOD, ast.fn, ast.args.length, dest); - ast.receiver.visit(this, new Destination(record, null)); for (var i = 0; i < ast.args.length; ++i) { ast.args[i].visit(this, new Destination(record, i)); } + if (ast.receiver instanceof ImplicitReceiver) { + record.setIsImplicitReceiver(); + } else { + ast.receiver.visit(this, new Destination(record, null)); + } this.add(record); }