Feature #2117 ยป fix-class-meta-class-superclass-bind.patch
proc.c | ||
---|---|---|
if (rb_obj_is_method(body)) {
|
||
struct METHOD *method = (struct METHOD *)DATA_PTR(body);
|
||
VALUE rclass = method->rclass;
|
||
if (rclass != mod) {
|
||
if (rclass != mod && !RTEST(rb_class_inherited_p(mod, rclass))) {
|
||
if (FL_TEST(rclass, FL_SINGLETON)) {
|
||
rb_raise(rb_eTypeError,
|
||
"can't bind singleton method to a different class");
|
||
}
|
||
if (!RTEST(rb_class_inherited_p(mod, rclass))) {
|
||
else {
|
||
rb_raise(rb_eTypeError,
|
||
"bind argument must be a subclass of %s",
|
||
rb_class2name(rclass));
|
||
... | ... | |
struct METHOD *data, *bound;
|
||
TypedData_Get_Struct(method, struct METHOD, &method_data_type, data);
|
||
if (data->rclass != CLASS_OF(recv)) {
|
||
if (FL_TEST(data->rclass, FL_SINGLETON)) {
|
||
rb_raise(rb_eTypeError,
|
||
"singleton method called for a different object");
|
||
}
|
||
if (!rb_obj_is_kind_of(recv, data->rclass)) {
|
||
rb_raise(rb_eTypeError, "bind argument must be an instance of %s",
|
||
rb_class2name(data->rclass));
|
||
}
|
||
if (data->rclass != CLASS_OF(recv) &&
|
||
!rb_obj_is_kind_of(recv, data->rclass)) {
|
||
if (FL_TEST(data->rclass, FL_SINGLETON)) {
|
||
rb_raise(rb_eTypeError,
|
||
"singleton method called for a different object");
|
||
}
|
||
else {
|
||
rb_raise(rb_eTypeError, "bind argument must be an instance of %s",
|
||
rb_class2name(data->rclass));
|
||
}
|
||
}
|
||
method = TypedData_Make_Struct(rb_cMethod, struct METHOD, &method_data_type, bound);
|