Commit fcb515f
authored
Fix rb_define_method(singleton_class_of_module, ...) not to change nested module name (#1458)
Fixes #1440
Always track class and singleton class stored to a variable to
`@classes`.
Otherwise, `find_class var_name, class_name` called from `handle_method`
will add a new class.
Before:
<img width="303" height="167" alt="before"
src="https://github.com/user-attachments/assets/fb885b6c-40bf-44c5-8f01-095cfdc75c16"
/>
After:
<img width="303" height="167" alt="after"
src="https://github.com/user-attachments/assets/e0aae152-f46e-4954-8b68-23b74dd3bc90"
/>
Minimal reproduction:
```c
VALUE mFoo = rb_define_module("Foo");
VALUE mBar = rb_define_module_under(mFoo, "Bar");
VALUE mBarS = rb_singleton_class(mBar);
rb_define_method(mBarS, "baz", baz, 0);
```
`RDoc::Parser::C#handle_method` calls `find_class 'mBarS', 'Foo::Bar'`.
`RDoc::Parser::C#find_class` calls `@top_level.add_class
RDoc::NormalClass, 'Foo::Bar'`. This will create `::Bar` for some reason
and `Foo::Bar` disappears from generated document.1 parent b0e21ef commit fcb515f
2 files changed
+43
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1052 | 1052 | | |
1053 | 1053 | | |
1054 | 1054 | | |
1055 | | - | |
1056 | | - | |
1057 | | - | |
1058 | | - | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
1059 | 1062 | | |
1060 | 1063 | | |
1061 | 1064 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
781 | 781 | | |
782 | 782 | | |
783 | 783 | | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
784 | 818 | | |
785 | 819 | | |
786 | 820 | | |
| |||
1973 | 2007 | | |
1974 | 2008 | | |
1975 | 2009 | | |
1976 | | - | |
| 2010 | + | |
| 2011 | + | |
1977 | 2012 | | |
1978 | 2013 | | |
1979 | 2014 | | |
| |||
0 commit comments