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

Unified Diff: runtime/lib/mirrors.cc

Issue 26346002: Correctly report the type of initializing formals declared without an explicit type to be the type … (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 | « no previous file | runtime/vm/parser.cc » ('j') | runtime/vm/parser.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « no previous file | runtime/vm/parser.cc » ('j') | runtime/vm/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698