Skip to content

Attempt to use receiver as parent class when it's a call node#651

Merged
vinistock merged 1 commit intomainfrom
at-unresolved-superclass-partial-ancestor
Apr 15, 2026
Merged

Attempt to use receiver as parent class when it's a call node#651
vinistock merged 1 commit intomainfrom
at-unresolved-superclass-partial-ancestor

Conversation

@Morriar
Copy link
Copy Markdown
Contributor

@Morriar Morriar commented Mar 6, 2026

Summary

  • When class Foo < Bar is indexed and Bar is never defined, Foo's ancestor chain was silently falling back to [Foo, Object, BasicObject] (partial) — Bar was completely absent. This is inconsistent with how unresolved mixins are handled, which push Ancestor::Partial(name_id) as a placeholder.
  • Fixed by applying the same approach for superclasses: when no resolved parent is found but an unresolved reference exists, linearize_parent_class now returns Ancestors::Partial([Ancestor::Partial(name_id)]) instead of falling back to Object's chain.
  • Updated assert_ancestors_eq to compare by name string, so it works uniformly for both Complete and Partial ancestor entries (previously panicked on Ancestors::Partial).
  • Added Class#superclass_name Ruby API that returns the unresolved superclass name as written in source, or nil when resolved or absent.

Test plan

  • New Rust test: unresolved_superclass_is_represented_as_partial_ancestor verifies class Foo < Bar yields ["Foo", "Bar"]
  • New Ruby tests: test_superclass_name_returns_nil_when_superclass_is_resolved and test_superclass_name_returns_name_when_superclass_is_unresolved
  • cargo test — all 380 tests pass
  • bundle exec ruby -Itest test/declaration_test.rb — all 23 tests pass
  • cargo clippy --all-targets -- -D warnings — clean

@Morriar Morriar requested a review from a team as a code owner March 6, 2026 17:01
@Morriar Morriar force-pushed the at-unresolved-superclass-partial-ancestor branch from 7a593bf to 8f0b663 Compare March 24, 2026 22:49
Copy link
Copy Markdown
Member

@vinistock vinistock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the resolution changes can be shipped, but I do think the superclass API will be nicer returning constant reference objects

Comment thread ext/rubydex/declaration.c Outdated
Comment thread rust/rubydex/src/indexing/ruby_indexer.rs Outdated
Comment thread rust/rubydex/src/test_utils/graph_test.rs Outdated
@vinistock vinistock force-pushed the at-unresolved-superclass-partial-ancestor branch from 8f0b663 to 6d63202 Compare April 13, 2026 15:17
@vinistock vinistock changed the title Represent unresolved superclass as Ancestor::Partial Attempt to use receiver as parent class when it's a call node Apr 13, 2026
Co-authored-by: Alexandre Terrasa <Morriar@users.noreply.github.com>
@vinistock vinistock force-pushed the at-unresolved-superclass-partial-ancestor branch from 6d63202 to 1d2e0e7 Compare April 13, 2026 15:20
@vinistock vinistock merged commit fedd314 into main Apr 15, 2026
36 checks passed
@vinistock vinistock deleted the at-unresolved-superclass-partial-ancestor branch April 15, 2026 14:27
vinistock added a commit that referenced this pull request Apr 15, 2026
Ensure that ancestors are marked as partial if the parent class reference is not resolved. Extracted from #651
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants