Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise if the attached namespace is missing during linearization #2279

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ruby_indexer/lib/ruby_indexer/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ def linearized_ancestors_of(fully_qualified_name)
# If we don't have an entry for `name`, raise
entries = self[fully_qualified_name]

if singleton_levels > 0 && !entries
if singleton_levels > 0 && !entries && indexed?(attached_class_name)
entries = [existing_or_new_singleton_class(attached_class_name)]
end

Expand Down
6 changes: 6 additions & 0 deletions lib/ruby_indexer/test/index_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1707,5 +1707,11 @@ module A; end
@index.linearized_ancestors_of("A::<Class:A>"),
)
end

def test_linearizing_a_singleton_class_with_no_attached
assert_raises(Index::NonExistingNamespaceError) do
@index.linearized_ancestors_of("A::<Class:A>")
end
end
end
end
Loading