Subject: | SUPER:: is always sort-of broken |
SUPER:: is always sort-of broken:
* $obj->SUPER::foo will never actually use $obj for the method
resolution -- it will use the *package in which the code was
compiled in*.
* $obj->can('SUPER::foo'), similarly, will use the "current"
place in the callstack to find the next one.
The problem here is that Class::Std overrides UNIVERSAL::can,
so when it calls $original_can->($class, $method) and $method
is SUPER::foo, the SUPER code will look at the 'current' place
in the callstack.. which is the UNIVERSAL::can override in
Class::Std.
Whoops.
In particular, this was breaking AnyEvent, which uses this
lovely construct:
goto &{ UNIVERSAL::can AnyEvent => "SUPER::$name" }
Previously, SUPER::$name broke if Class::Std was loaded.
see https://github.com/chorny/Class-Std/pull/3/commits/933aeb3063c25ee0e8a358f6465536086a590c2b by Brian Fraser and similar commit by Tom van der Woerdt
Subject: | diff.txt |
392c392
< if ( (my $sub_ref = $real_can->(@_)) || $method_name=~/^[()]/ ) {
---
> if (my $sub_ref = $real_can->(@_)) {
410c410
< goto &$real_can;
---
> return;