Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(600)

Unified Diff: pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart

Issue 2938443003: Add type inference for assignments to `this[...]` (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart ('k') | pkg/front_end/test/fasta/kompile.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart
diff --git a/pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart b/pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart
index 287a9763bb76344a49ff2649178ee14d4f79978b..6e8767f7b8367f077db547497ed19c42029f312e 100644
--- a/pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart
@@ -517,10 +517,13 @@ class ThisIndexAccessor extends Accessor {
Expression _makeSimpleWrite(Expression value, bool voidContext,
KernelComplexAssignment complexAssignment) {
- if (!voidContext) return _makeWriteAndReturn(value);
- return new KernelMethodInvocation(new ThisExpression(), indexSetName,
+ if (!voidContext) return _makeWriteAndReturn(value, complexAssignment);
+ var write = new KernelMethodInvocation(new ThisExpression(), indexSetName,
new KernelArguments(<Expression>[index, value]),
- interfaceTarget: setter);
+ interfaceTarget: setter)
+ ..fileOffset = offsetForToken(token);
+ complexAssignment?.write = write;
+ return write;
}
indexAccess() {
@@ -528,34 +531,52 @@ class ThisIndexAccessor extends Accessor {
return new VariableGet(indexVariable);
}
- Expression _makeRead(KernelComplexAssignment complexAssignment) =>
- new KernelMethodInvocation(new ThisExpression(), indexGetName,
- new KernelArguments(<Expression>[indexAccess()]),
- interfaceTarget: getter);
+ Expression _makeRead(KernelComplexAssignment complexAssignment) {
+ var read = new KernelMethodInvocation(new ThisExpression(), indexGetName,
+ new KernelArguments(<Expression>[indexAccess()]),
+ interfaceTarget: getter)
+ ..fileOffset = offsetForToken(token);
+ complexAssignment?.read = read;
+ return read;
+ }
Expression _makeWrite(Expression value, bool voidContext,
KernelComplexAssignment complexAssignment) {
- if (!voidContext) return _makeWriteAndReturn(value);
- return new KernelMethodInvocation(new ThisExpression(), indexSetName,
+ if (!voidContext) return _makeWriteAndReturn(value, complexAssignment);
+ var write = new KernelMethodInvocation(new ThisExpression(), indexSetName,
new KernelArguments(<Expression>[indexAccess(), value]),
- interfaceTarget: setter);
+ interfaceTarget: setter)
+ ..fileOffset = offsetForToken(token);
+ complexAssignment?.write = write;
+ return write;
}
- _makeWriteAndReturn(Expression value) {
+ _makeWriteAndReturn(
+ Expression value, KernelComplexAssignment complexAssignment) {
var valueVariable = new VariableDeclaration.forValue(value);
- var dummy = new VariableDeclaration.forValue(new KernelMethodInvocation(
+ var write = new KernelMethodInvocation(
new ThisExpression(),
indexSetName,
new KernelArguments(
<Expression>[indexAccess(), new VariableGet(valueVariable)]),
- interfaceTarget: setter));
+ interfaceTarget: setter)
+ ..fileOffset = offsetForToken(token);
+ complexAssignment?.write = write;
+ var dummy = new VariableDeclaration.forValue(write);
return makeLet(
valueVariable, makeLet(dummy, new VariableGet(valueVariable)));
}
Expression _finish(
- Expression body, KernelComplexAssignment complexAssignment) =>
- makeLet(indexVariable, body);
+ Expression body, KernelComplexAssignment complexAssignment) {
+ var desugared = makeLet(indexVariable, body);
+ if (complexAssignment != null) {
+ complexAssignment.desugared = desugared;
+ return complexAssignment;
+ } else {
+ return desugared;
+ }
+ }
}
class SuperIndexAccessor extends Accessor {
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart ('k') | pkg/front_end/test/fasta/kompile.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698