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-Status: No, score=-2.6 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=no 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 24C891F9FC for ; Sat, 20 Mar 2021 04:57:30 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id DA62F1209EB; Sat, 20 Mar 2021 13:56:31 +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 E7C17120927 for ; Sat, 20 Mar 2021 13:56:29 +0900 (JST) Received: by filterdrecv-p3iad2-7b664dbcb7-5jjj2 with SMTP id filterdrecv-p3iad2-7b664dbcb7-5jjj2-17-605580B5-8 2021-03-20 04:57:25.154838084 +0000 UTC m=+121913.869972321 Received: from herokuapp.com (unknown) by ismtpd0161p1iad2.sendgrid.net (SG) with ESMTP id pPAjSyYNTP2GlmUXQ_V6bA for ; Sat, 20 Mar 2021 04:57:25.082 +0000 (UTC) Date: Sat, 20 Mar 2021 04:57:25 +0000 (UTC) From: nagachika00@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 78978 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 17130 X-Redmine-Issue-Author: jeremyevans0 X-Redmine-Sender: nagachika 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?O2wxg26uOO6cft6GjkEp=2FGevTnH9lR=2FEdG60AX3F8=2FD7PuQej1mBQCmEkCSA7P?= =?us-ascii?Q?W4m28rhTPwarwDRx5fay+gLK3J+QrTww=2FLl3JzX?= =?us-ascii?Q?lnGvY6VY0ZXFSdxtdi8ndL6DJTEvGRC3ZM10skM?= =?us-ascii?Q?G7xhCxqClBKQN3ihfDrGBo1ypUF6mlOGGN+SRtj?= =?us-ascii?Q?BMdxSvZi=2F=2FwP6NEBsu6oPR6Fg6rzxu+pRi47ntm?= =?us-ascii?Q?I00Z6fMCrSOIqvFuQ=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 102943 Subject: [ruby-core:102943] [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 nagachika (Tomoyuki Chikanaga). Backport changed from 2.5: UNKNOWN, 2.6: REQUIRED, 2.7: REQUIRED to 2.5: UNKNOWN, 2.6: REQUIRED, 2.7: DONE ruby_2_7 c98aa2db60f43e839d7a82897c22b5ceecbed417 merged revision(s) c60aaed1856b2b6f90de0992c34771830019e021. ---------------------------------------- Bug #17130: Method#super_method is broken for aliased methods https://bugs.ruby-lang.org/issues/17130#change-91009 * 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: REQUIRED, 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/