case SAVEt_GP: /* scalar reference */
ptr = SSPOPPTR;
gv = MUTABLE_GV(SSPOPPTR);
- gp_free(gv);
- GvGP_set(gv, (GP*)ptr);
- if ((hv=GvSTASH(gv)) && HvENAME_get(hv)) {
+ {
+ /* possibly taking a method out of circulation */
+ const bool had_method = !!GvCVu(gv);
+ gp_free(gv);
+ GvGP_set(gv, (GP*)ptr);
+ if ((hv=GvSTASH(gv)) && HvENAME_get(hv)) {
if (GvNAMELEN(gv) == 3 && strnEQ(GvNAME(gv), "ISA", 3))
mro_isa_changed_in(hv);
- else if (GvCVu(gv))
+ else if (had_method || GvCVu(gv))
/* putting a method back into circulation ("local")*/
gv_method_changed(gv);
+ }
}
SvREFCNT_dec(gv);
break;
sub { is(MCTest::Derived->foo(0), 5); },
sub { sub FFF { $_[1]+7 }; local *MCTest::Base::foo = *FFF; is(MCTest::Derived->foo(0), 7); },
sub { is(MCTest::Derived->foo(0), 5); },
+ sub { { local *MCTest::Base::can = sub { "tomatoes" };
+ MCTest::Derived->can(0); }
+ local $::TODO = " ";
+ is(MCTest::Derived->can("isa"), \&UNIVERSAL::isa,
+ 'removing method when unwinding local *method=sub{}'); },
+ sub { sub peas { "peas" }
+ { local *MCTest::Base::can = *peas;
+ MCTest::Derived->can(0); }
+ is(MCTest::Derived->can("isa"), \&UNIVERSAL::isa,
+ 'removing method when unwinding local *method=*other'); },
sub { sub DDD { $_[1]+8 }; *MCTest::Base::foo = *DDD; is(MCTest::Derived->foo(0), 8); },
sub { *ASDF::asdf = sub { $_[1]+9 }; *MCTest::Base::foo = \&ASDF::asdf; is(MCTest::Derived->foo(0), 9); },
sub { undef *MCTest::Base::foo; eval { MCTest::Derived->foo(0) }; like($@, qr/locate object method/); },