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

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: better runtime checks 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 50f81faefccc8ddf16ed1f90ecdecc1c7f503db8..834a3b8722ebee0771624c0fe905aa72d9b87187 100644
--- a/frog/gen.dart
+++ b/frog/gen.dart
@@ -1100,12 +1100,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.
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);
+ writer.writeln('return ${value.code};');
}
return true;
}
« no previous file with comments | « frog/frogsh ('k') | frog/lib/corelib_impl.dart » ('j') | frog/lib/corelib_impl.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698