From: ko1@... Date: 2015-05-23T18:58:41+00:00 Subject: [ruby-dev:48992] [Ruby trunk - Bug #11173] [Open] inter class/module alias causes "no superclass method" Issue #11173 has been reported by Koichi Sasada. ---------------------------------------- Bug #11173: inter class/module alias causes "no superclass method" https://bugs.ruby-lang.org/issues/11173 * Author: Koichi Sasada * Status: Open * Priority: Normal * Assignee: * ruby -v: * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- ```ruby class C0 def foo p :C0 end end module M0 def foo p :M0 super end end module M1 include M0 alias orig_foo foo end class C1 < C0 include M1 end p C1.ancestors C1.new.orig_foo ``` 結果: ``` ruby 2.3.0dev (2015-05-21 trunk 50502) [i386-mswin32_110] [C1, M1, M0, C0, Object, Kernel, BasicObject] :M0 test.rb:12:in `foo': super: no superclass method `foo' for # (NoMethodError) from test.rb:26:in `
' ``` M0#foo の super である C0#foo が呼ばれてもいいと思うのですが、 この挙動はそういうもんでしたっけ。 挙動的には、M1 の alias で作られる method_entry が M0 の T_ICLASS (TI1) を指すけど、C1 からの継承関係で作られる M0 を指す T_ICLASS (TI2)と、TI1 が関係ないから、起こっているんだと思います。 なんか、class/module をまたいだ alias の挙動(と、その super での挙動)が色々怪しい感じです。 -- https://bugs.ruby-lang.org/