diff options
author | Marc-Andre Lafortune <github@marc-andre.ca> | 2020-05-07 23:58:19 -0400 |
---|---|---|
committer | Marc-André Lafortune <github@marc-andre.ca> | 2020-05-08 04:18:45 -0400 |
commit | adf709a78534c1483ba851ccb0490464ca31503c (patch) | |
tree | 3bd79435a29f2320e457646839e98768c69862f7 /object.c | |
parent | da345adc1c9cb6182ee11c43853f67bb41aeea76 (diff) |
Classes made from Struct should have default `new` singleton method.
[Bug #16465] [Bug #16801]
[Fix GH-2795] [Fix GH-2944] [Fix GH-3045] [Fix GH-3093]
Note: Backporting shouldn't modify object.h and instead can use
struct_new_kw which is basically a duplicate implementation of
rb_class_new_instance_pass_kw
Co-authored-by: Yusuke Endoh <mame@ruby-lang.org>
Co-authored-by: John Hawthorn <john@hawthorn.email>
Co-authored-by: Adam Hess <HParker@github.com>
Co-authored-by: Jose Cortinas <jacortinas@gmail.com>
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3093
Diffstat (limited to 'object.c')
-rw-r--r-- | object.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -2203,8 +2203,8 @@ rb_class_allocate_instance(VALUE klass) * */ -static VALUE -rb_class_s_new(int argc, const VALUE *argv, VALUE klass) +VALUE +rb_class_new_instance_pass_kw(int argc, const VALUE *argv, VALUE klass) { VALUE obj; @@ -4726,7 +4726,7 @@ InitVM_Object(void) rb_define_method(rb_cModule, "singleton_class?", rb_mod_singleton_p, 0); rb_define_method(rb_cClass, "allocate", rb_class_alloc_m, 0); - rb_define_method(rb_cClass, "new", rb_class_s_new, -1); + rb_define_method(rb_cClass, "new", rb_class_new_instance_pass_kw, -1); rb_define_method(rb_cClass, "initialize", rb_class_initialize, -1); rb_define_method(rb_cClass, "superclass", rb_class_superclass, 0); rb_define_alloc_func(rb_cClass, rb_class_s_alloc); |