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

Side by Side Diff: pkg/analyzer/lib/src/generated/error_verifier.dart

Issue 2667343005: Infer Null for return type of functions with empty returns. (Closed)
Patch Set: Avoid merge conflict Created 3 years, 10 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 analyzer.src.generated.error_verifier; 5 library analyzer.src.generated.error_verifier;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import "dart:math" as math; 8 import "dart:math" as math;
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 2288 matching lines...) Expand 10 before | Expand all | Expand 10 after
2299 } 2299 }
2300 if (expectedReturnType is InterfaceType && 2300 if (expectedReturnType is InterfaceType &&
2301 expectedReturnType.isDartAsyncFuture) { 2301 expectedReturnType.isDartAsyncFuture) {
2302 DartType futureArgument = expectedReturnType.typeArguments[0]; 2302 DartType futureArgument = expectedReturnType.typeArguments[0];
2303 if (futureArgument.isDynamic || 2303 if (futureArgument.isDynamic ||
2304 futureArgument.isDartCoreNull || 2304 futureArgument.isDartCoreNull ||
2305 futureArgument.isObject) { 2305 futureArgument.isObject) {
2306 return; 2306 return;
2307 } 2307 }
2308 } 2308 }
2309 } else if (expectedReturnType.isDynamic || expectedReturnType.isVoid) { 2309 } else if (expectedReturnType.isDynamic ||
2310 expectedReturnType.isVoid ||
2311 _typeSystem.isSubtypeOf(
2312 expectedReturnType, _typeProvider.futureOrNullType)) {
Jennifer Messerly 2017/02/03 18:47:53 If I have: Future<Null> foo() { return;
Leaf 2017/02/06 18:27:15 Good catch, thanks! Fixed to keep it simple for n
2310 return; 2313 return;
2311 } 2314 }
2312 _hasReturnWithoutValue = true; 2315 _hasReturnWithoutValue = true;
2313 _errorReporter.reportErrorForNode( 2316 _errorReporter.reportErrorForNode(
2314 StaticWarningCode.RETURN_WITHOUT_VALUE, statement); 2317 StaticWarningCode.RETURN_WITHOUT_VALUE, statement);
2315 return; 2318 return;
2316 } else if (_inGenerator) { 2319 } else if (_inGenerator) {
2317 // RETURN_IN_GENERATOR 2320 // RETURN_IN_GENERATOR
2318 _errorReporter.reportErrorForNode( 2321 _errorReporter.reportErrorForNode(
2319 CompileTimeErrorCode.RETURN_IN_GENERATOR, 2322 CompileTimeErrorCode.RETURN_IN_GENERATOR,
(...skipping 4757 matching lines...) Expand 10 before | Expand all | Expand 10 after
7077 class _InvocationCollector extends RecursiveAstVisitor { 7080 class _InvocationCollector extends RecursiveAstVisitor {
7078 final List<String> superCalls = <String>[]; 7081 final List<String> superCalls = <String>[];
7079 7082
7080 @override 7083 @override
7081 visitMethodInvocation(MethodInvocation node) { 7084 visitMethodInvocation(MethodInvocation node) {
7082 if (node.target is SuperExpression) { 7085 if (node.target is SuperExpression) {
7083 superCalls.add(node.methodName.name); 7086 superCalls.add(node.methodName.name);
7084 } 7087 }
7085 } 7088 }
7086 } 7089 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | pkg/analyzer/test/generated/strong_mode_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698