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

Unified Diff: sdk/lib/_internal/compiler/implementation/typechecker.dart

Issue 23583035: Emit a compile-time error when returning a value from a constructor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Include howToFix and example in error message. Created 7 years, 3 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: sdk/lib/_internal/compiler/implementation/typechecker.dart
diff --git a/sdk/lib/_internal/compiler/implementation/typechecker.dart b/sdk/lib/_internal/compiler/implementation/typechecker.dart
index 996b53767321f9c488d966d13d95aab9b4fdcd8f..3c8bae65cb22613fbe268069c912b2f607ddcacf 100644
--- a/sdk/lib/_internal/compiler/implementation/typechecker.dart
+++ b/sdk/lib/_internal/compiler/implementation/typechecker.dart
@@ -1051,7 +1051,10 @@ class TypeCheckerVisitor extends Visitor<DartType> {
// immediately enclosing function.
if (expression != null) {
final expressionType = analyze(expression);
- if (isVoidFunction
+ Element element = elements.currentElement;
+ if (element != null && element.isGenerativeConstructor()) {
+ // The resolver already emitted an error for this expression.
+ } else if (isVoidFunction
&& !types.isAssignable(expressionType, types.voidType)) {
reportTypeWarning(expression, MessageKind.RETURN_VALUE_IN_VOID);
} else {

Powered by Google App Engine
This is Rietveld 408576698