[#49078] DevelopersMeeting20150728Japan — SASADA Koichi <ko1@...>
Hi,
5 messages
2015/06/12
[ruby-dev:49160] [Ruby trunk - Bug #11173] inter class/module alias causes "no superclass method"
From:
usa@...
Date:
2015-06-30 04:14:04 UTC
List:
ruby-dev #49160
Issue #11173 has been updated by Usaku NAKAMURA.
Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN to 2.0.0: WONTFIX, 2.1: REQUIRED, 2.2: REQUIRED
いったん2.1と2.2でREQUIREDとしてますが、必ずしも直さないといけないと思っているわけではありません。
(問題自体はあるよ、というマーク付け)
----------------------------------------
Bug #11173: inter class/module alias causes "no superclass method"
https://bugs.ruby-lang.org/issues/11173#change-53197
* Author: Koichi Sasada
* Status: Closed
* Priority: Normal
* Assignee:
* ruby -v:
* Backport: 2.0.0: WONTFIX, 2.1: REQUIRED, 2.2: REQUIRED
----------------------------------------
```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 #<C1:0x109634c> (NoMethodError)
from test.rb:26:in `<main>'
```
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/