Issue #16297 has been updated by usa (Usaku NAKAMURA).

Backport changed from 2.5: REQUIRED, 2.6: REQUIRED to 2.5: REQUIRED, 2.6: DONE

ruby_2_6 r67896 merged revision(s) f72dc407.

----------------------------------------
Bug #16297: calling undefined allocator by `Class.instance_method(:allocate)`
https://bugs.ruby-lang.org/issues/16297#change-90649

* Author: nobu (Nobuyoshi Nakada)
* Status: Closed
* Priority: Normal
* Backport: 2.5: REQUIRED, 2.6: DONE
----------------------------------------
For instance, `Rational.allocate` is undefined.

```ruby
Rational.allocate #=> undefined method `allocate' for Rational:Class (NoMethodError)
```

But it can be called by `Class.instance_method(:allocate)`.

```ruby
Class.instance_method(:allocate).bind_call(Rational) #=> (0/1)
Class.instance_method(:allocate).bind(Rational).call #=> (0/1)
```

These allocators are defined for Marshal, and undefined as methods.




-- 
https://bugs.ruby-lang.org/