diff --git a/ruby/ext/google/protobuf_c/map.c b/ruby/ext/google/protobuf_c/map.c index d1a648daecce..2f6de4d8bad3 100644 --- a/ruby/ext/google/protobuf_c/map.c +++ b/ruby/ext/google/protobuf_c/map.c @@ -682,6 +682,8 @@ void Map_register(VALUE module) { rb_define_method(klass, "length", Map_length, 0); rb_define_method(klass, "size", Map_length, 0); rb_define_method(klass, "dup", Map_dup, 0); + // Also define #clone so that we don't inherit Object#clone. + rb_define_method(klass, "clone", Map_dup, 0); rb_define_method(klass, "==", Map_eq, 1); rb_define_method(klass, "freeze", Map_freeze, 0); rb_define_method(klass, "hash", Map_hash, 0);