Skip to content

Fix corner cases of re-opening aliases#621

Merged
vinistock merged 1 commit intomainfrom
03-02-fix_corner_cases_of_re-opening_aliases
Mar 4, 2026
Merged

Fix corner cases of re-opening aliases#621
vinistock merged 1 commit intomainfrom
03-02-fix_corner_cases_of_re-opening_aliases

Conversation

@vinistock
Copy link
Member

@vinistock vinistock commented Mar 2, 2026

When an alias is re-opened with the class or module keyword, we need to ensure that we're adequately following it, so that we re-open the target and not the alias itself.

For example:

class Foo; end

ALIAS = Foo

class ALIAS
  def bar; end
end

This creates Foo#bar() and not ALIAS#bar().

@vinistock vinistock self-assigned this Mar 2, 2026
@vinistock vinistock added the bugfix A change that fixes an existing bug label Mar 2, 2026 — with Graphite App
@vinistock vinistock marked this pull request as ready for review March 2, 2026 19:06
@vinistock vinistock requested a review from a team as a code owner March 2, 2026 19:06
@vinistock vinistock force-pushed the 03-02-follow_aliases_when_they_are_used_in_mixins_or_parent_classes branch from 5d91b0f to 2c4dcbb Compare March 2, 2026 19:12
@vinistock vinistock force-pushed the 03-02-fix_corner_cases_of_re-opening_aliases branch 2 times, most recently from 4f2c3c2 to 9cf59ac Compare March 2, 2026 19:59
@vinistock vinistock force-pushed the 03-02-follow_aliases_when_they_are_used_in_mixins_or_parent_classes branch from 2c4dcbb to c043f4d Compare March 2, 2026 19:59
@vinistock vinistock force-pushed the 03-02-follow_aliases_when_they_are_used_in_mixins_or_parent_classes branch from c043f4d to adc0cd9 Compare March 4, 2026 14:49
@vinistock vinistock force-pushed the 03-02-fix_corner_cases_of_re-opening_aliases branch from 9cf59ac to 5ea4e22 Compare March 4, 2026 14:49
Copy link
Member Author

vinistock commented Mar 4, 2026

Merge activity

  • Mar 4, 8:32 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Mar 4, 8:34 PM UTC: Graphite rebased this pull request as part of a merge.
  • Mar 4, 8:43 PM UTC: @vinistock merged this pull request with Graphite.

@vinistock vinistock changed the base branch from 03-02-follow_aliases_when_they_are_used_in_mixins_or_parent_classes to graphite-base/621 March 4, 2026 20:32
@vinistock vinistock changed the base branch from graphite-base/621 to main March 4, 2026 20:32
@vinistock vinistock force-pushed the 03-02-fix_corner_cases_of_re-opening_aliases branch from 5ea4e22 to ed9f3b7 Compare March 4, 2026 20:33
@vinistock vinistock merged commit 6517163 into main Mar 4, 2026
33 checks passed
@vinistock vinistock deleted the 03-02-fix_corner_cases_of_re-opening_aliases branch March 4, 2026 20:43
assert_declaration_exists!(context, "Foo#@@class_var");
assert_declaration_exists!(context, "Foo#some_attr()");
assert_declaration_exists!(context, "Foo::<Foo>#class_method()");
assert_declaration_exists!(context, "Foo#initialize()");
Copy link
Contributor

Choose a reason for hiding this comment

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

The test covers every definition type (constants, ivars, class vars, attrs, methods) except alias new_name old_name (Definition::MethodAlias), whose callsite was also updated on line 512. Any chance we can add one more assertion here?

Suggested change
assert_declaration_exists!(context, "Foo#initialize()");
assert_declaration_exists!(context, "Foo#initialize()");
assert_declaration_exists!(context, "Foo#bar()"); // alias bar initialize
}

With a matching alias bar initialize added to the module ALIAS body.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix A change that fixes an existing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants