OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |