lib/tapioca/runtime/trackers/constant_definition.rb in tapioca-0.9.1 vs lib/tapioca/runtime/trackers/constant_definition.rb in tapioca-0.9.2
- old
+ new
@@ -23,19 +23,19 @@
TracePoint.trace(:class) do |tp|
next if tp.self.singleton_class?
key = tp.self
- if tp.path == "(eval)"
+ path = tp.path
+ if File.exist?(path)
+ loc = build_constant_location(tp, caller_locations)
+ else
caller_location = T.must(caller_locations)
- .drop_while { |loc| loc.path == "(eval)" }
- .first
+ .find { |loc| loc.path && File.exist?(loc.path) }
next unless caller_location
loc = ConstantLocation.new(path: caller_location.absolute_path || "", lineno: caller_location.lineno)
- else
- loc = build_constant_location(tp, caller_locations)
end
(@class_files[key] ||= Set.new) << loc
end