ruby-changes:62258
From: Masataka <ko1@a...>
Date: Sat, 18 Jul 2020 08:37:43 +0900 (JST)
Subject: [ruby-changes:62258] 8d2333019a (master): Fix MonitorMixin when the super's initialize has kwargs
https://git.ruby-lang.org/ruby.git/commit/?id=8d2333019a From 8d2333019abb1f8ad882dadf9096f81e9f427c6e Mon Sep 17 00:00:00 2001 From: Masataka Pocke Kuwabara <kuwabara@p...> Date: Sat, 11 Jul 2020 16:01:05 +0900 Subject: Fix MonitorMixin when the super's initialize has kwargs diff --git a/ext/monitor/lib/monitor.rb b/ext/monitor/lib/monitor.rb index 63a54fe..08a3a31 100644 --- a/ext/monitor/lib/monitor.rb +++ b/ext/monitor/lib/monitor.rb @@ -220,7 +220,7 @@ module MonitorMixin https://github.com/ruby/ruby/blob/trunk/ext/monitor/lib/monitor.rb#L220 # 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 721c848..734b639 100644 --- a/test/monitor/test_monitor.rb +++ b/test/monitor/test_monitor.rb @@ -236,6 +236,22 @@ class TestMonitor < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/monitor/test_monitor.rb#L236 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" -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/