Skip to content

Commit c839def

Browse files
committed
merge revision(s) r49182,r49183: [Backport ruby#10706]
vm_method.c: fix change refined new method visibility * vm_method.c (rb_export_method): bail out if the original method is undefined when the method is refined. [ruby-core:67387] [Bug ruby#10706] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 8e73157 commit c839def

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Sun Mar 1 01:17:24 2015 Seiei Higa <[email protected]>
2+
3+
* vm_method.c (rb_export_method): bail out if the original method
4+
is undefined when the method is refined.
5+
[ruby-core:67387] [Bug #10706]
6+
17
Sun Mar 1 01:14:59 2015 Eric Wong <[email protected]>
28

39
* lib/resolv.rb: consider ENETUNREACH as ResolvTimeout

test/ruby/test_refinement.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,20 @@ def foo
11671167
end;
11681168
end
11691169

1170+
def test_change_refined_new_method_visibility
1171+
assert_separately([], <<-"end;")
1172+
bug10706 = '[ruby-core:67387] [Bug #10706]'
1173+
module RefinementBug
1174+
refine Object do
1175+
def foo
1176+
end
1177+
end
1178+
end
1179+
1180+
assert_raise(NameError, bug10706) {private(:foo)}
1181+
end;
1182+
end
1183+
11701184
private
11711185

11721186
def eval_using(mod, s)

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define RUBY_VERSION "2.1.5"
22
#define RUBY_RELEASE_DATE "2015-03-01"
3-
#define RUBY_PATCHLEVEL 303
3+
#define RUBY_PATCHLEVEL 304
44

55
#define RUBY_RELEASE_YEAR 2015
66
#define RUBY_RELEASE_MONTH 3

vm_method.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,9 @@ rb_export_method(VALUE klass, ID name, rb_method_flag_t noex)
811811
me = search_method(rb_cObject, name, &defined_class);
812812
}
813813

814-
if (UNDEFINED_METHOD_ENTRY_P(me)) {
814+
if (UNDEFINED_METHOD_ENTRY_P(me) ||
815+
(me->def->type == VM_METHOD_TYPE_REFINED &&
816+
UNDEFINED_METHOD_ENTRY_P(me->def->body.orig_me))) {
815817
rb_print_undef(klass, name, 0);
816818
}
817819

0 commit comments

Comments
 (0)