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

Unified Diff: pkg/compiler/lib/src/typechecker.dart

Issue 2866213004: Allowing `e` of any type in `void f(...) => e` in dart2js. (Closed)
Patch Set: Rebase again 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/typechecker.dart
diff --git a/pkg/compiler/lib/src/typechecker.dart b/pkg/compiler/lib/src/typechecker.dart
index cbb5c246a66d1ee357fc11a5a80400aed921869d..ca3ef3fe1b424bd54886fd99c01c3d4d4c110496 100644
--- a/pkg/compiler/lib/src/typechecker.dart
+++ b/pkg/compiler/lib/src/typechecker.dart
@@ -1707,7 +1707,10 @@ class TypeCheckerVisitor extends Visitor<ResolutionDartType> {
}
if (expectedReturnType.isVoid &&
!types.isAssignable(expressionType, const ResolutionVoidType())) {
- reportTypeWarning(expression, MessageKind.RETURN_VALUE_IN_VOID);
+ // In `void f(...) => e`, `e` can have any type.
+ if (!node.isArrowBody) {
+ reportTypeWarning(expression, MessageKind.RETURN_VALUE_IN_VOID);
+ }
} else {
checkAssignable(expression, expressionType, expectedReturnType);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698