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

Unified Diff: runtime/vm/object.cc

Issue 2806893002: Make finalization of recursive function types more robust, especially since (Closed)
Patch Set: updated tests status and sync Created 3 years, 8 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/class_finalizer.cc ('k') | tests/language/language_kernel.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index c7472e4a7ee1d0d88352f9ed52bf28c9bc27dc8e..66fc98ee3bf1ad257738807ca2870329c91296f0 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -16875,6 +16875,12 @@ bool Type::IsInstantiated(Genericity genericity, TrailPtr trail) const {
if (HasResolvedTypeClass()) {
const Class& cls = Class::Handle(type_class());
len = cls.NumTypeParameters(); // Check the type parameters only.
+ if (len > num_type_args) {
+ // This type has the wrong number of arguments and is not finalized yet.
+ // Type arguments are reset to null when finalizing such a type.
+ ASSERT(!IsFinalized());
+ len = num_type_args;
+ }
}
return (len == 0) ||
args.IsSubvectorInstantiated(num_type_args - len, len, genericity,
@@ -16921,10 +16927,12 @@ RawAbstractType* Type::InstantiateFrom(
const LanguageError& bound_error = LanguageError::Handle(zone, error());
instantiated_type.set_error(bound_error);
}
- // If this type is a function type, instantiate its signature.
+ // For a function type, possibly instantiate and set its signature.
if (!sig_fun.IsNull()) {
- // If we are finalizing a typedef, do not yet instantiate its signature.
- // Other function types should never be instantiated while unfinalized.
+ // If we are finalizing a typedef, do not yet instantiate its signature,
+ // since it gets instantiated just before the type is marked as finalized.
+ // Other function types should never get instantiated while unfinalized,
+ // even while checking bounds of recursive types.
if (IsFinalized()) {
// A generic typedef may actually declare an instantiated signature.
if (!sig_fun.HasInstantiatedSignature()) {
@@ -16932,7 +16940,8 @@ RawAbstractType* Type::InstantiateFrom(
space);
}
} else {
- ASSERT(cls.IsTypedefClass());
+ // The Kernel frontend does not keep the information that a function type
+ // is a typedef, so we cannot assert that cls.IsTypedefClass().
}
instantiated_type.set_signature(sig_fun);
}
« no previous file with comments | « runtime/vm/class_finalizer.cc ('k') | tests/language/language_kernel.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698