ruby-changes:63904
From: Masataka <ko1@a...>
Date: Fri, 4 Dec 2020 19:53:33 +0900 (JST)
Subject: [ruby-changes:63904] 60b57866ac (master): [ruby/mutex_m] Fix `Mutex_m#initialize` when the super's initialize has kwargs
https://git.ruby-lang.org/ruby.git/commit/?id=60b57866ac From 60b57866ac64ef8a21951c7d5ff7b7f98e1ce15f Mon Sep 17 00:00:00 2001 From: Masataka Pocke Kuwabara <p.ck.t22@g...> Date: Tue, 24 Nov 2020 00:37:13 +0900 Subject: [ruby/mutex_m] Fix `Mutex_m#initialize` when the super's initialize has kwargs Co-authored-by: Ryuta Kamizono <kamipo@g...> https://github.com/ruby/mutex_m/commit/84ca1fc108 diff --git a/lib/mutex_m.rb b/lib/mutex_m.rb index dd47934..07f5a9a 100644 --- a/lib/mutex_m.rb +++ b/lib/mutex_m.rb @@ -113,4 +113,5 @@ module Mutex_m https://github.com/ruby/ruby/blob/trunk/lib/mutex_m.rb#L113 mu_initialize super end + ruby2_keywords(:initialize) if respond_to?(:ruby2_keywords, true) end diff --git a/test/test_mutex_m.rb b/test/test_mutex_m.rb index 30971dd..e5cfbc8 100644 --- a/test/test_mutex_m.rb +++ b/test/test_mutex_m.rb @@ -23,4 +23,36 @@ class TestMutexM < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/test_mutex_m.rb#L23 c.signal assert_equal "abc", t.value end + + class KeywordInitializeParent + def initialize(x:) + end + end + + class KeywordInitializeChild < KeywordInitializeParent + include Mutex_m + def initialize + super(x: 1) + end + end + + def test_initialize_with_keyword_arg + assert KeywordInitializeChild.new + end + + class NoArgInitializeParent + def initialize + end + end + + class NoArgInitializeChild < NoArgInitializeParent + include Mutex_m + def initialize + super() + end + end + + def test_initialize_no_args + assert NoArgInitializeChild.new + end end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/