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 end
2267+ # Issue #287: every value already inferred as poly (the slot
2268+ # was widened upstream — typically an ivar that #247's
2269+ # finalize_ivar_heterogeneity widened on a sibling-writer
2270+ # disagreement). Same poly-hash storage as the mixed-types
2271+ # `else` branch — every value carries its own tag.
2272+ if first_vt == "poly"
2273+ if all_sym_keys == 1
2274+ return "sym_poly_hash"
2275+ end
2276+ return "str_poly_hash"
2277+ end
22672278 else
22682279 # Mixed value types: use a *_poly_hash so each slot carries its
22692280 # own tag (sp_RbVal) rather than coercing everything to one type.
@@ -8861,6 +8872,48 @@
88618872 @meth_param_types[mi] = ptypes.join(",")
88628873 end
88638874 end
8875+ # Issue #286: bare call inside a class method body that
8876+ # resolves to an inherited instance method. find_method_idx
8877+ # 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() walk
8880+ # in the recv >= 0 branch below — find_method_owner finds the
8881+ # ancestor that actually defines the method, then we update
8882+ # *that* class's @cls_meth_ptypes.
8883+ if @current_class_idx >= 0
8884+ cls_ci_286 = @current_class_idx
8885+ cls_owner_286 = cls_ci_286
8886+ midx_286 = cls_find_method_direct(cls_ci_286, mname)
8887+ if midx_286 < 0
8888+ 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 >= 0
8892+ midx_286 = cls_find_method_direct(cls_owner_286, mname)
8893+ end
8894+ end
8895+ end
8896+ if midx_286 >= 0
8897+ args_id_286 = @nd_arguments[nid]
8898+ if args_id_286 >= 0
8899+ 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.length
8902+ ptypes_286 = all_ptypes_286[midx_286].split(",")
8903+ kk_286 = 0
8904+ while kk_286 < arg_ids_286.length
8905+ at_286 = infer_type(arg_ids_286[kk_286])
8906+ if kk_286 < ptypes_286.length
8907+ ptypes_286[kk_286] = unify_call_types(ptypes_286[kk_286], at_286, arg_ids_286[kk_286])
8908+ end
8909+ kk_286 = kk_286 + 1
8910+ end
8911+ all_ptypes_286[midx_286] = ptypes_286.join(",")
8912+ @cls_meth_ptypes[cls_owner_286] = all_ptypes_286.join("|")
8913+ end
8914+ end
8915+ end
8916+ end
88648917 end
88658918 if @nd_name[nid] == "new"
88668919 recv = @nd_receiver[nid]
@@ -19556,7 +19609,17 @@
1955619609 bp = "0"
1955719610 end
1955819611 end
19559- return "sp_" + owner + "_" + sanitize_name(mname) + "(" + self_expr + build_call_tail(ca, bp) + ")"
19612+ # Issue #286: when the call resolves through inheritance to an
19613+ # 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 same
19616+ # cast pattern is already used by the recv >= 0 / instance_eval
19617+ # branches a few lines above.
19618+ recv_arg = self_expr
19619+ if owner != "" && owner != @cls_names[@current_class_idx]
19620+ recv_arg = "(sp_" + owner + " *)" + self_expr
19621+ end
19622+ return "sp_" + owner + "_" + sanitize_name(mname) + "(" + recv_arg + build_call_tail(ca, bp) + ")"
1956019623 end
1956119624 # Check attr_readers (bare method call like `x` meaning self.x)
1956219625 readers = @cls_attr_readers[@current_class_idx].split(";")