@@ -1646,6 +1646,43 @@ class Module < Object
16461646 #
16471647 def remove_method : (*interned arg0) -> self
16481648
1649+ # <!--
1650+ # rdoc-file=vm_method.c
1651+ # - ruby2_keywords(method_name, ...) -> nil
1652+ # -->
1653+ # For the given method names, marks the method as passing keywords through a
1654+ # normal argument splat. This should only be called on methods that accept an
1655+ # argument splat (`*args`) but not explicit keywords or a keyword splat. It
1656+ # marks the method such that if the method is called with keyword arguments, the
1657+ # final hash argument is marked with a special flag such that if it is the final
1658+ # element of a normal argument splat to another method call, and that method
1659+ # call does not include explicit keywords or a keyword splat, the final element
1660+ # is interpreted as keywords. In other words, keywords will be passed through
1661+ # the method to other methods.
1662+ #
1663+ # This should only be used for methods that delegate keywords to another method,
1664+ # and only for backwards compatibility with Ruby versions before 3.0. See
1665+ # https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyw
1666+ # ord-arguments-in-ruby-3-0/ for details on why `ruby2_keywords` exists and when
1667+ # and how to use it.
1668+ #
1669+ # This method will probably be removed at some point, as it exists only for
1670+ # backwards compatibility. As it does not exist in Ruby versions before 2.7,
1671+ # check that the module responds to this method before calling it:
1672+ #
1673+ # module Mod
1674+ # def foo(meth, *args, &block)
1675+ # send(:"do_#{meth}", *args, &block)
1676+ # end
1677+ # ruby2_keywords(:foo) if respond_to?(:ruby2_keywords, true)
1678+ # end
1679+ #
1680+ # However, be aware that if the `ruby2_keywords` method is removed, the behavior
1681+ # of the `foo` method using the above approach will change so that the method
1682+ # does not pass through keywords.
1683+ #
1684+ private def ruby2_keywords : (*interned method_name) -> nil
1685+
16491686 # <!--
16501687 # rdoc-file=object.c
16511688 # - mod.set_temporary_name(string) -> self
0 commit comments