Skip to content

Commit

Permalink
Merge pull request #2073 from warhammerkid/fix-1974
Browse files Browse the repository at this point in the history
Call `to_a` on cached `ObjectSpace` enumerator
  • Loading branch information
egiurleo authored Nov 18, 2024
2 parents 063f134 + 7942305 commit 2663f04
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/tapioca/dsl/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 2663f04

Please sign in to comment.