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

Unified Diff: frog/gen.dart

Issue 8534001: Adds typechecking of return values (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merged Created 9 years, 1 month 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: frog/gen.dart
diff --git a/frog/gen.dart b/frog/gen.dart
index 90853e227f8d2a48bccaf6d502dccb0c666fb023..2d74b3a03e9eee334294de98b308ba0bae1cddea 100644
--- a/frog/gen.dart
+++ b/frog/gen.dart
@@ -1103,12 +1103,15 @@ class MethodGenerator implements TreeVisitor {
*/
bool visitReturnStatement(ReturnStatement node) {
if (node.value == null) {
+ // This is essentially "return null".
+ // It can't issue a warning because every type is nullable.
jimhug 2011/11/11 15:02:02 Isn't there a TODO here to fix the language <smile
writer.writeln('return;');
} else {
if (method.isConstructor) {
world.error('return of value not allowed from constructor', node.span);
}
- writer.writeln('return ${visitValue(node.value).code};');
+ var value = visitTypedValue(node.value, method.returnType);
jimhug 2011/11/11 15:02:02 I love the fact that this is essentially your enti
+ writer.writeln('return ${value.code};');
}
return true;
}

Powered by Google App Engine
This is Rietveld 408576698