Commit 13d04491

13d04491ba21Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 4 files · +2 added · ~2 modified

Description

analyze,codegen: poly.class — runtime tag dispatch

`a[0].class` on a heterogeneous-array element (recv_type "poly") previously fell through compile_poly_method_call's user-class loop, emitted the "no concrete user-class arm" warning, and returned 0. Add a poly-recv arm before that dispatch that emits a tag-based ternary returning the builtin class id for primitive tags (Integer/String/Float/Symbol/NilClass/TrueClass/FalseClass) and the stored cls_id for SP_TAG_OBJ. Analyze claims "class" return for poly receivers too.

Fixes #998

Co-Authored-By: Claude Opus 4.7 [email protected]

Details

Commit
13d04491ba21
Parent
6d70b4bd233f

spinel_analyze.rbmodifiedView file

@@ -4137,6 +4137,12 @@
41374137 bt_pc == "proc" || bt_pc == "lambda"
41384138 return "class"
41394139 end
4140+ # poly receivers — runtime tag dispatch in codegen returns a
4141+ # sp_Class struct (built-in class id for primitive tags, stored
4142+ # cls_id for OBJ-tagged values).
4143+ if bt_pc == "poly" || bt_pc == "poly?"
4144+ return "class"
4145+ end
41404146 end
41414147 end
41424148 # `<obj>.class.<cmeth>` chained dispatch. When the