lib/tapioca/dsl/compiler.rb in tapioca-0.16.4 vs lib/tapioca/dsl/compiler.rb in tapioca-0.16.5

- old
+ new

@@ -49,10 +49,17 @@ sig { params(constants: T::Array[Module]).void } def requested_constants=(constants) @@requested_constants = constants # rubocop:disable Style/ClassVars end + sig { void } + def reset_state + @processable_constants = nil + @all_classes = nil + @all_modules = nil + end + private sig do type_parameters(:U) .params(klass: T.all(T::Class[T.anything], T.type_parameter(:U))) @@ -72,26 +79,22 @@ end sig { returns(T::Enumerable[T::Class[T.anything]]) } def all_classes @all_classes ||= T.let( - if @@requested_constants.any? - @@requested_constants.grep(Class) - else - ObjectSpace.each_object(Class) - end, + all_modules.grep(Class).freeze, T.nilable(T::Enumerable[T::Class[T.anything]]), ) end sig { returns(T::Enumerable[Module]) } def all_modules @all_modules ||= T.let( if @@requested_constants.any? - @@requested_constants.select { |k| k.is_a?(Module) } + @@requested_constants.grep(Module) else - ObjectSpace.each_object(Module) - end, + ObjectSpace.each_object(Module).to_a + end.freeze, T.nilable(T::Enumerable[Module]), ) end end