lib/tapioca/runtime/reflection.rb in tapioca-0.9.3 vs lib/tapioca/runtime/reflection.rb in tapioca-0.9.4

- old
+ new

@@ -156,18 +156,17 @@ 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 # labeled "<main>", which is the original call site. - sig { returns(String) } - def required_from_location - locations = Kernel.caller_locations + sig { params(locations: T.nilable(T::Array[Thread::Backtrace::Location])).returns(String) } + def resolve_loc(locations) return "" unless locations - required_location = locations.find { |loc| REQUIRED_FROM_LABELS.include?(loc.label) } - return "" unless required_location + resolved_loc = locations.find { |loc| REQUIRED_FROM_LABELS.include?(loc.label) } + return "" unless resolved_loc - required_location.absolute_path || "" + resolved_loc.absolute_path || "" end sig { params(singleton_class: Module).returns(T.nilable(Module)) } def attached_class_of(singleton_class) # https://stackoverflow.com/a/36622320/98634