Skip to content

Commit 5d3b8d0

Browse files
committed
merge revision(s) r49322: [Backport ruby#10753]
* vm_method.c (check_definition): Module#public_method_defined?, Module#private_method_defined?, Module#protected_method_defined? should not use refinements. [ruby-core:67656] [Bug ruby#10753] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent db0f860 commit 5d3b8d0

File tree

4 files changed

+85
-4
lines changed

4 files changed

+85
-4
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Wed Mar 18 00:32:08 2015 Seiei Higa <[email protected]>
2+
3+
* vm_method.c (check_definition): Module#public_method_defined?,
4+
Module#private_method_defined?, Module#protected_method_defined?
5+
should not use refinements. [ruby-core:67656] [Bug #10753]
6+
17
Tue Mar 10 02:40:11 2015 SHIBATA Hiroshi <[email protected]>
28

39
* thread.c: Improve documentation for Thread#value

test/ruby/test_refinement.rb

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,81 @@ class C
12061206
end;
12071207
end
12081208

1209+
def test_refined_method_defined
1210+
assert_separately([], <<-"end;")
1211+
bug10753 = '[ruby-core:67656] [Bug #10753]'
1212+
1213+
c = Class.new do
1214+
def refined_public; end
1215+
def refined_protected; end
1216+
def refined_private; end
1217+
1218+
public :refined_public
1219+
protected :refined_protected
1220+
private :refined_private
1221+
end
1222+
1223+
m = Module.new do
1224+
refine(c) do
1225+
def refined_public; end
1226+
def refined_protected; end
1227+
def refined_private; end
1228+
1229+
public :refined_public
1230+
protected :refined_protected
1231+
private :refined_private
1232+
end
1233+
end
1234+
1235+
using m
1236+
1237+
assert_equal(true, c.public_method_defined?(:refined_public), bug10753)
1238+
assert_equal(false, c.public_method_defined?(:refined_protected), bug10753)
1239+
assert_equal(false, c.public_method_defined?(:refined_private), bug10753)
1240+
1241+
assert_equal(false, c.protected_method_defined?(:refined_public), bug10753)
1242+
assert_equal(true, c.protected_method_defined?(:refined_protected), bug10753)
1243+
assert_equal(false, c.protected_method_defined?(:refined_private), bug10753)
1244+
1245+
assert_equal(false, c.private_method_defined?(:refined_public), bug10753)
1246+
assert_equal(false, c.private_method_defined?(:refined_protected), bug10753)
1247+
assert_equal(true, c.private_method_defined?(:refined_private), bug10753)
1248+
end;
1249+
end
1250+
1251+
def test_undefined_refined_method_defined
1252+
assert_separately([], <<-"end;")
1253+
bug10753 = '[ruby-core:67656] [Bug #10753]'
1254+
1255+
c = Class.new
1256+
1257+
m = Module.new do
1258+
refine(c) do
1259+
def undefined_refined_public; end
1260+
def undefined_refined_protected; end
1261+
def undefined_refined_private; end
1262+
public :undefined_refined_public
1263+
protected :undefined_refined_protected
1264+
private :undefined_refined_private
1265+
end
1266+
end
1267+
1268+
using m
1269+
1270+
assert_equal(false, c.public_method_defined?(:undefined_refined_public), bug10753)
1271+
assert_equal(false, c.public_method_defined?(:undefined_refined_protected), bug10753)
1272+
assert_equal(false, c.public_method_defined?(:undefined_refined_private), bug10753)
1273+
1274+
assert_equal(false, c.protected_method_defined?(:undefined_refined_public), bug10753)
1275+
assert_equal(false, c.protected_method_defined?(:undefined_refined_protected), bug10753)
1276+
assert_equal(false, c.protected_method_defined?(:undefined_refined_private), bug10753)
1277+
1278+
assert_equal(false, c.private_method_defined?(:undefined_refined_public), bug10753)
1279+
assert_equal(false, c.private_method_defined?(:undefined_refined_protected), bug10753)
1280+
assert_equal(false, c.private_method_defined?(:undefined_refined_private), bug10753)
1281+
end;
1282+
end
1283+
12091284
private
12101285

12111286
def eval_using(mod, s)

version.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#define RUBY_VERSION "2.1.5"
2-
#define RUBY_RELEASE_DATE "2015-03-10"
3-
#define RUBY_PATCHLEVEL 312
2+
#define RUBY_RELEASE_DATE "2015-03-18"
3+
#define RUBY_PATCHLEVEL 313
44

55
#define RUBY_RELEASE_YEAR 2015
66
#define RUBY_RELEASE_MONTH 3
7-
#define RUBY_RELEASE_DAY 10
7+
#define RUBY_RELEASE_DAY 18
88

99
#include "ruby/version.h"
1010

vm_method.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ check_definition(VALUE mod, VALUE mid, rb_method_flag_t noex)
10441044
const rb_method_entry_t *me;
10451045
ID id = rb_check_id(&mid);
10461046
if (!id) return Qfalse;
1047-
me = rb_method_entry(mod, id, 0);
1047+
me = rb_method_entry_without_refinements(mod, id, 0);
10481048
if (me) {
10491049
if (VISI_CHECK(me->flag, noex))
10501050
return Qtrue;

0 commit comments

Comments
 (0)