Commit 13d04491
13d04491ba21Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 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
end4140+
# poly receivers — runtime tag dispatch in codegen returns a4141+
# sp_Class struct (built-in class id for primitive tags, stored4142+
# cls_id for OBJ-tagged values).4143+
if bt_pc == "poly" || bt_pc == "poly?"4144+
return "class"4145+
end41404146
end41414147
end41424148
# `<obj>.class.<cmeth>` chained dispatch. When thespinel_codegen.rbmodifiedView file
Loading diff…
test/poly_class_dispatch.rbaddedView file
Loading diff…
test/poly_class_dispatch.rb.expectedaddedView file
Loading diff…