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

Unified Diff: pkg/analyzer/lib/src/generated/error_verifier.dart

Issue 2871163002: Revert "Allowing `e` of any type in `void f(...) => e` in the analyzer." (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | tests/language/void_arrow_return_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/error_verifier.dart
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index f8a9177bf6be18b66157a50c187d595de2ea631a..ce1dfe702f438e83d9493bd27671865965180383 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -660,8 +660,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
function is PropertyAccessorElement &&
function.isSetter;
if (!isSetterWithImplicitReturn) {
- _checkForReturnOfInvalidType(node.expression, expectedReturnType,
- isArrowFunction: true);
+ _checkForReturnOfInvalidType(node.expression, expectedReturnType);
}
return super.visitExpressionFunctionBody(node);
} finally {
@@ -5599,8 +5598,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
* See [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE].
*/
void _checkForReturnOfInvalidType(
- Expression returnExpression, DartType expectedReturnType,
- {bool isArrowFunction = false}) {
+ Expression returnExpression, DartType expectedReturnType) {
if (_enclosingFunction == null) {
return;
}
@@ -5612,10 +5610,6 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
}
DartType staticReturnType = _computeReturnTypeForMethod(returnExpression);
if (expectedReturnType.isVoid) {
- if (isArrowFunction) {
- // "void f(..) => e" admits all types for "e".
- return;
- }
if (staticReturnType.isVoid ||
staticReturnType.isDynamic ||
staticReturnType.isBottom ||
« no previous file with comments | « no previous file | tests/language/void_arrow_return_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698