Skip Menu |

This queue is for tickets about the Class-Classless-C3 CPAN distribution.

Report information
The Basics
Id: 123671
Status: resolved
Priority: 0/
Queue: Class-Classless-C3

People
Owner: JWILLIAMS [...] cpan.org
Requestors: 'spro^^*%*^6ut# [...] &$%*c
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 1.01



Subject: [PATCH] Compatibility with constants and with CV-in-stash optimisation
Since perl 5.10, ‘use constant’ has cheated and put scalar references in the stash, not full typeglobs (at least when it can get away with it). Perl 5.28 will introduce (or extend) a new optimisation, detailed below. The attached patch makes Class::Classless::C3 work with both. From the perldelta for 5.27.6: =head2 Subroutines no longer need typeglobs Perl 5.22.0 introduced an optimization allowing subroutines to be stored in packages as simple sub refs, not requiring a full typeglob (thus potentially saving large amounts of memeory). However, the optimization was flawed: it only applied to the main package. This optimization has now been extended to all packages. This may break compatibility with introspection code that looks inside stashes and expects everything in them to be a typeglob. When this optimization happens, the typeglob still notionally exists, so accessing it will cause the stash entry to be upgraded to a typeglob. The optimization does not apply to XSUBs or exported subroutines, and calling a method will undo it, since method calls cache things in typeglobs. [perl #129916] [perl #132252]
Subject: open_YbePLB6W.txt
diff -rup Class-Classless-C3-1.00-1/lib/Class/Classless/C3.pm Class-Classless-C3-1.00-0/lib/Class/Classless/C3.pm --- Class-Classless-C3-1.00-1/lib/Class/Classless/C3.pm 2010-10-20 12:44:05.000000000 -0700 +++ Class-Classless-C3-1.00-0/lib/Class/Classless/C3.pm 2017-11-18 12:23:24.000000000 -0800 @@ -248,7 +248,11 @@ sub declassify my $symtable = \%{$class.'::'}; for my $sym ( keys %$symtable ) { next if $sym =~ m/^(AUTOLOAD|NEXT|can|isa|VERSION|meta|new)$/; - my $sub = *{$symtable->{$sym}}{CODE}; + my $sub = ref \$symtable->{$sym} eq 'GLOB' + ? *{$symtable->{$sym}}{CODE} + : exists &{$class.'::'.$sym} + ? \&{$class.'::'.$sym} + : undef; if (defined $sub) { $self->meta->addmethod($sym => $sub); delete ${$class.'::'}{$sym}; #deletes all glob-parts diff -rup Class-Classless-C3-1.00-1/t/Class-Classless-C3.t Class-Classless-C3-1.00-0/t/Class-Classless-C3.t --- Class-Classless-C3-1.00-1/t/Class-Classless-C3.t 2010-10-20 11:47:39.000000000 -0700 +++ Class-Classless-C3-1.00-0/t/Class-Classless-C3.t 2017-11-18 12:18:27.000000000 -0800 @@ -36,6 +36,7 @@ sub test my $self = shift; return join ',','base',$self->NEXT(); } +use constant foo => 3; }; my $t = Test::Inherit->Class::Classless::C3::Meta::declassify();
Thank you for the patch. An updated version is going up soon.