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

Unified Diff: pkg/analyzer/test/src/task/strong/front_end_inference_test.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 side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/test/src/task/strong/front_end_inference_test.dart
diff --git a/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart b/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart
index 4eb4a57b37e07f5b3202d0b90604e48025d6a1e3..ffc750075edb4b27cc5d63473ff001cf303a2aef 100644
--- a/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart
+++ b/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart
@@ -369,6 +369,30 @@ class _InstrumentationVisitor extends RecursiveAstVisitor<Null> {
}
}
+ @override
+ visitFunctionDeclaration(FunctionDeclaration node) {
+ super.visitFunctionDeclaration(node);
+ if (node.element is LocalElement &&
+ node.element.enclosingElement is! CompilationUnitElement) {
+ if (node.returnType == null) {
+ _instrumentation.record(
+ uri,
+ node.name.offset,
+ 'returnType',
+ new _InstrumentationValueForType(
+ node.element.returnType, elementNamer));
+ }
+ var parameters = node.functionExpression.parameters;
+ for (var parameter in parameters.parameters) {
+ // Note: it's tempting to check `parameter.type == null`, but that
+ // doesn't work because of function-typed formal parameter syntax.
+ if (parameter.element.hasImplicitType) {
+ _recordType(parameter.identifier.offset, parameter.element.type);
+ }
+ }
+ }
+ }
+
visitFunctionExpression(FunctionExpression node) {
super.visitFunctionExpression(node);
if (node.parent is! FunctionDeclaration) {

Powered by Google App Engine
This is Rietveld 408576698