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

Unified Diff: runtime/vm/class_finalizer.cc

Issue 23295020: Fix bound checking in self referencing type (issue 12553). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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 | tests/language/f_bounded_quantification4_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/class_finalizer.cc
===================================================================
--- runtime/vm/class_finalizer.cc (revision 26439)
+++ runtime/vm/class_finalizer.cc (working copy)
@@ -648,10 +648,14 @@
ASSERT(type_param.IsFinalized());
declared_bound = type_param.bound();
if (!declared_bound.IsObjectType() && !declared_bound.IsDynamicType()) {
+ if (!declared_bound.IsFinalized() && !declared_bound.IsBeingFinalized()) {
+ declared_bound = FinalizeType(cls, declared_bound, kCanonicalize);
+ type_param.set_bound(declared_bound);
+ }
+ ASSERT(declared_bound.IsFinalized() || declared_bound.IsBeingFinalized());
Error& malformed_error = Error::Handle();
// Note that the bound may be malformed, in which case the bound check
// will return an error and the bound check will be postponed to run time.
- // Note also that the bound may still be unfinalized.
if (declared_bound.IsInstantiated()) {
instantiated_bound = declared_bound.raw();
} else {
@@ -821,15 +825,26 @@
// argument vector.
const intptr_t offset = num_type_arguments - num_type_parameters;
AbstractType& type_arg = AbstractType::Handle(Type::DynamicType());
+ for (intptr_t i = 0; i < offset; i++) {
+ // Temporarily set the type arguments of the super classes to dynamic.
+ full_arguments.SetTypeAt(i, type_arg);
+ }
for (intptr_t i = 0; i < num_type_parameters; i++) {
// If no type parameters were provided, a raw type is desired, so we
- // create a vector of DynamicType.
+ // create a vector of dynamic.
if (!arguments.IsNull()) {
type_arg = arguments.TypeAt(i);
}
ASSERT(type_arg.IsFinalized()); // Index of type parameter is adjusted.
full_arguments.SetTypeAt(offset + i, type_arg);
}
+ // Replace the compile-time argument vector (of length zero or
+ // num_type_parameters) of this type being finalized with the still
+ // unfinalized run-time argument vector (of length num_type_arguments).
+ // This type being finalized may be recursively reached via bounds
+ // checking, in which case type arguments of super classes will be seen
+ // as dynamic.
+ parameterized_type.set_arguments(full_arguments);
// If the type class is a signature class, the full argument vector
// must include the argument vector of the super type.
// If the signature class is a function type alias, it is also the owner
« no previous file with comments | « no previous file | tests/language/f_bounded_quantification4_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698