summaryrefslogtreecommitdiff
path: root/complex.c
diff options
context:
space:
mode:
Diffstat (limited to 'complex.c')
-rw-r--r--complex.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/complex.c b/complex.c
index 38a1907aac..c4d4f80848 100644
--- a/complex.c
+++ b/complex.c
@@ -75,6 +75,20 @@ f_add(VALUE x, VALUE y)
return x;
if (FIXNUM_ZERO_P(x))
return y;
+
+ if (RB_INTEGER_TYPE_P(x) &&
+ UNLIKELY(rb_method_basic_definition_p(rb_cInteger, idPLUS))) {
+ return rb_int_plus(x, y);
+ }
+ else if (RB_FLOAT_TYPE_P(x) &&
+ UNLIKELY(rb_method_basic_definition_p(rb_cFloat, idPLUS))) {
+ return rb_float_plus(x, y);
+ }
+ else if (RB_TYPE_P(x, T_RATIONAL) &&
+ UNLIKELY(rb_method_basic_definition_p(rb_cRational, idPLUS))) {
+ return rb_rational_plus(x, y);
+ }
+
return rb_funcall(x, '+', 1, y);
}