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

ruby-changes:66306

From: nagachika <ko1@a...>
Date: Sun, 23 May 2021 15:00:20 +0900 (JST)
Subject: [ruby-changes:66306] 410216c9db (ruby_3_0): merge revision(s) d8a13e504992a45d52063f7c925408d7aad3595a: [Backport #17780]

https://git.ruby-lang.org/ruby.git/commit/?id=410216c9db

From 410216c9db033a72f4dd119c366bc58dd54383ec Mon Sep 17 00:00:00 2001
From: nagachika <nagachika@r...>
Date: Sun, 23 May 2021 14:59:26 +0900
Subject: merge revision(s) d8a13e504992a45d52063f7c925408d7aad3595a: [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(-)
---
 proc.c                   |  2 +-
 test/ruby/test_method.rb | 13 +++++++++++++
 version.h                |  2 +-
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/proc.c b/proc.c
index d3310e8..a933fde 100644
--- a/proc.c
+++ b/proc.c
@@ -3199,7 +3199,7 @@ method_super_method(VALUE method) https://github.com/ruby/ruby/blob/trunk/proc.c#L3199
     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 cc7421b..240821c 100644
--- a/test/ruby/test_method.rb
+++ b/test/ruby/test_method.rb
@@ -1168,6 +1168,19 @@ class TestMethod < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_method.rb#L1168
     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 0e9aef5..0acccfc 100644
--- a/version.h
+++ b/version.h
@@ -12,7 +12,7 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L12
 # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
 #define RUBY_VERSION_TEENY 2
 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 84
+#define RUBY_PATCHLEVEL 85
 
 #define RUBY_RELEASE_YEAR 2021
 #define RUBY_RELEASE_MONTH 5
-- 
cgit v1.1


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

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