Define Integer#+ instead of Bignum#+.

* numeric.c (rb_int_plus): Define Integer#+.

* bignum.c (rb_big_plus): Don't define Bignum#+.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2016-04-30 12:24:06 +00:00
parent 11ca96d3a3
commit d0e2d150b8
3 changed files with 9 additions and 9 deletions

View File

@ -1,3 +1,9 @@
Sat Apr 30 21:11:08 2016 Tanaka Akira <akr@fsij.org>
* numeric.c (rb_int_plus): Define Integer#+.
* bignum.c (rb_big_plus): Don't define Bignum#+.
Sat Apr 30 21:01:20 2016 Tanaka Akira <akr@fsij.org> Sat Apr 30 21:01:20 2016 Tanaka Akira <akr@fsij.org>
* numeric.c (rb_int_minus): Define Integer#-. * numeric.c (rb_int_minus): Define Integer#-.

View File

@ -5767,13 +5767,6 @@ bigadd(VALUE x, VALUE y, int sign)
return z; return z;
} }
/*
* call-seq:
* big + other -> Numeric
*
* Adds big and other, returning the result.
*/
VALUE VALUE
rb_big_plus(VALUE x, VALUE y) rb_big_plus(VALUE x, VALUE y)
{ {
@ -6828,7 +6821,6 @@ Init_Bignum(void)
rb_cBignum = rb_define_class("Bignum", rb_cInteger); rb_cBignum = rb_define_class("Bignum", rb_cInteger);
rb_define_method(rb_cBignum, "coerce", rb_big_coerce, 1); rb_define_method(rb_cBignum, "coerce", rb_big_coerce, 1);
rb_define_method(rb_cBignum, "+", rb_big_plus, 1);
rb_define_method(rb_cBignum, "/", rb_big_div, 1); rb_define_method(rb_cBignum, "/", rb_big_div, 1);
rb_define_method(rb_cBignum, "===", rb_big_eq, 1); rb_define_method(rb_cBignum, "===", rb_big_eq, 1);

View File

@ -3223,9 +3223,10 @@ rb_int2str(VALUE x, int base)
} }
/* /*
* Document-method: Integer#+
* Document-method: Fixnum#+ * Document-method: Fixnum#+
* call-seq: * call-seq:
* fix + numeric -> numeric_result * int + numeric -> numeric_result
* *
* Performs addition: the class of the resulting object depends on the class of * Performs addition: the class of the resulting object depends on the class of
* +numeric+ and on the magnitude of the result. It may return a Bignum. * +numeric+ and on the magnitude of the result. It may return a Bignum.
@ -4940,6 +4941,7 @@ Init_Numeric(void)
rb_define_method(rb_cInteger, "-@", rb_int_uminus, 0); rb_define_method(rb_cInteger, "-@", rb_int_uminus, 0);
rb_define_method(rb_cFixnum, "+", fix_plus, 1); rb_define_method(rb_cFixnum, "+", fix_plus, 1);
rb_define_method(rb_cInteger, "+", rb_int_plus, 1);
rb_define_method(rb_cFixnum, "-", fix_minus, 1); rb_define_method(rb_cFixnum, "-", fix_minus, 1);
rb_define_method(rb_cInteger, "-", rb_int_minus, 1); rb_define_method(rb_cInteger, "-", rb_int_minus, 1);
rb_define_method(rb_cFixnum, "*", fix_mul, 1); rb_define_method(rb_cFixnum, "*", fix_mul, 1);