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

Unified Diff: runtime/vm/class_finalizer.cc

Issue 8429013: Verify that user classes do not extend any of Bool, Double, ObjectArray, (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 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 | tests/standalone/standalone.status » ('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 960)
+++ runtime/vm/class_finalizer.cc (working copy)
@@ -263,6 +263,40 @@
class_name.ToCString(),
super_class_name.ToCString());
}
+ // If cls belongs to core lib or to core lib's implementation, restrictions
+ // about allowed interfaces are lifted.
+ if ((cls.library() != Library::CoreLibrary()) &&
+ (cls.library() != Library::CoreImplLibrary())) {
+ // Prevent extending core implementation classes Bool, Double, ObjectArray,
+ // ImmutableArray, GrowableObjectArray, IntegerImplementation, Smi, Mint,
+ // BigInt, OneByteString, TwoByteString, FourByteString.
+ ObjectStore* object_store = Isolate::Current()->object_store();
+ const Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary());
+ const String& integer_implementation_name =
+ String::Handle(String::NewSymbol("IntegerImplementation"));
+ const Class& integer_implementation_class =
+ Class::Handle(core_impl_lib.LookupClass(integer_implementation_name));
+ const String& growable_object_array_name =
+ String::Handle(String::NewSymbol("GrowableObjectArray"));
+ const Class& growable_object_array_class =
+ Class::Handle(core_impl_lib.LookupClass(growable_object_array_name));
+ if ((super_class.raw() == object_store->bool_class()) ||
+ (super_class.raw() == object_store->double_class()) ||
+ (super_class.raw() == object_store->array_class()) ||
+ (super_class.raw() == object_store->immutable_array_class()) ||
+ (super_class.raw() == growable_object_array_class.raw()) ||
+ (super_class.raw() == integer_implementation_class.raw()) ||
+ (super_class.raw() == object_store->smi_class()) ||
+ (super_class.raw() == object_store->mint_class()) ||
+ (super_class.raw() == object_store->bigint_class()) ||
+ (super_class.raw() == object_store->one_byte_string_class()) ||
+ (super_class.raw() == object_store->two_byte_string_class()) ||
+ (super_class.raw() == object_store->four_byte_string_class())) {
+ ReportError("'%s' is not allowed to extend '%s'\n",
+ String::Handle(cls.Name()).ToCString(),
+ String::Handle(super_class.Name()).ToCString());
+ }
+ }
return;
}
« no previous file with comments | « no previous file | tests/standalone/standalone.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698