Issue #9755 has been reported by Shugo M…
Feature #9755: Thread::Backtrace::Location#defined_class
- Author: Shugo M.
- Status: Assigned
- Priority: Normal
- Assignee: Koichi Sasada
- Category: core
- Target version:
I’d like Thread::Backtrace::Location#defined_class.
class X
def foo
p caller_locations.first.defined_class #=> Y
end
end
class Y
def bar
X.new.foo
end
end
Y.new.bar
nobu created a patch:
Comparing ruby:master...nobu:backtrace-self+class · ruby/ruby · GitHub
But this patch has two problems:
- The patch adds Thread::Backtrace::Location#self, but it’s weird that
a location has self. - Thread::Backtrace::Location#class conflicts with Kernel#class.
So I proposed defined_class as the method name.