No respond_to? as if the default definition
* vm_method.c (vm_respond_to): try method_missing if respond_to? is undefined, as if it is the default definition. [ruby-core:75377] [Bug #12353] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9de2af7bd9
commit
b51174a6b0
@ -1,3 +1,9 @@
|
|||||||
|
Sat Jun 25 02:33:33 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* vm_method.c (vm_respond_to): try method_missing if respond_to?
|
||||||
|
is undefined, as if it is the default definition.
|
||||||
|
[ruby-core:75377] [Bug #12353]
|
||||||
|
|
||||||
Fri Jun 24 17:04:21 2016 SHIBATA Hiroshi <hsbt@ruby-lang.org>
|
Fri Jun 24 17:04:21 2016 SHIBATA Hiroshi <hsbt@ruby-lang.org>
|
||||||
|
|
||||||
* ext/psych/*, test/psych/*: Upate psych 2.1.0
|
* ext/psych/*, test/psych/*: Upate psych 2.1.0
|
||||||
|
@ -737,4 +737,24 @@ class TestMarshal < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
|
MethodMissingWithoutRespondTo = Struct.new(:wrapped_object) do
|
||||||
|
undef respond_to?
|
||||||
|
def method_missing(*args, &block)
|
||||||
|
wrapped_object.public_send(*args, &block)
|
||||||
|
end
|
||||||
|
def respond_to_missing?(name, private = false)
|
||||||
|
wrapped_object.respond_to?(name, false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_method_missing_without_respond_to
|
||||||
|
bug12353 = "[ruby-core:75377] [Bug #12353]: try method_missing if" \
|
||||||
|
" respond_to? is undefined"
|
||||||
|
obj = MethodMissingWithoutRespondTo.new("foo")
|
||||||
|
dump = assert_nothing_raised(NoMethodError, bug12353) do
|
||||||
|
Marshal.dump(obj)
|
||||||
|
end
|
||||||
|
assert_equal(obj, Marshal.load(dump))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1916,7 +1916,7 @@ vm_respond_to(rb_thread_t *th, VALUE klass, VALUE obj, ID id, int priv)
|
|||||||
const rb_method_entry_t *const me =
|
const rb_method_entry_t *const me =
|
||||||
method_entry_get(klass, resid, &defined_class);
|
method_entry_get(klass, resid, &defined_class);
|
||||||
|
|
||||||
if (!me) return TRUE;
|
if (!me) return -1;
|
||||||
if (METHOD_ENTRY_BASIC(me)) {
|
if (METHOD_ENTRY_BASIC(me)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user