Commit 7f507bbb
7f507bbb6732Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified
Description
Class#superclass returns the parent class name
A class constant's .superclass resolves at compile time to the parent class name string (the recorded parent index, or "Object" when the class has no explicit user-defined parent). analyze types it as a string so puts/comparison dispatch.
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- 7f507bbb6732
- Parent
- a0fb552aa77b
src/analyze.cmodifiedView file
@@ -278,7 +278,8 @@
278278
279279
/* SomeClass.name / .to_s / .inspect -> the class-name string */280280
if (recv >= 0 && argc == 0 &&281-
(!strcmp(name, "name") || !strcmp(name, "to_s") || !strcmp(name, "inspect")) &&281+
(!strcmp(name, "name") || !strcmp(name, "to_s") || !strcmp(name, "inspect") ||282+
!strcmp(name, "superclass")) &&282283
nt_type(nt, recv) && !strcmp(nt_type(nt, recv), "ConstantReadNode") &&283284
nt_str(nt, recv, "name") && comp_class_index(c, nt_str(nt, recv, "name")) >= 0)284285
return TY_STRING;src/codegen.cmodifiedView file
Loading diff…