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

Unified Diff: runtime/lib/error.cc

Issue 8416052: Verify that user classes/interfaces do not extend/implement any of bool, num, (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
Index: runtime/lib/error.cc
===================================================================
--- runtime/lib/error.cc (revision 921)
+++ runtime/lib/error.cc (working copy)
@@ -216,28 +216,24 @@
}
-// Check that the type of the given object is allowed in conditional context.
+// Report that the type of the given object is not bool in conditional context.
// Arg0: index of the token of the assignment (source location).
-// Arg1: object being checked.
-// Return value: checked value, otherwise allocate and throw a TypeError.
-DEFINE_RUNTIME_ENTRY(ConditionTypeCheck, 2) {
+// Arg1: bad object.
+// Return value: none, throws a TypeError.
+DEFINE_RUNTIME_ENTRY(ConditionTypeError, 2) {
ASSERT(arguments.Count() ==
- kConditionTypeCheckRuntimeEntry.argument_count());
+ kConditionTypeErrorRuntimeEntry.argument_count());
intptr_t location = Smi::CheckedHandle(arguments.At(0)).Value();
const Instance& src_instance = Instance::CheckedHandle(arguments.At(1));
-
+ ASSERT(src_instance.IsNull() || !src_instance.IsBool());
const char* msg = "boolean expression";
- if (src_instance.IsNull() || !src_instance.IsBool()) {
- const Type& bool_interface = Type::Handle(Type::BoolInterface());
- const Type& src_type = Type::Handle(src_instance.GetType());
- const String& src_type_name = String::Handle(src_type.Name());
- const String& bool_type_name = String::Handle(bool_interface.Name());
- ThrowTypeError(location, src_type_name, bool_type_name,
- String::Handle(String::NewSymbol(msg)));
- UNREACHABLE();
- }
-
- arguments.SetReturn(src_instance);
+ const Type& bool_interface = Type::Handle(Type::BoolInterface());
+ const Type& src_type = Type::Handle(src_instance.GetType());
+ const String& src_type_name = String::Handle(src_type.Name());
+ const String& bool_type_name = String::Handle(bool_interface.Name());
+ ThrowTypeError(location, src_type_name, bool_type_name,
+ String::Handle(String::NewSymbol(msg)));
+ UNREACHABLE();
}

Powered by Google App Engine
This is Rietveld 408576698