eval "class Bar; p __method__; end"
On MRI 2.0.0 and 1.9.3, this prints nil. On JRuby 1.7.9, it prints :foo.
Obviously this is kind of a crazy edge case, but it does cause problems for Pry.
Oh Pry, you so crazy.
It appears we have never set a method name on the current frame for class and module bodies. When entering a class or module, we simply clone the previous call's frame and do not clear the name therein. That causes method, callee, caller, and others to show the outer method's name.
I believe this is special-cased logic, however. Kernel#caller does show a name, albeit one appropriate to a class:
$ rvm ruby-2.1 do ruby -e "class Foo; p caller(0); end"
The fact that method and callee return nil indicates they're specializing that logic for when the surrounding frame is a class.
Clear frame name when duplicating it for a class body. Fixes #1402
@headius this fix broke master and jruby-1_7.
The issue was a bad test in test_trace_func. It didn't pass on MRI either. 3e5496f