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=-3.8 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 3BEFD1F66E for ; Wed, 26 Aug 2020 17:39:27 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 405B8120A35; Thu, 27 Aug 2020 02:38: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 189CC120A33 for ; Thu, 27 Aug 2020 02:38:52 +0900 (JST) Received: by filterdrecv-p3mdw1-5b7978bb98-k9d6g with SMTP id filterdrecv-p3mdw1-5b7978bb98-k9d6g-18-5F469E4A-61 2020-08-26 17:39:22.808829723 +0000 UTC m=+79728.138374165 Received: from herokuapp.com (unknown) by ismtpd0023p1iad2.sendgrid.net (SG) with ESMTP id Q0P8fBGBQ7COL2C-A37WZQ for ; Wed, 26 Aug 2020 17:39:22.731 +0000 (UTC) Date: Wed, 26 Aug 2020 17:39:22 +0000 (UTC) From: merch-redmine@jeremyevans.net Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 75543 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 17130 X-Redmine-Issue-Author: jeremyevans0 X-Redmine-Sender: jeremyevans0 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?RVE3t853K5scBhbmJHUzZTFFeVC=2FZSUmHZ0Dc+26wcEi2CTgsF1oz0wTSSxGGN?= =?us-ascii?Q?BI1JtcuQ8BgQcHAm0mythwifm1P5ba0hobgvzuW?= =?us-ascii?Q?dbw90Pwlaj1q3uiNA1mp2RUjgJdjky2HUtDj1m4?= =?us-ascii?Q?THkXUzYQXjiqIsq3xlswXdYzkJz2eMic9x4h4wV?= =?us-ascii?Q?SHWyINsbXdXj0AqCLo1UQVZxEVYGQASFYa4cpZv?= =?us-ascii?Q?uN23lKjN5+oc1nMCE=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 99710 Subject: [ruby-core:99710] [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 jeremyevans0 (Jeremy Evans). Pull request submitted: https://github.com/ruby/ruby/pull/3458 ---------------------------------------- Bug #17130: Method#super_method is broken for aliased methods https://bugs.ruby-lang.org/issues/17130#change-87200 * Author: jeremyevans0 (Jeremy Evans) * Status: Open * 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: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- 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/