| Index: runtime/lib/mirrors.cc
|
| diff --git a/runtime/lib/mirrors.cc b/runtime/lib/mirrors.cc
|
| index e7f709d6fb132bdd3f02a0daf5adc0ef1da0e7d4..be30b5deb8d1184d08c65f9bbff634554e7a01b2 100644
|
| --- a/runtime/lib/mirrors.cc
|
| +++ b/runtime/lib/mirrors.cc
|
| @@ -5,6 +5,7 @@
|
| #include "lib/invocation_mirror.h"
|
| #include "vm/bootstrap_natives.h"
|
| #include "vm/class_finalizer.h"
|
| +#include "vm/compiler.h"
|
| #include "vm/dart_entry.h"
|
| #include "vm/exceptions.h"
|
| #include "vm/object_store.h"
|
| @@ -105,6 +106,22 @@ DEFINE_NATIVE_ENTRY(Mirrors_isLocalPort, 1) {
|
| return Bool::Get(PortMap::IsLocalPort(port_id)).raw();
|
| }
|
|
|
| +static void EnsureConstructorsAreCompiled(const Function& func) {
|
| + if (func.kind() != RawFunction::kConstructor) return;
|
| + const Class& cls = Class::Handle(func.Owner());
|
| + const Error& error = Error::Handle(cls.EnsureIsFinalized(Isolate::Current()));
|
| + if (!error.IsNull()) {
|
| + ThrowInvokeError(error);
|
| + UNREACHABLE();
|
| + }
|
| + if (!func.HasCode()) {
|
| + const Error& error = Error::Handle(Compiler::CompileFunction(func));
|
| + if (!error.IsNull()) {
|
| + ThrowInvokeError(error);
|
| + UNREACHABLE();
|
| + }
|
| + }
|
| +}
|
|
|
| static RawInstance* CreateParameterMirrorList(const Function& func,
|
| const Instance& owner_mirror) {
|
| @@ -134,6 +151,11 @@ static RawInstance* CreateParameterMirrorList(const Function& func,
|
| Object& default_value = Object::Handle();
|
| Object& metadata = Object::Handle();
|
|
|
| + // We force compilation of constructors to ensure the types of initializing
|
| + // formals have been corrected. We do not force the compilation of all types
|
| + // of functions because some have no body, e.g. signature functions.
|
| + EnsureConstructorsAreCompiled(func);
|
| +
|
| // Reparse the function for the following information:
|
| // * The default value of a parameter.
|
| // * Whether a parameters has been deflared as final.
|
|
|