lib/tapioca/dsl/pipeline.rb in tapioca-0.11.13 vs lib/tapioca/dsl/pipeline.rb in tapioca-0.11.14
- old
+ new
@@ -128,11 +128,14 @@
active_compilers
end
sig { params(requested_constants: T::Array[Module], requested_paths: T::Array[Pathname]).returns(T::Set[Module]) }
def gather_constants(requested_constants, requested_paths)
- constants = active_compilers.map(&:processable_constants).reduce(Set.new, :union)
+ constants = Set.new.compare_by_identity
+ active_compilers.each do |compiler|
+ constants.merge(compiler.processable_constants)
+ end
constants = filter_anonymous_and_reloaded_constants(constants)
constants &= requested_constants unless requested_constants.empty? && requested_paths.empty?
constants
end
@@ -156,14 +159,15 @@
$stderr.puts("Make sure some object is not holding onto these constants during an app reload.")
end
# Look up all the constants back from their names. The resulting constant set will be the
# set of constants that are actually in memory with those names.
- constants_by_name
+ filtered_constants = constants_by_name
.keys
.map { |name| T.cast(Runtime::Reflection.constantize(name), Module) }
.select { |mod| Runtime::Reflection.constant_defined?(mod) }
- .to_set
+
+ Set.new.compare_by_identity.merge(filtered_constants)
end
sig { params(constant: Module).returns(T.nilable(RBI::File)) }
def rbi_for_constant(constant)
file = RBI::File.new(strictness: "true")