diff --git a/lib/ruby_lsp/node_context.rb b/lib/ruby_lsp/node_context.rb index 8f5a8f235..2025f2dea 100644 --- a/lib/ruby_lsp/node_context.rb +++ b/lib/ruby_lsp/node_context.rb @@ -89,12 +89,12 @@ def handle_nesting_nodes(nodes) when Prism::ClassNode, Prism::ModuleNode nesting << node.constant_path.slice when Prism::SingletonClassNode - nesting << "" + nesting << "" when Prism::DefNode surrounding_method = node.name.to_s next unless node.receiver.is_a?(Prism::SelfNode) - nesting << "" + nesting << "" end end diff --git a/test/type_inferrer_test.rb b/test/type_inferrer_test.rb index eb26abaef..622be98ed 100644 --- a/test/type_inferrer_test.rb +++ b/test/type_inferrer_test.rb @@ -138,6 +138,19 @@ class << self assert_equal("Foo::::>", @type_inferrer.infer_receiver_type(node_context).name) end + def test_infer_receiver_type_in_namespaced_singleton_method + node_context = index_and_locate(<<~RUBY, { line: 2, character: 4 }) + class Foo::Bar + def self.foo + bar + end + end + RUBY + + result = @type_inferrer.infer_receiver_type(node_context).name + assert_equal("Foo::Bar::", result) + end + def test_infer_receiver_type_instance_variables_in_singleton_block_method node_context = index_and_locate(<<~RUBY, { line: 3, character: 6 }) class Foo