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

Unified Diff: pkg/analyzer/lib/src/kernel/resynthesize.dart

Issue 3006973002: Resynthesize ?? expressions from Kernel. (Closed)
Patch Set: Created 3 years, 4 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 | « no previous file | pkg/analyzer/test/src/summary/resynthesize_kernel_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/kernel/resynthesize.dart
diff --git a/pkg/analyzer/lib/src/kernel/resynthesize.dart b/pkg/analyzer/lib/src/kernel/resynthesize.dart
index 30a2197c528642aa97d1b388adf83f0413e2addf..0931edff0db979af808457f9e5b5aa9d26bb53e7 100644
--- a/pkg/analyzer/lib/src/kernel/resynthesize.dart
+++ b/pkg/analyzer/lib/src/kernel/resynthesize.dart
@@ -262,6 +262,28 @@ class _ExprBuilder {
return AstTestFactory.binaryExpression(left, operator, right);
}
+ if (expr is kernel.Let) {
+ var body = expr.body;
+ if (body is kernel.ConditionalExpression) {
+ var condition = body.condition;
+ var otherwiseExpr = body.otherwise;
+ if (condition is kernel.MethodInvocation) {
+ var equalsReceiver = condition.receiver;
+ if (equalsReceiver is kernel.VariableGet &&
+ condition.name.name == '==' &&
+ condition.arguments.positional.length == 1 &&
+ condition.arguments.positional[0] is kernel.NullLiteral &&
+ otherwiseExpr is kernel.VariableGet &&
+ otherwiseExpr.variable == equalsReceiver.variable) {
+ var left = build(expr.variable.initializer);
+ var right = build(body.then);
+ return AstTestFactory.binaryExpression(
+ left, TokenType.QUESTION_QUESTION, right);
+ }
+ }
+ }
+ }
+
if (expr is kernel.MethodInvocation) {
kernel.Member member = expr.interfaceTarget;
if (member is kernel.Procedure) {
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_kernel_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698