From 9b1c2919496c7d2d3fecd2dc07b271c8ebb3df7f Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Tue, 1 Oct 2024 16:46:32 +0100 Subject: [PATCH] Move `defined?` check out of `process_overload` --- lib/ruby_indexer/lib/ruby_indexer/rbs_indexer.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ruby_indexer/lib/ruby_indexer/rbs_indexer.rb b/lib/ruby_indexer/lib/ruby_indexer/rbs_indexer.rb index 6bd2377b4..e8bb79566 100644 --- a/lib/ruby_indexer/lib/ruby_indexer/rbs_indexer.rb +++ b/lib/ruby_indexer/lib/ruby_indexer/rbs_indexer.rb @@ -5,6 +5,8 @@ module RubyIndexer class RBSIndexer extend T::Sig + HAS_UNTYPED_FUNCTION = T.let(!!defined?(RBS::Types::UntypedFunction), T::Boolean) + sig { params(index: Index).void } def initialize(index) @index = index @@ -161,7 +163,7 @@ def process_overload(overload) # Untyped functions are a new RBS feature (since v3.6.0) to declare methods that accept any parameters. For our # purposes, accepting any argument is equivalent to `...` - if defined?(RBS::Types::UntypedFunction) && function.is_a?(RBS::Types::UntypedFunction) + if HAS_UNTYPED_FUNCTION && function.is_a?(RBS::Types::UntypedFunction) [Entry::ForwardingParameter.new] else []