int filled = 0, have_ovl = 0;
int i, lim = 1;
- /* The first key in PL_AMG_names is the overloadedness indicator, which
- allows us to skip overloading entries for non-overloaded classes. */
+ /* Work with "fallback" key, which we assume to be first in PL_AMG_names */
/* Try to find via inheritance. */
GV *gv = gv_fetchmeth_pvn(stash, PL_AMG_names[0], 2, -1, 0);
+ SV * const sv = gv ? GvSV(gv) : NULL;
CV* cv;
if (!gv)
+ {
+ if (!gv_fetchmeth_pvn(stash, "((", 2, -1, 0))
lim = DESTROY_amg; /* Skip overloading entries. */
-
- else {
-
- /* The "fallback" key is special-cased here, being absent from the
- list in PL_AMG_names. */
-
- SV *sv;
- gv = gv_fetchmeth_pvn(stash, "(fallback", 9, -1, 0);
-
- if (!gv || !(sv = GvSV(gv)))
+ }
+#ifdef PERL_DONT_CREATE_GVSV
+ else if (!sv) {
NOOP; /* Equivalent to !SvTRUE and !SvOK */
- else if (SvTRUE(sv))
+ }
+#endif
+ else if (SvTRUE(sv))
amt.fallback=AMGfallYES;
- else if (SvOK(sv))
+ else if (SvOK(sv))
amt.fallback=AMGfallNEVER;
- }
for (i = 1; i < lim; i++)
amt.table[i] = NULL;
$package = shift;
my %arg = @_;
my ($sub, $fb);
- *{$package . "::()"} = \&nil; # Make it findable via fetchmethod.
+ *{$package . "::(("} = \&nil; # Make it findable via fetchmethod.
for (keys %arg) {
if ($_ eq 'fallback') {
- for my $sym (*{$package . "::(fallback"}) {
+ for my $sym (*{$package . "::()"}) {
*$sym = \&nil; # Make it findable via fetchmethod.
$$sym = $arg{$_};
}
sub unimport {
$package = (caller())[0];
shift;
+ *{$package . "::(("} = \&nil;
for (@_) {
warnings::warnif("overload arg '$_' is invalid")
unless $ops_seen{$_};
- delete $ {$package . "::"}{"(" . $_};
+ delete $ {$package . "::"}{$_ eq 'fallback' ? '()' : "(" .$_};
}
}
sub Overloaded {
my $package = shift;
$package = ref $package if ref $package;
- mycan ($package, '()');
+ mycan ($package, '()') || mycan ($package, '((');
}
sub ov_method {
$| = 1;
BEGIN { require './test.pl' }
-plan tests => 5081;
+plan tests => 5082;
use Scalar::Util qw(tainted);
is eval { "$a" }, 'twine', ':: in method name' or diag $@;
is eval { !$a }, 1, "' in method name" or diag $@;
+# [perl #113050] Half of CPAN assumes fallback is under "()"
+{
+ package dodo;
+ use overload '+' => sub {};
+ no strict;
+ *{"dodo::()"} = sub{};
+ ${"dodo::()"} = 1;
+}
+$a = bless [],'dodo';
+is eval {"$a"}, overload::StrVal($a), 'fallback is stored under "()"';
+
{ # undefining the overload stash -- KEEP THIS TEST LAST
package ant;