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

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

Issue 2950213002: Infer the return types of local functions where appropriate. (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) 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 8 show
9 FastaMessage, 9 FastaMessage,
10 codeConstFieldWithoutInitializer, 10 codeConstFieldWithoutInitializer,
(...skipping 2414 matching lines...) Expand 10 before | Expand all | Expand 10 after
2425 ..fileOffset = formals.charOffset 2425 ..fileOffset = formals.charOffset
2426 ..fileEndOffset = endToken.charOffset)); 2426 ..fileEndOffset = endToken.charOffset));
2427 } 2427 }
2428 2428
2429 @override 2429 @override
2430 void endFunctionDeclaration(Token token) { 2430 void endFunctionDeclaration(Token token) {
2431 debugEvent("FunctionDeclaration"); 2431 debugEvent("FunctionDeclaration");
2432 FunctionNode function = pop(); 2432 FunctionNode function = pop();
2433 exitLocalScope(); 2433 exitLocalScope();
2434 var declaration = pop(); 2434 var declaration = pop();
2435 var returnType = pop() ?? const DynamicType(); 2435 var returnType = pop();
2436 var hasImplicitReturnType = returnType == null;
2437 returnType ??= const DynamicType();
2436 pop(); // Modifiers. 2438 pop(); // Modifiers.
2437 exitFunction(); 2439 exitFunction();
2438 if (declaration is FunctionDeclaration) { 2440 if (declaration is FunctionDeclaration) {
2441 KernelFunctionDeclaration.setHasImplicitReturnType(
2442 declaration, hasImplicitReturnType);
2439 function.returnType = returnType; 2443 function.returnType = returnType;
2440 declaration.variable.type = function.functionType; 2444 declaration.variable.type = function.functionType;
2441 declaration.function = function; 2445 declaration.function = function;
2442 function.parent = declaration; 2446 function.parent = declaration;
2443 } else { 2447 } else {
2444 // If [declaration] isn't a [FunctionDeclaration], it must be because 2448 // If [declaration] isn't a [FunctionDeclaration], it must be because
2445 // there was a compile-time error. 2449 // there was a compile-time error.
2446 2450
2447 // TODO(paulberry): ensure that when integrating with analyzer, type 2451 // TODO(paulberry): ensure that when integrating with analyzer, type
2448 // inference is still performed for the dropped declaration. 2452 // inference is still performed for the dropped declaration.
(...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after
3682 if (starToken == null) { 3686 if (starToken == null) {
3683 return AsyncMarker.Async; 3687 return AsyncMarker.Async;
3684 } else { 3688 } else {
3685 assert(identical(starToken.stringValue, "*")); 3689 assert(identical(starToken.stringValue, "*"));
3686 return AsyncMarker.AsyncStar; 3690 return AsyncMarker.AsyncStar;
3687 } 3691 }
3688 } else { 3692 } else {
3689 return internalError("Unknown async modifier: $asyncToken"); 3693 return internalError("Unknown async modifier: $asyncToken");
3690 } 3694 }
3691 } 3695 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698