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

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

Issue 2895063003: Flatten futures when inferring the type of an async function expression. (Closed)
Patch Set: Don't recurse on future-derived types Created 3 years, 7 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
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 // `async`, `async*`, or `sync*`. 455 // `async`, `async*`, or `sync*`.
456 if (isGenerator) { 456 if (isGenerator) {
457 if (isAsync) { 457 if (isAsync) {
458 inferredReturnType = inferrer.wrapType( 458 inferredReturnType = inferrer.wrapType(
459 inferredReturnType, inferrer.coreTypes.streamClass); 459 inferredReturnType, inferrer.coreTypes.streamClass);
460 } else { 460 } else {
461 inferredReturnType = inferrer.wrapType( 461 inferredReturnType = inferrer.wrapType(
462 inferredReturnType, inferrer.coreTypes.iterableClass); 462 inferredReturnType, inferrer.coreTypes.iterableClass);
463 } 463 }
464 } else if (isAsync) { 464 } else if (isAsync) {
465 inferredReturnType = inferrer.wrapType( 465 inferredReturnType = inferrer.wrapFutureType(inferredReturnType);
466 inferredReturnType, inferrer.coreTypes.futureClass);
467 } 466 }
468 } 467 }
469 468
470 // Then the result of inference is `<T0, ..., Tn>(R0 x0, ..., Rn xn) B` with 469 // Then the result of inference is `<T0, ..., Tn>(R0 x0, ..., Rn xn) B` with
471 // type `<T0, ..., Tn>(R0, ..., Rn) -> M’` (with some of the `Ri` and `xi` 470 // type `<T0, ..., Tn>(R0, ..., Rn) -> M’` (with some of the `Ri` and `xi`
472 // denoted as optional or named parameters, if appropriate). 471 // denoted as optional or named parameters, if appropriate).
473 if (needToSetReturnType) { 472 if (needToSetReturnType) {
474 inferrer.instrumentation?.record(Uri.parse(inferrer.uri), fileOffset, 473 inferrer.instrumentation?.record(Uri.parse(inferrer.uri), fileOffset,
475 'returnType', new InstrumentationValueForType(inferredReturnType)); 474 'returnType', new InstrumentationValueForType(inferredReturnType));
476 function.returnType = inferredReturnType; 475 function.returnType = inferredReturnType;
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) { 1289 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) {
1291 var variable = this.variable as KernelVariableDeclaration; 1290 var variable = this.variable as KernelVariableDeclaration;
1292 typeNeeded = 1291 typeNeeded =
1293 inferrer.listener.variableSetEnter(this, typeContext) || typeNeeded; 1292 inferrer.listener.variableSetEnter(this, typeContext) || typeNeeded;
1294 var inferredType = 1293 var inferredType =
1295 inferrer.inferExpression(value, variable._declaredType, typeNeeded); 1294 inferrer.inferExpression(value, variable._declaredType, typeNeeded);
1296 inferrer.listener.variableSetExit(this, inferredType); 1295 inferrer.listener.variableSetExit(this, inferredType);
1297 return inferredType; 1296 return inferredType;
1298 } 1297 }
1299 } 1298 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698