| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library fasta.body_builder; | 5 library fasta.body_builder; |
| 6 | 6 |
| 7 import '../fasta_codes.dart' | 7 import '../fasta_codes.dart' |
| 8 show FastaMessage, codeExpectedButGot, codeExpectedFunctionBody; | 8 show FastaMessage, codeExpectedButGot, codeExpectedFunctionBody; |
| 9 | 9 |
| 10 import '../parser/parser.dart' show FormalParameterType, MemberKind, optional; | 10 import '../parser/parser.dart' show FormalParameterType, MemberKind, optional; |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 @override | 461 @override |
| 462 void handleNoInitializers() { | 462 void handleNoInitializers() { |
| 463 debugEvent("NoInitializers"); | 463 debugEvent("NoInitializers"); |
| 464 } | 464 } |
| 465 | 465 |
| 466 @override | 466 @override |
| 467 void endInitializers(int count, Token beginToken, Token endToken) { | 467 void endInitializers(int count, Token beginToken, Token endToken) { |
| 468 debugEvent("Initializers"); | 468 debugEvent("Initializers"); |
| 469 } | 469 } |
| 470 | 470 |
| 471 DartType _computeReturnTypeContext(MemberBuilder member) { |
| 472 if (member is KernelProcedureBuilder) { |
| 473 if (member.target.kind == ProcedureKind.Factory) { |
| 474 return computeFactoryConstructorReturnType(member.target); |
| 475 } |
| 476 return member.target.function.returnType; |
| 477 } else { |
| 478 assert(member is KernelConstructorBuilder); |
| 479 return null; |
| 480 } |
| 481 } |
| 482 |
| 471 @override | 483 @override |
| 472 void finishFunction( | 484 void finishFunction( |
| 473 FormalParameters formals, AsyncMarker asyncModifier, Statement body) { | 485 FormalParameters formals, AsyncMarker asyncModifier, Statement body) { |
| 474 debugEvent("finishFunction"); | 486 debugEvent("finishFunction"); |
| 475 typePromoter.finished(); | 487 typePromoter.finished(); |
| 476 _typeInferrer.inferFunctionBody( | 488 _typeInferrer.inferFunctionBody( |
| 477 member.target.function.returnType, asyncModifier, body); | 489 _computeReturnTypeContext(member), asyncModifier, body); |
| 478 KernelFunctionBuilder builder = member; | 490 KernelFunctionBuilder builder = member; |
| 479 builder.body = body; | 491 builder.body = body; |
| 480 if (formals?.optional != null) { | 492 if (formals?.optional != null) { |
| 481 Iterator<FormalParameterBuilder> formalBuilders = | 493 Iterator<FormalParameterBuilder> formalBuilders = |
| 482 builder.formals.skip(formals.required.length).iterator; | 494 builder.formals.skip(formals.required.length).iterator; |
| 483 for (VariableDeclaration parameter in formals.optional.formals) { | 495 for (VariableDeclaration parameter in formals.optional.formals) { |
| 484 bool hasMore = formalBuilders.moveNext(); | 496 bool hasMore = formalBuilders.moveNext(); |
| 485 assert(hasMore); | 497 assert(hasMore); |
| 486 VariableDeclaration realParameter = formalBuilders.current.target; | 498 VariableDeclaration realParameter = formalBuilders.current.target; |
| 487 Expression initializer = | 499 Expression initializer = |
| (...skipping 2691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3179 if (starToken == null) { | 3191 if (starToken == null) { |
| 3180 return AsyncMarker.Async; | 3192 return AsyncMarker.Async; |
| 3181 } else { | 3193 } else { |
| 3182 assert(identical(starToken.stringValue, "*")); | 3194 assert(identical(starToken.stringValue, "*")); |
| 3183 return AsyncMarker.AsyncStar; | 3195 return AsyncMarker.AsyncStar; |
| 3184 } | 3196 } |
| 3185 } else { | 3197 } else { |
| 3186 return internalError("Unknown async modifier: $asyncToken"); | 3198 return internalError("Unknown async modifier: $asyncToken"); |
| 3187 } | 3199 } |
| 3188 } | 3200 } |
| OLD | NEW |