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

Unified Diff: runtime/lib/mirrors.cc

Issue 22633005: Make reflectClass(dynamic) throw an illegal argument exception. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase 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 | sdk/lib/mirrors/mirrors.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/mirrors.cc
diff --git a/runtime/lib/mirrors.cc b/runtime/lib/mirrors.cc
index e0c8b2327c4e75efe5ff64fc4e49c3e10a4ee74f..ed78b7bbfe150d5073e390c1a46cc88800bbbff1 100644
--- a/runtime/lib/mirrors.cc
+++ b/runtime/lib/mirrors.cc
@@ -187,6 +187,8 @@ static RawFunction* CallMethod(const Class& cls) {
static RawInstance* CreateClassMirror(const Class& cls,
const AbstractType& type,
const Instance& owner_mirror) {
+ ASSERT(!cls.IsDynamicClass() && !cls.IsVoidClass());
+
if (cls.IsSignatureClass()) {
if (cls.IsCanonicalSignatureClass()) {
// We represent function types as canonical signature classes.
@@ -305,6 +307,12 @@ DEFINE_NATIVE_ENTRY(Mirrors_makeLocalClassMirror, 1) {
GET_NON_NULL_NATIVE_ARGUMENT(Type, type, arguments->NativeArgAt(0));
const Class& cls = Class::Handle(type.type_class());
ASSERT(!cls.IsNull());
+ if (cls.IsDynamicClass() || cls.IsVoidClass()) {
+ const Array& args = Array::Handle(Array::New(1));
+ args.SetAt(0, type);
+ Exceptions::ThrowByType(Exceptions::kArgument, args);
+ UNREACHABLE();
+ }
// Strip the type for generics only.
if (cls.NumTypeParameters() == 0) {
return CreateClassMirror(cls,
@@ -561,15 +569,15 @@ DEFINE_NATIVE_ENTRY(LibraryMirror_members, 2) {
entry = entries.GetNext();
if (entry.IsClass()) {
const Class& klass = Class::Cast(entry);
- if (!klass.IsCanonicalSignatureClass()) {
- // The various implementations of public classes don't always have the
- // expected superinterfaces or other properties, so we filter them out.
- if (!RawObject::IsImplementationClassId(klass.id())) {
- member_mirror = CreateClassMirror(klass,
- AbstractType::Handle(),
- owner_mirror);
- member_mirrors.Add(member_mirror);
- }
+ // We filter out implementation classes like Smi, Mint, Bignum,
+ // OneByteString; function signature classes; and dynamic.
+ if (!klass.IsCanonicalSignatureClass() &&
+ !klass.IsDynamicClass() &&
+ !RawObject::IsImplementationClassId(klass.id())) {
+ member_mirror = CreateClassMirror(klass,
+ AbstractType::Handle(),
+ owner_mirror);
+ member_mirrors.Add(member_mirror);
}
} else if (entry.IsField()) {
const Field& field = Field::Cast(entry);
« no previous file with comments | « no previous file | sdk/lib/mirrors/mirrors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698