[前][次][番号順一覧][スレッド一覧]

ruby-changes:66674

From: usa <ko1@a...>
Date: Sun, 4 Jul 2021 01:53:52 +0900 (JST)
Subject: [ruby-changes:66674] 67b324529b (ruby_2_6): merge revision(s) d8a13e50: [Backport #17780]

https://git.ruby-lang.org/ruby.git/commit/?id=67b324529b

From 67b324529b378c34fcc0fd910fa4139fc6cc5478 Mon Sep 17 00:00:00 2001
From: usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
Date: Sat, 3 Jul 2021 16:53:29 +0000
Subject: merge revision(s) d8a13e50: [Backport #17780]

	[Bug #17780] Fix Method#super_method for module alias

	Method#super_method crashes for aliased module methods because they are
	not defined on a class. This bug was introduced in
	c60aaed1856b2b6f90de0992c34771830019e021 as part of bug #17130.
	---
	 proc.c                   |  2 +-
	 test/ruby/test_method.rb | 13 +++++++++++++
	 2 files changed, 14 insertions(+), 1 deletion(-)

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67945 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
---
 proc.c                   |  2 +-
 test/ruby/test_method.rb | 13 +++++++++++++
 version.h                |  8 ++++----
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/proc.c b/proc.c
index d3d75cb..fc1fdf7 100644
--- a/proc.c
+++ b/proc.c
@@ -2781,7 +2781,7 @@ method_super_method(VALUE method) https://github.com/ruby/ruby/blob/trunk/proc.c#L2781
     TypedData_Get_Struct(method, struct METHOD, &method_data_type, data);
     iclass = data->iclass;
     if (!iclass) return Qnil;
-    if (data->me->def->type == VM_METHOD_TYPE_ALIAS) {
+    if (data->me->def->type == VM_METHOD_TYPE_ALIAS && data->me->defined_class) {
         super_class = RCLASS_SUPER(rb_find_defined_class_by_owner(data->me->defined_class,
             data->me->def->body.alias.original_me->owner));
         mid = data->me->def->body.alias.original_me->def->original_id;
diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb
index 1df09c2..3bf2592 100644
--- a/test/ruby/test_method.rb
+++ b/test/ruby/test_method.rb
@@ -1038,6 +1038,19 @@ class TestMethod < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_method.rb#L1038
     assert_nil(m.super_method)
   end
 
+  # Bug 17780
+  def test_super_method_module_alias
+    m = Module.new do
+      def foo
+      end
+      alias :f :foo
+    end
+
+    method = m.instance_method(:f)
+    super_method = method.super_method
+    assert_nil(super_method)
+  end
+
   def rest_parameter(*rest)
     rest
   end
diff --git a/version.h b/version.h
index c7eb06d..31a7605 100644
--- a/version.h
+++ b/version.h
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L1
 #define RUBY_VERSION "2.6.8"
-#define RUBY_RELEASE_DATE "2021-06-24"
-#define RUBY_PATCHLEVEL 200
+#define RUBY_RELEASE_DATE "2021-07-04"
+#define RUBY_PATCHLEVEL 201
 
 #define RUBY_RELEASE_YEAR 2021
-#define RUBY_RELEASE_MONTH 6
-#define RUBY_RELEASE_DAY 24
+#define RUBY_RELEASE_MONTH 7
+#define RUBY_RELEASE_DAY 4
 
 #include "ruby/version.h"
 
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]