Commit 3b423bd2

3b423bd2cecdMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified

Description

Restore Class.cmethod inference clobbered by the Time insertion

The Time inference block accidentally replaced the Class.cmethod return- type arm, breaking class-method calls (Point.origin, C.hi). Restore it after the Time arms.

Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]

Details

Commit
3b423bd2cecd
Parent
619e3e5516b8

src/analyze.cmodifiedView file

@@ -89,6 +89,18 @@
8989 return TY_INT;
9090 }
9191
92+ /* Class.cmethod(...) -> the class method's return type */
93+ if (recv >= 0) {
94+ const char *rty = nt_type(nt, recv);
95+ if (rty && !strcmp(rty, "ConstantReadNode")) {
96+ int ci = comp_class_index(c, nt_str(nt, recv, "name"));
97+ if (ci >= 0) {
98+ int mi = comp_cmethod_in_chain(c, ci, name, NULL);
99+ if (mi >= 0) return c->scopes[mi].ret;
100+ }
101+ }
102+ }
103+
92104 /* obj.method(...) -> the method's return type (walks the superclass chain) */
93105 if (recv >= 0 && ty_is_object(rt)) {
94106 int cid = ty_object_class(rt);