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

Unified Diff: runtime/vm/flow_graph_builder.cc

Issue 10784020: Revert fix for type checking of void type, because some top level tests fail. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 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 | « runtime/vm/debugger_api_impl_test.cc ('k') | runtime/vm/flow_graph_compiler_ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_builder.cc
===================================================================
--- runtime/vm/flow_graph_builder.cc (revision 9672)
+++ runtime/vm/flow_graph_builder.cc (working copy)
@@ -340,6 +340,16 @@
return true;
}
+ // It is a compile-time error to explicitly return a value (including null)
+ // from a void function. However, functions that do not explicitly return a
+ // value, implicitly return null. This includes void functions. Therefore, we
+ // skip the type test here and trust the parser to only return null in void
+ // function.
+ if (dst_type.IsVoidType()) {
+ // TODO(regis): Should we perform this null test at run-time?
+ return true;
+ }
+
// Do not perform type check elimination if this optimization is turned off.
if (!FLAG_eliminate_type_checks) {
return false;
@@ -352,31 +362,15 @@
return false;
}
- // If the value is the null constant, its type (NullType) is more specific
- // than the destination type, even if the destination type is the void type,
- // since a void function is allowed to return null.
- if (value->IsConstant() && value->AsConstant()->value().IsNull()) {
- return true;
- }
-
- // Functions that do not explicitly return a value, implicitly return null,
- // except generative constructors, which return the object being constructed.
- // It is therefore acceptable for void functions to return null.
- // In case of a null constant, we have already returned true above, else we
- // return false here.
- if (dst_type.IsVoidType()) {
- return false;
- }
-
// Consider the static type of the value.
const AbstractType& static_type = AbstractType::Handle(value->StaticType());
ASSERT(!static_type.IsMalformed());
- // If the static type of the value is void, we are type checking the result of
- // a void function, which was checked to be null at the return statement
- // inside the function.
+ // If the static type of the value is void, the only allowed value is null,
+ // which must be verified by the type test.
+ // TODO(regis): Eliminate the test if the value is constant null.
if (static_type.IsVoidType()) {
- return true;
+ return false;
}
// If the static type of the value is NullType, the type test is eliminated.
« no previous file with comments | « runtime/vm/debugger_api_impl_test.cc ('k') | runtime/vm/flow_graph_compiler_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698