lib/tapioca/runtime/reflection.rb in tapioca-0.16.3 vs lib/tapioca/runtime/reflection.rb in tapioca-0.16.4

- old
+ new

@@ -176,16 +176,22 @@ T.unsafe(result) end # Examines the call stack to identify the closest location where a "require" is performed - # by searching for the label "<top (required)>". If none is found, it returns the location + # by searching for the label "<top (required)>" or "block in <class:...>" in the + # case of an ActiveSupport.on_load hook. If none is found, it returns the location # labeled "<main>", which is the original call site. sig { params(locations: T.nilable(T::Array[Thread::Backtrace::Location])).returns(String) } def resolve_loc(locations) return "" unless locations - resolved_loc = locations.find { |loc| REQUIRED_FROM_LABELS.include?(loc.label) } + resolved_loc = locations.find do |loc| + label = loc.label + next unless label + + REQUIRED_FROM_LABELS.include?(label) || label.start_with?("block in <class:") + end return "" unless resolved_loc resolved_loc.absolute_path || "" end