diff --git a/lib/tapioca/dsl/compiler.rb b/lib/tapioca/dsl/compiler.rb index c3e7192f0..18b149dbd 100644 --- a/lib/tapioca/dsl/compiler.rb +++ b/lib/tapioca/dsl/compiler.rb @@ -74,11 +74,7 @@ def descendants_of(klass) 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 @@ -87,10 +83,10 @@ def all_classes 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