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

Unified Diff: runtime/vm/class_finalizer.cc

Issue 10696013: Consider upper bounds of type parameters in type checks. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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/flow_graph_compiler_ia32.cc » ('j') | runtime/vm/object.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/class_finalizer.cc
===================================================================
--- runtime/vm/class_finalizer.cc (revision 9186)
+++ runtime/vm/class_finalizer.cc (working copy)
@@ -434,14 +434,10 @@
TypeArguments::Handle(factory_signature_class.type_parameters());
const TypeArguments& actual_type_parameters =
TypeArguments::Handle(factory_class.type_parameters());
- const TypeArguments& expected_type_parameter_bounds =
- TypeArguments::Handle(factory_signature_class.type_parameter_bounds());
- const TypeArguments& actual_type_parameter_bounds =
- TypeArguments::Handle(factory_class.type_parameter_bounds());
+ const bool check_type_parameter_bounds = true;
if (!AbstractTypeArguments::AreIdentical(expected_type_parameters,
- actual_type_parameters) ||
- !AbstractTypeArguments::AreIdentical(expected_type_parameter_bounds,
- actual_type_parameter_bounds)) {
+ actual_type_parameters,
+ check_type_parameter_bounds)) {
const String& interface_name = String::Handle(interface.Name());
const String& factory_name = String::Handle(factory_class.Name());
const Script& script = Script::Handle(interface.script());
@@ -454,13 +450,15 @@
}
}
// Verify that the type parameters of the factory class and of the interface
- // have identical names.
+ // have identical names, but not necessarily identical bounds.
const TypeArguments& interface_type_parameters =
TypeArguments::Handle(interface.type_parameters());
const TypeArguments& factory_type_parameters =
TypeArguments::Handle(factory_class.type_parameters());
+ const bool check_type_parameter_bounds = false;
if (!AbstractTypeArguments::AreIdentical(interface_type_parameters,
- factory_type_parameters)) {
+ factory_type_parameters,
+ check_type_parameter_bounds)) {
const String& interface_name = String::Handle(interface.Name());
const String& factory_name = String::Handle(factory_class.Name());
const Script& script = Script::Handle(interface.script());
@@ -638,7 +636,7 @@
// parameterized class.
const intptr_t offset = parameterized_class.NumTypeArguments() -
parameterized_class.NumTypeParameters();
- type_parameter.set_index(type_parameter.Index() + offset);
+ type_parameter.set_index(type_parameter.index() + offset);
type_parameter.set_is_finalized();
// We do not canonicalize type parameters.
return type_parameter.raw();
@@ -904,19 +902,21 @@
// Resolve and finalize the upper bounds of the type parameters of class cls.
void ClassFinalizer::ResolveAndFinalizeUpperBounds(const Class& cls) {
const intptr_t num_type_params = cls.NumTypeParameters();
+ TypeParameter& type_param = TypeParameter::Handle();
AbstractType& bound = AbstractType::Handle();
- const AbstractTypeArguments& bounds =
- AbstractTypeArguments::Handle(cls.type_parameter_bounds());
- ASSERT((bounds.IsNull() && (num_type_params == 0)) ||
- (bounds.Length() == num_type_params));
+ const AbstractTypeArguments& type_params =
+ AbstractTypeArguments::Handle(cls.type_parameters());
+ ASSERT((type_params.IsNull() && (num_type_params == 0)) ||
+ (type_params.Length() == num_type_params));
for (intptr_t i = 0; i < num_type_params; i++) {
- bound = bounds.TypeAt(i);
+ type_param ^= type_params.TypeAt(i);
+ bound = type_param.bound();
if (bound.IsFinalized()) {
continue;
}
ResolveType(cls, bound, kFinalize);
bound = FinalizeType(cls, bound, kFinalize);
- bounds.SetTypeAt(i, bound);
+ type_param.set_bound(bound);
}
}
« no previous file with comments | « no previous file | runtime/vm/flow_graph_compiler_ia32.cc » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698