Check if bindable against the refined target [Bug #16617]
This commit is contained in:
parent
0f05b234fb
commit
e3e96e3faa
@ -3224,6 +3224,7 @@ proc.$(OBJEXT): $(top_srcdir)/internal/array.h
|
|||||||
proc.$(OBJEXT): $(top_srcdir)/internal/class.h
|
proc.$(OBJEXT): $(top_srcdir)/internal/class.h
|
||||||
proc.$(OBJEXT): $(top_srcdir)/internal/compilers.h
|
proc.$(OBJEXT): $(top_srcdir)/internal/compilers.h
|
||||||
proc.$(OBJEXT): $(top_srcdir)/internal/error.h
|
proc.$(OBJEXT): $(top_srcdir)/internal/error.h
|
||||||
|
proc.$(OBJEXT): $(top_srcdir)/internal/eval.h
|
||||||
proc.$(OBJEXT): $(top_srcdir)/internal/gc.h
|
proc.$(OBJEXT): $(top_srcdir)/internal/gc.h
|
||||||
proc.$(OBJEXT): $(top_srcdir)/internal/imemo.h
|
proc.$(OBJEXT): $(top_srcdir)/internal/imemo.h
|
||||||
proc.$(OBJEXT): $(top_srcdir)/internal/object.h
|
proc.$(OBJEXT): $(top_srcdir)/internal/object.h
|
||||||
|
5
proc.c
5
proc.c
@ -14,6 +14,7 @@
|
|||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "internal/class.h"
|
#include "internal/class.h"
|
||||||
#include "internal/error.h"
|
#include "internal/error.h"
|
||||||
|
#include "internal/eval.h"
|
||||||
#include "internal/object.h"
|
#include "internal/object.h"
|
||||||
#include "internal/proc.h"
|
#include "internal/proc.h"
|
||||||
#include "internal/symbol.h"
|
#include "internal/symbol.h"
|
||||||
@ -2366,6 +2367,10 @@ convert_umethod_to_method_components(VALUE method, VALUE recv, VALUE *methclass_
|
|||||||
VALUE iclass = data->me->defined_class;
|
VALUE iclass = data->me->defined_class;
|
||||||
VALUE klass = CLASS_OF(recv);
|
VALUE klass = CLASS_OF(recv);
|
||||||
|
|
||||||
|
if (RB_TYPE_P(methclass, T_MODULE)) {
|
||||||
|
VALUE refined_class = rb_refinement_module_get_refined_class(methclass);
|
||||||
|
if (!NIL_P(refined_class)) methclass = refined_class;
|
||||||
|
}
|
||||||
if (!RB_TYPE_P(methclass, T_MODULE) &&
|
if (!RB_TYPE_P(methclass, T_MODULE) &&
|
||||||
methclass != CLASS_OF(recv) && !rb_obj_is_kind_of(recv, methclass)) {
|
methclass != CLASS_OF(recv) && !rb_obj_is_kind_of(recv, methclass)) {
|
||||||
if (FL_TEST(methclass, FL_SINGLETON)) {
|
if (FL_TEST(methclass, FL_SINGLETON)) {
|
||||||
|
@ -2386,6 +2386,25 @@ class TestRefinement < Test::Unit::TestCase
|
|||||||
assert_equal(0, Bug13446::GenericEnumerable.new.sum)
|
assert_equal(0, Bug13446::GenericEnumerable.new.sum)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_unbound_refine_method
|
||||||
|
a = EnvUtil.labeled_class("A") do
|
||||||
|
def foo
|
||||||
|
self.class
|
||||||
|
end
|
||||||
|
end
|
||||||
|
b = EnvUtil.labeled_class("B")
|
||||||
|
bar = EnvUtil.labeled_module("R") do
|
||||||
|
break refine a do
|
||||||
|
def foo
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
assert_raise(TypeError) do
|
||||||
|
bar.instance_method(:foo).bind(b.new)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def eval_using(mod, s)
|
def eval_using(mod, s)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user