Subject: | [PATCH] Fix to work with subref-in-stash optimisation |
Sorry for not using GitHub, but GitHub is a bit flaky for me right now. See the attached patch, which you should be able to feed straight into ‘git am’.
Subject: | open_6AeQqWxM.txt |
From: Father Chrysostomos <sprout@cpan.org>
Fix to work with subref-in-stash optimisation
The subref-in-stash optimisation introduced in perl 5.22 accidentally
applied only to the main package. I am trying to rectify that now,
but it causes Test::Simple to fail its tests, because it assumes that
any defined sub has already created a typeglob in the stash. A sub
ref cannot be dereferenced with *{ }.
diff --git a/lib/Test2/Event/Generic.pm b/lib/Test2/Event/Generic.pm
index ad00f5a..67ec877 100644
--- a/lib/Test2/Event/Generic.pm
+++ b/lib/Test2/Event/Generic.pm
@@ -35,15 +35,12 @@ sub init {
for my $field (@FIELDS) {
no strict 'refs';
- my $stash = \%{__PACKAGE__ . "::"};
*$field = sub { exists $_[0]->{$field} ? $_[0]->{$field} : () }
- unless defined $stash->{$field}
- && defined *{$stash->{$field}}{CODE};
+ unless exists &{$field};
*{"set_$field"} = sub { $_[0]->{$field} = $_[1] }
- unless defined $stash->{"set_$field"}
- && defined *{$stash->{"set_$field"}}{CODE};
+ unless exists &{"set_$field"};
}
sub summary {