| 1229 |
1229 |
if (rb_obj_is_method(body)) {
|
| 1230 |
1230 |
struct METHOD *method = (struct METHOD *)DATA_PTR(body);
|
| 1231 |
1231 |
VALUE rclass = method->rclass;
|
| 1232 |
|
if (rclass != mod) {
|
|
1232 |
if (rclass != mod && !RTEST(rb_class_inherited_p(mod, rclass))) {
|
| 1233 |
1233 |
if (FL_TEST(rclass, FL_SINGLETON)) {
|
| 1234 |
1234 |
rb_raise(rb_eTypeError,
|
| 1235 |
1235 |
"can't bind singleton method to a different class");
|
| 1236 |
1236 |
}
|
| 1237 |
|
if (!RTEST(rb_class_inherited_p(mod, rclass))) {
|
|
1237 |
else {
|
| 1238 |
1238 |
rb_raise(rb_eTypeError,
|
| 1239 |
1239 |
"bind argument must be a subclass of %s",
|
| 1240 |
1240 |
rb_class2name(rclass));
|
| ... | ... | |
| 1461 |
1461 |
struct METHOD *data, *bound;
|
| 1462 |
1462 |
|
| 1463 |
1463 |
TypedData_Get_Struct(method, struct METHOD, &method_data_type, data);
|
| 1464 |
|
if (data->rclass != CLASS_OF(recv)) {
|
| 1465 |
|
if (FL_TEST(data->rclass, FL_SINGLETON)) {
|
| 1466 |
|
rb_raise(rb_eTypeError,
|
| 1467 |
|
"singleton method called for a different object");
|
| 1468 |
|
}
|
| 1469 |
|
if (!rb_obj_is_kind_of(recv, data->rclass)) {
|
| 1470 |
|
rb_raise(rb_eTypeError, "bind argument must be an instance of %s",
|
| 1471 |
|
rb_class2name(data->rclass));
|
| 1472 |
|
}
|
|
1464 |
|
|
1465 |
if (data->rclass != CLASS_OF(recv) &&
|
|
1466 |
!rb_obj_is_kind_of(recv, data->rclass)) {
|
|
1467 |
if (FL_TEST(data->rclass, FL_SINGLETON)) {
|
|
1468 |
rb_raise(rb_eTypeError,
|
|
1469 |
"singleton method called for a different object");
|
|
1470 |
}
|
|
1471 |
else {
|
|
1472 |
rb_raise(rb_eTypeError, "bind argument must be an instance of %s",
|
|
1473 |
rb_class2name(data->rclass));
|
|
1474 |
}
|
| 1473 |
1475 |
}
|
| 1474 |
1476 |
|
| 1475 |
1477 |
method = TypedData_Make_Struct(rb_cMethod, struct METHOD, &method_data_type, bound);
|