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

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart

Issue 2904263003: Implement type inference for await expressions in front_end. (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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// This file declares a "shadow hierarchy" of concrete classes which extend 5 /// This file declares a "shadow hierarchy" of concrete classes which extend
6 /// the kernel class hierarchy, adding methods and fields needed by the 6 /// the kernel class hierarchy, adding methods and fields needed by the
7 /// BodyBuilder. 7 /// BodyBuilder.
8 /// 8 ///
9 /// Instances of these classes may be created using the factory methods in 9 /// Instances of these classes may be created using the factory methods in
10 /// `ast_factory.dart`. 10 /// `ast_factory.dart`.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } 103 }
104 104
105 /// Shadow object for [AwaitExpression]. 105 /// Shadow object for [AwaitExpression].
106 class KernelAwaitExpression extends AwaitExpression 106 class KernelAwaitExpression extends AwaitExpression
107 implements KernelExpression { 107 implements KernelExpression {
108 KernelAwaitExpression(Expression operand) : super(operand); 108 KernelAwaitExpression(Expression operand) : super(operand);
109 109
110 @override 110 @override
111 DartType _inferExpression( 111 DartType _inferExpression(
112 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) { 112 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) {
113 // TODO(scheglov): implement. 113 typeNeeded =
114 return typeNeeded ? const DynamicType() : null; 114 inferrer.listener.awaitExpressionEnter(this, typeContext) || typeNeeded;
115 if (!inferrer.typeSchemaEnvironment.isEmptyContext(typeContext)) {
116 typeContext = inferrer.wrapFutureOrType(typeContext);
117 }
118 var inferredType =
119 inferrer.inferExpression(operand, typeContext, typeNeeded);
120 inferredType = inferrer.typeSchemaEnvironment.flattenFutures(inferredType);
121 inferrer.listener.awaitExpressionExit(this, inferredType);
122 return inferredType;
115 } 123 }
116 } 124 }
117 125
118 /// Concrete shadow object representing a statement block in kernel form. 126 /// Concrete shadow object representing a statement block in kernel form.
119 class KernelBlock extends Block implements KernelStatement { 127 class KernelBlock extends Block implements KernelStatement {
120 KernelBlock(List<Statement> statements) : super(statements); 128 KernelBlock(List<Statement> statements) : super(statements);
121 129
122 @override 130 @override
123 void _inferStatement(KernelTypeInferrer inferrer) { 131 void _inferStatement(KernelTypeInferrer inferrer) {
124 inferrer.listener.blockEnter(this); 132 inferrer.listener.blockEnter(this);
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 closureContext.isAsync 1535 closureContext.isAsync
1528 ? inferrer.coreTypes.streamClass 1536 ? inferrer.coreTypes.streamClass
1529 : inferrer.coreTypes.iterableClass); 1537 : inferrer.coreTypes.iterableClass);
1530 } 1538 }
1531 var inferredType = inferrer.inferExpression( 1539 var inferredType = inferrer.inferExpression(
1532 expression, typeContext, closureContext != null); 1540 expression, typeContext, closureContext != null);
1533 closureContext.handleYield(inferrer, isYieldStar, inferredType); 1541 closureContext.handleYield(inferrer, isYieldStar, inferredType);
1534 inferrer.listener.yieldStatementExit(this); 1542 inferrer.listener.yieldStatementExit(this);
1535 } 1543 }
1536 } 1544 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698