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

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

Issue 2940453002: Add offsets to the `== null` calls inserted by null-aware desugaring. (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
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 37a10d5653f1fa64395ba27df7b10f99ce8a58fb..74c63a42af18bbf8e68c55d663e6e1c2caf03c31 100644
--- a/pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart
@@ -73,12 +73,13 @@ abstract class Accessor {
/// [voidContext] is true, in which case it may evaluate to anything.
///
/// [type] is the static type of the RHS.
- Expression buildNullAwareAssignment(Expression value, DartType type,
+ Expression buildNullAwareAssignment(
+ Expression value, DartType type, int offset,
{bool voidContext: false}) {
var complexAssignment = startComplexAssignment(value);
if (voidContext) {
var nullAwareCombiner = new KernelConditionalExpression(
- buildIsNull(_makeRead(complexAssignment)),
+ buildIsNull(_makeRead(complexAssignment), offset),
_makeWrite(value, false, complexAssignment),
new NullLiteral());
complexAssignment?.nullAwareCombiner = nullAwareCombiner;
@@ -86,7 +87,7 @@ abstract class Accessor {
}
var tmp = new VariableDeclaration.forValue(_makeRead(complexAssignment));
var nullAwareCombiner = new KernelConditionalExpression(
- buildIsNull(new VariableGet(tmp)),
+ buildIsNull(new VariableGet(tmp), offset),
_makeWrite(value, false, complexAssignment),
new VariableGet(tmp));
complexAssignment?.nullAwareCombiner = nullAwareCombiner;
@@ -348,7 +349,9 @@ class NullAwarePropertyAccessor extends Accessor {
Expression _finish(
Expression body, KernelComplexAssignment complexAssignment) {
var nullAwareGuard = new KernelConditionalExpression(
- buildIsNull(receiverAccess()), new NullLiteral(), body)
+ buildIsNull(receiverAccess(), offsetForToken(token)),
+ new NullLiteral(),
+ body)
..fileOffset = offsetForToken(token);
body = makeLet(receiver, nullAwareGuard);
if (complexAssignment != null) {
@@ -680,7 +683,7 @@ Expression makeBinary(
..fileOffset = offset;
}
-Expression buildIsNull(Expression value, {int offset: TreeNode.noOffset}) {
+Expression buildIsNull(Expression value, int offset) {
Paul Berry 2017/06/12 20:17:23 Note: I changed `offset` to a required argument he
return makeBinary(value, equalsName, null, new NullLiteral(), offset: offset);
}
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart ('k') | pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698