Commit 9f13ca03
9f13ca038688Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 5 files · +3 added · ~2 modified
Description
Merge pull request #472 from rubys/fix/issue-470-poly-fetch-hash-arms
Closes #470. Polymorphic .fetch dispatch on an sp_RbVal receiver
now enumerates built-in Hash variants (StrIntHash / StrStrHash /
StrPolyHash) in addition to user-class fetch arms, plus widens
analyze-side fetch on poly recv to poly so the result temp matches
the boxed branches.
Rebased on master with one trivial conflict resolved (PR #469's
parent-walking owner_idx supersedes the per-arm i in the
narrowed-int gating arm).
Details
- Commit
- 9f13ca038688
- Parent
- 1c3e51e42296
- Merge parent
- cadd330ea4b9
spinel_analyze.rbmodifiedView file
@@ -3709,6 +3709,19 @@
37093709
if rt == "str_str_hash" || rt == "sym_str_hash" || rt == "int_str_hash"37103710
return "string"37113711
end3712+
# Poly recv: runtime can be any user class (with `def fetch`)3713+
# OR any built-in Hash variant. The codegen-side dispatch3714+
# (`compile_poly_method_call` + `emit_poly_builtin_dispatch`)3715+
# boxes each per-cls_id arm to sp_RbVal because the value3716+
# types diverge across arms. Surface that here so the caller's3717+
# slot widens accordingly — without this, `lookup` keeps a3718+
# `const char *` return slot and the boxed dispatch result is3719+
# a C type mismatch. Sibling to the `[]` poly-recv widening3720+
# at line 4520 above.3721+
if rt == "poly"3722+
@needs_rb_value = 13723+
return "poly"3724+
end37123725
end37133726
# Don't claim "int" for fetch on receivers we don't recognize37143727
# as a built-in collection — let later dispatch resolve aspinel_codegen.rbmodifiedView file
Loading diff…
test/poly_recv_fetch_arm_incompat.rbaddedView file
Loading diff…
test/poly_recv_fetch_arm_incompat.rb.expectedaddedView file
Loading diff…
test/poly_recv_fetch_hash_arms.rbaddedView file
Loading diff…