diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-05-18 13:36:48 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-05-21 18:09:27 -0700 |
commit | 234df27b26b3e259edfeda438b80eb3ed1d8b5ec (patch) | |
tree | 3ca43a3a59939b5d7517fd782273828a230d78a5 /mro.c | |
parent | ef38ce040f8843ec54aca57219ab9fbadcea4cb8 (diff) | |
download | perl-234df27b26b3e259edfeda438b80eb3ed1d8b5ec.tar.gz |
[perl #112708] Update overloadedness with ‘use overload’
Instead of setting a class’s overloaded (HvAMAGIC) flag when bless
happens, we should do it in ‘use overload’. Otherwise, if a non-over-
loaded class gains overloading via ‘use overload’, existing objects
won’t get overloading until another object is blessed into the
same class.
Inherited overloading that is turned on due to @ISA changes still
won’t work yet. That will come in a later commit.
Doing this via %OVERLOAD magic would require referencing
the stash from magic. Since overload.pm already does
‘*{$package . "::()"} = \&nil’, triggering mro_method_changed_in,
the simplest approach is to turn on the stash’s AMAGIC flag in
mro_method_changed_in. Since, if there is no overloading, the flag
will be turned off on the next attempted overload call (in Gv_AM in
sv.h), there should be noticeable slowdown.
I had to turn off HvAMAGIC in hv_undef, to prevent ‘Can't use anony-
nous symbol table for method lookup’ from occurring when stringifying
an object whose package has been undefined.
Diffstat (limited to 'mro.c')
-rw-r--r-- | mro.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -1346,6 +1346,10 @@ Perl_mro_method_changed_in(pTHX_ HV *stash) hv_clear(mrometa->mro_nextmethod); } } + + /* The method change may be due to *{$package . "::()"} = \&nil; in + overload.pm. */ + HvAMAGIC_on(stash); } void |