From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 9FC721F4B4 for ; Mon, 5 Apr 2021 00:12:54 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 8CA4C120D24; Mon, 5 Apr 2021 09:11:54 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id C6FB1120C94 for ; Mon, 5 Apr 2021 09:11:52 +0900 (JST) Received: by filterdrecv-p3las1-699f5f7ff5-zpgll with SMTP id filterdrecv-p3las1-699f5f7ff5-zpgll-19-606A5602-2E 2021-04-05 00:12:50.751592762 +0000 UTC m=+1057188.624473634 Received: from herokuapp.com (unknown) by ismtpd0202p1mdw1.sendgrid.net (SG) with ESMTP id 7KHguvduRfuMUKdtXcfyTQ for ; Mon, 05 Apr 2021 00:12:50.633 +0000 (UTC) Date: Mon, 05 Apr 2021 00:12:50 +0000 (UTC) From: usa@garbagecollect.jp Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 79274 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 17130 X-Redmine-Issue-Author: jeremyevans0 X-Redmine-Sender: usa X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?9Ij0W+xF+66shKwcOf8RvdqxJGkEJjaCZuueI4cieuBQelZjz+yD1BwfuTAkyX?= =?us-ascii?Q?wH4AlcSzBrOFPiaJFn=2FAX2qKxKwOx9Pq2F4hFLk?= =?us-ascii?Q?BAaKHVPULt8dyrjmx=2FidiyQXhnP5IxzSGri6JiO?= =?us-ascii?Q?hsMioeJ3ipDUSWapGZpO4dn=2FZi9unImFDdb6EOs?= =?us-ascii?Q?5NXWaWx8qlEMAzD2XHjfKMF0WdtX0ccglTS4q0C?= =?us-ascii?Q?NoE6ivHxmckpHmBU4=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 103229 Subject: [ruby-core:103229] [Ruby master Bug#17130] Method#super_method is broken for aliased methods X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #17130 has been updated by usa (Usaku NAKAMURA). Backport changed from 2.5: UNKNOWN, 2.6: REQUIRED, 2.7: DONE to 2.5: UNKNOWN, 2.6: DONE, 2.7: DONE backported into ruby_2_6 at r67933 ---------------------------------------- Bug #17130: Method#super_method is broken for aliased methods https://bugs.ruby-lang.org/issues/17130#change-91307 * Author: jeremyevans0 (Jeremy Evans) * Status: Closed * Priority: Normal * ruby -v: ruby 2.8.0dev (2020-08-25T21:09:31Z master a84a2e872f) [x86_64-openbsd6.7] * Backport: 2.5: UNKNOWN, 2.6: DONE, 2.7: DONE ---------------------------------------- Method#super_method currently does not work correctly for aliased methods. Here's a simple example: ```ruby class A def m1; p :A_m1 end def m2; p :A_m2 end end class B < A def m1; p :B_m1; super end alias m2 m1 end B.new.m2 puts m = B.new.method(:m2) m.call puts m.super_method.call ``` Current Output: ``` :B_m1 :A_m1 :B_m1 :A_m1 :A_m2 ``` You can see from this example that normal super lookup for B#m2 is A#m1, as B#m2 is an alias of B#m1 and super lookup follows the original method name, not the aliased name. However, the `super_method` call returns a Method instance for A#m2 instead of A#m1. There is another issue with aliases and that is when the method being aliased is from another module or class. In this case, super lookup needs to start at the super class of the defined class of the method being aliased. See https://bugs.ruby-lang.org/issues/11189#note-3 for an example of that issue. I have a fix that handles both of these cases that I'll submit shortly via a pull request. -- https://bugs.ruby-lang.org/