-
Notifications
You must be signed in to change notification settings - Fork 439
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
fix: C variables should never show up in Ancestors tree #1217
fix: C variables should never show up in Ancestors tree #1217
Conversation
@s.resolve_c_references | ||
|
||
# now the ancestor tree correctly references the NormalClass objects | ||
assert_equal(parent, @s.classes_hash['Child'].superclass) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(#superclass
can return either string or RDoc::NormalClass
really hurts my brain 🙈)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And of course the bug in #1221 is related to this confusion. 🤦
If a NormalClass's superclass is a C enclosure, then update the superclass to point to the RDoc::NormalClass. This is done in a single pass after all files have been parsed. Fixes ruby#1205.
ae631cb
to
8013d3d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix!
(ruby/rdoc#1217) If a NormalClass's superclass is a C enclosure, then update the superclass to point to the RDoc::NormalClass. This is done in a single pass after all files have been parsed. Fixes ruby/rdoc#1205. ruby/rdoc@1ecd9581b1
It is necessary for ClassModule's instance variable @superclass to always be a String (or nil) so that the class can be saved with `#marshal_dump` and loaded with `#marshal_load`. However, there's no type checking being done, which allows a bug like the one reported in ruby#1221 (which was introduced in ruby#1217) that sets superclass to a ClassModule. That bug requires: - setting a superclass to a NormalClass - marshal_save - marshal_load (which raises an exception) With this change, passing a ClassModule to ClassModule#superclass= is explicitly allowed by saving the full name of the ClassModule in the @superclass instance variable.
It is necessary for ClassModule's instance variable @superclass to always be a String (or nil) so that the class can be saved with `#marshal_dump` and loaded with `#marshal_load`. However, there's no type checking being done, which allows a bug like the one reported in #1221 (which was introduced in #1217) that sets superclass to a ClassModule. That bug requires: - setting a superclass to a NormalClass - marshal_save - marshal_load (which raises an exception) With this change, passing a ClassModule to ClassModule#superclass= is explicitly allowed by saving the full name of the ClassModule in the @superclass instance variable.
If a
NormalClass
's superclass is a C variable ("enclosure"), then update the superclass to point to the RDoc::NormalClass.This is done in a single pass after all files have been parsed.
Fixes #1205.
Before:
After: