Treat messages to id and Class separately.

As id and Class do not point to real objects as such, trying to get the
class from their types doesn't work, so instead send the message to a
"null" class that skips the method checks.
This commit is contained in:
Bill Currie 2012-11-11 17:39:12 +09:00
parent ee28f3869c
commit 96110a0f54
2 changed files with 16 additions and 13 deletions

View file

@ -761,7 +761,7 @@ class_message_response (class_t *class, int class_msg, expr_t *sel)
selector = get_selector (sel);
if (!selector)
return 0;
if (class->type != &type_obj_object) {
if (class && class->type != &type_obj_object) {
while (c) {
for (cat = c->categories; cat; cat = cat->next) {
for (m = cat->methods->head; m; m = m->next) {

View file

@ -2828,19 +2828,22 @@ message_expr (expr_t *receiver, keywordarg_t *message)
if (receiver->type == ex_error)
return receiver;
if (rec_type->type == ev_pointer)
rec_type = rec_type->t.fldptr.type;
if (!is_class (rec_type))
return error (receiver, "not a class/object");
if (self) {
if (!class)
class = extract_class (current_class);
if (rec_type == &type_obj_class)
class_msg = 1;
if (rec_type == &type_id || rec_type == &type_Class) {
} else {
if (!class)
class = rec_type->t.class;
if (rec_type->type == ev_pointer)
rec_type = rec_type->t.fldptr.type;
if (!is_class (rec_type))
return error (receiver, "not a class/object");
if (self) {
if (!class)
class = extract_class (current_class);
if (rec_type == &type_obj_class)
class_msg = 1;
} else {
if (!class)
class = rec_type->t.class;
}
}
}