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

Unified Diff: runtime/vm/class_finalizer.cc

Issue 1219023002: Redirection type of a redirecting factory can be deferred (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Add test case Created 5 years, 6 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') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/class_finalizer.cc
diff --git a/runtime/vm/class_finalizer.cc b/runtime/vm/class_finalizer.cc
index 46f3f4dcbaa47b0bc8055b80a7a5b514bda8204f..4af663639458e768d06615a0294f9662ee7ee2f3 100644
--- a/runtime/vm/class_finalizer.cc
+++ b/runtime/vm/class_finalizer.cc
@@ -248,6 +248,18 @@ void ClassFinalizer::VerifyBootstrapClasses() {
#endif // defined(DART_NO_SNAPSHOT).
+static bool IsLoaded(const Type& type) {
+ if (type.HasResolvedTypeClass()) {
+ return true;
+ }
+ const UnresolvedClass& unresolved_class =
+ UnresolvedClass::Handle(type.unresolved_class());
+ const LibraryPrefix& prefix =
+ LibraryPrefix::Handle(unresolved_class.library_prefix());
+ return prefix.IsNull() || prefix.is_loaded();
+}
+
+
// Resolve unresolved_class in the library of cls, or return null.
RawClass* ClassFinalizer::ResolveClass(
const Class& cls,
@@ -275,7 +287,7 @@ void ClassFinalizer::ResolveRedirectingFactory(const Class& cls,
const Function& target = Function::Handle(factory.RedirectionTarget());
if (target.IsNull()) {
Type& type = Type::Handle(factory.RedirectionType());
- if (!type.IsMalformed()) {
+ if (!type.IsMalformed() && IsLoaded(type)) {
const GrowableObjectArray& visited_factories =
GrowableObjectArray::Handle(GrowableObjectArray::New());
ResolveRedirectingFactoryTarget(cls, factory, visited_factories);
@@ -1498,9 +1510,13 @@ void ClassFinalizer::ResolveAndFinalizeMemberTypes(const Class& cls) {
// The function may be a still unresolved redirecting factory. Do not
// yet try to resolve it in order to avoid cycles in class finalization.
// However, the redirection type should be finalized.
+ // If the redirection type is from a deferred library and is not
+ // yet loaded, do not attempt to resolve.
Type& type = Type::Handle(I, function.RedirectionType());
- type ^= FinalizeType(cls, type, kCanonicalize);
- function.SetRedirectionType(type);
+ if (IsLoaded(type)) {
+ type ^= FinalizeType(cls, type, kCanonicalize);
+ function.SetRedirectionType(type);
+ }
}
} else if (function.IsGetterFunction() ||
function.IsImplicitGetterFunction()) {
« no previous file with comments | « no previous file | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698