From 79423053936a7652dc22ef0294bf2eca1b53f50e Mon Sep 17 00:00:00 2001 From: Stephen Augenstein Date: Thu, 14 Nov 2024 14:39:29 -0500 Subject: [PATCH] Call to_a on cached object space enumerator --- lib/tapioca/dsl/compiler.rb | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) 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