From da204d2eee51082854ff6ec89eacea2911ea1590 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Tue, 22 Nov 2022 14:28:22 -0800 Subject: Inherit max_iv_count from superclass In 274870bd5434ab64ac3a3c9db9aa27d262c1d6d6 we gained the ability to make an educated guess at the max_iv_count of a class based on its initialize method. This commit makes subclasses inherit their super's max_iv_count, which makes the estimate work in cases that the subclass does not have an initialize method. --- class.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'class.c') diff --git a/class.c b/class.c index b9d62c18b1..87ebabef32 100644 --- a/class.c +++ b/class.c @@ -326,7 +326,13 @@ rb_class_new(VALUE super) { Check_Type(super, T_CLASS); rb_check_inheritable(super); - return rb_class_boot(super); + VALUE klass = rb_class_boot(super); + + if (super != rb_cObject && super != rb_cBasicObject) { + RCLASS_EXT(klass)->max_iv_count = RCLASS_EXT(super)->max_iv_count; + } + + return klass; } VALUE -- cgit v1.2.3