Delegates to BasicObject do not work
The delegate library does not currently handle BasicObject targets, since it assumes the target responds to
respond_to?. The attached patch works around the issue by binding the Kernel
respond_to? instance method to the target and then calling that.
Updated by decuplet (Nikita Shilnikov) 17 days ago
UnboundMethod#bind_call added in https://bugs.ruby-lang.org/projects/ruby-trunk/repository/git/revisions/83c6a1ef454c51ad1c0ca58e8a95fd67a033f710, we should be able to save some allocations by assigning
::Kernel.instance_method(:respond_to?) to a constant and calling with
.bind_call. WDYT? Not a big deal, I just don't like the idea we allocate objects when merely calling a method.
Updated by jeremyevans0 (Jeremy Evans) 17 days ago
Sure, it would be fine to use
#bind_call for this. At the time this patch was submitted,
#bind_call wasn't available. I know I have a patch in #7833 where
#bind_call could also be applied. We should probably do a sweep for other places in stdlib where
#bind_call could be used.