diff options
author | Masataka Pocke Kuwabara <[email protected]> | 2020-07-11 16:01:05 +0900 |
---|---|---|
committer | Jeremy Evans <[email protected]> | 2020-07-17 16:37:18 -0700 |
commit | 8d2333019abb1f8ad882dadf9096f81e9f427c6e (patch) | |
tree | ffe4a76e48d0c0de9ea1aa6a1711814909a2bc50 | |
parent | 1fb4e28002327c1224c3ed32783160b011f14747 (diff) |
Fix MonitorMixin when the super's initialize has kwargs
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3310
-rw-r--r-- | ext/monitor/lib/monitor.rb | 2 | ||||
-rw-r--r-- | test/monitor/test_monitor.rb | 16 |
2 files changed, 17 insertions, 1 deletions
diff --git a/ext/monitor/lib/monitor.rb b/ext/monitor/lib/monitor.rb index 63a54fe731..08a3a31ef0 100644 --- a/ext/monitor/lib/monitor.rb +++ b/ext/monitor/lib/monitor.rb @@ -220,7 +220,7 @@ module MonitorMixin # Use <tt>extend MonitorMixin</tt> or <tt>include MonitorMixin</tt> instead # of this constructor. Have look at the examples above to understand how to # use this module. - def initialize(*args) + def initialize(...) super mon_initialize end diff --git a/test/monitor/test_monitor.rb b/test/monitor/test_monitor.rb index 721c848d68..734b639d4c 100644 --- a/test/monitor/test_monitor.rb +++ b/test/monitor/test_monitor.rb @@ -236,6 +236,22 @@ class TestMonitor < Test::Unit::TestCase assert NewCondTest.new.cond.instance_variable_get(:@monitor) != nil end + class KeywordInitializeParent + def initialize(x:) + end + end + + class KeywordInitializeChild < KeywordInitializeParent + include MonitorMixin + def initialize + super(x: 1) + end + end + + def test_initialize_with_keyword_arg + assert KeywordInitializeChild.new + end + def test_timedwait cond = @monitor.new_cond b = "foo" |