Commit b8de8866
b8de8866c5f4Merged
Ryan Seys <[email protected]> · 6 months ago · 5 files · +4 added · ~1 modified
Description
Merge branch 'matz:master' into rs-node-class-var-read
Details
- Commit
- b8de8866c5f4
- Parent
- b2d417b1d521
- Merge parent
- 9b7a2ad0721a
spinel_codegen.rbmodifiedView file
@@ -2264,6 +2264,17 @@
22642264
if all_sym_keys == 1 && (first_vt == "int" || first_vt == "bool" || first_vt == "nil")22652265
return "sym_int_hash"22662266
end2267+
# Issue #287: every value already inferred as poly (the slot2268+
# was widened upstream — typically an ivar that #247's2269+
# finalize_ivar_heterogeneity widened on a sibling-writer2270+
# disagreement). Same poly-hash storage as the mixed-types2271+
# `else` branch — every value carries its own tag.2272+
if first_vt == "poly"2273+
if all_sym_keys == 12274+
return "sym_poly_hash"2275+
end2276+
return "str_poly_hash"2277+
end22672278
else22682279
# Mixed value types: use a *_poly_hash so each slot carries its22692280
# own tag (sp_RbVal) rather than coercing everything to one type.@@ -8861,6 +8872,48 @@
88618872
@meth_param_types[mi] = ptypes.join(",")88628873
end88638874
end8875+
# Issue #286: bare call inside a class method body that8876+
# resolves to an inherited instance method. find_method_idx8877+
# above only finds *top-level* methods; an `assert_not_nil(x)`8878+
# inside `T2 < T`'s body needs to widen T's `assert_not_nil`8879+
# ptypes from this call's args. Mirror the obj.method() walk8880+
# in the recv >= 0 branch below — find_method_owner finds the8881+
# ancestor that actually defines the method, then we update8882+
# *that* class's @cls_meth_ptypes.8883+
if @current_class_idx >= 08884+
cls_ci_286 = @current_class_idx8885+
cls_owner_286 = cls_ci_2868886+
midx_286 = cls_find_method_direct(cls_ci_286, mname)8887+
if midx_286 < 08888+
owner_286 = find_method_owner(cls_ci_286, mname)8889+
if owner_286 != "" && owner_286 != @cls_names[cls_ci_286]8890+
cls_owner_286 = find_class_idx(owner_286)8891+
if cls_owner_286 >= 08892+
midx_286 = cls_find_method_direct(cls_owner_286, mname)8893+
end8894+
end8895+
end8896+
if midx_286 >= 08897+
args_id_286 = @nd_arguments[nid]8898+
if args_id_286 >= 08899+
arg_ids_286 = get_args(args_id_286)8900+
all_ptypes_286 = @cls_meth_ptypes[cls_owner_286].split("|")8901+
if midx_286 < all_ptypes_286.length8902+
ptypes_286 = all_ptypes_286[midx_286].split(",")8903+
kk_286 = 08904+
while kk_286 < arg_ids_286.length8905+
at_286 = infer_type(arg_ids_286[kk_286])8906+
if kk_286 < ptypes_286.length8907+
ptypes_286[kk_286] = unify_call_types(ptypes_286[kk_286], at_286, arg_ids_286[kk_286])8908+
end8909+
kk_286 = kk_286 + 18910+
end8911+
all_ptypes_286[midx_286] = ptypes_286.join(",")8912+
@cls_meth_ptypes[cls_owner_286] = all_ptypes_286.join("|")8913+
end8914+
end8915+
end8916+
end88648917
end88658918
if @nd_name[nid] == "new"88668919
recv = @nd_receiver[nid]@@ -19556,7 +19609,17 @@
1955619609
bp = "0"1955719610
end1955819611
end19559-
return "sp_" + owner + "_" + sanitize_name(mname) + "(" + self_expr + build_call_tail(ca, bp) + ")"19612+
# Issue #286: when the call resolves through inheritance to an19613+
# ancestor's method, the C function takes `sp_<owner> *self`.19614+
# Our `self` here is `sp_<current> *`. Cast so the `-Werror`19615+
# build doesn't trip on -Wincompatible-pointer-types. The same19616+
# cast pattern is already used by the recv >= 0 / instance_eval19617+
# branches a few lines above.19618+
recv_arg = self_expr19619+
if owner != "" && owner != @cls_names[@current_class_idx]19620+
recv_arg = "(sp_" + owner + " *)" + self_expr19621+
end19622+
return "sp_" + owner + "_" + sanitize_name(mname) + "(" + recv_arg + build_call_tail(ca, bp) + ")"1956019623
end1956119624
# Check attr_readers (bare method call like `x` meaning self.x)1956219625
readers = @cls_attr_readers[@current_class_idx].split(";")test/inherited_method_param_widen.rbaddedView file
Loading diff…
test/inherited_method_param_widen.rb.expectedaddedView file
Loading diff…
test/poly_hash_literal_from_ivar.rbaddedView file
Loading diff…
test/poly_hash_literal_from_ivar.rb.expectedaddedView file
Loading diff…