Index: runtime/lib/isolate.cc |
diff --git a/runtime/lib/isolate.cc b/runtime/lib/isolate.cc |
index 154ad01b042ac93b625d4ea7373a792dec59cf08..0f7da54201652a3f4787731a780d952e7e8f8023 100644 |
--- a/runtime/lib/isolate.cc |
+++ b/runtime/lib/isolate.cc |
@@ -215,30 +215,22 @@ static RawObject* Spawn(NativeArguments* arguments, IsolateSpawnState* state) { |
DEFINE_NATIVE_ENTRY(Isolate_spawnFunction, 1) { |
GET_NON_NULL_NATIVE_ARGUMENT(Instance, closure, arguments->NativeArgAt(0)); |
- bool throw_exception = false; |
- Function& func = Function::Handle(); |
if (closure.IsClosure()) { |
+ Function& func = Function::Handle(); |
func = Closure::function(closure); |
- const Class& cls = Class::Handle(func.Owner()); |
- if (!func.IsClosureFunction() || !func.is_static() || !cls.IsTopLevel()) { |
- throw_exception = true; |
- } |
- } else { |
- throw_exception = true; |
- } |
- if (throw_exception) { |
- const String& msg = String::Handle(String::New( |
- "Isolate.spawn expects to be passed a top-level function")); |
- Exceptions::ThrowArgumentError(msg); |
- } |
- |
+ if (func.IsImplicitClosureFunction() && func.is_static()) { |
#if defined(DEBUG) |
- Context& ctx = Context::Handle(); |
- ctx = Closure::context(closure); |
- ASSERT(ctx.num_variables() == 0); |
+ Context& ctx = Context::Handle(); |
+ ctx = Closure::context(closure); |
+ ASSERT(ctx.num_variables() == 0); |
#endif |
- |
- return Spawn(arguments, new IsolateSpawnState(func)); |
+ return Spawn(arguments, new IsolateSpawnState(func)); |
+ } |
+ } |
+ const String& msg = String::Handle(String::New( |
+ "Isolate.spawn expects to be passed a static or top-level function")); |
+ Exceptions::ThrowArgumentError(msg); |
+ return Object::null(); |
} |