summaryrefslogtreecommitdiff
path: root/lib/Attribute
diff options
context:
space:
mode:
authorRichard Clamp <richardc@unixbeard.net>2002-12-09 11:10:24 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2003-01-16 20:58:59 +0000
commitc760c918c71b4e55dc300234d0a8679a6bdf1e3c (patch)
treea26b424e29bfdea17112b37fe4a9f4ee9e88d68e /lib/Attribute
parent0de8cad8cba777e31f98ef8b8ac579070f7c78a6 (diff)
downloadperl-c760c918c71b4e55dc300234d0a8679a6bdf1e3c.tar.gz
Integrate changes to Attribute::Handlers from maint-5.8
(18404 and 18427). Subject: [PATCH] Re: Attribute::Handlers phase variance Message-ID: <20021209111024.GA14365@mirth.demon.co.uk> p4raw-id: //depot/perl@18499 p4raw-integrated: from //depot/maint-5.8/perl@18498 'copy in' lib/Attribute/Handlers.pm (@18080..) lib/Attribute/Handlers/t/multi.t (@18404..)
Diffstat (limited to 'lib/Attribute')
-rw-r--r--lib/Attribute/Handlers.pm3
-rw-r--r--lib/Attribute/Handlers/t/multi.t17
2 files changed, 19 insertions, 1 deletions
diff --git a/lib/Attribute/Handlers.pm b/lib/Attribute/Handlers.pm
index a26ed180b5..9dfe783c66 100644
--- a/lib/Attribute/Handlers.pm
+++ b/lib/Attribute/Handlers.pm
@@ -137,7 +137,8 @@ sub _gen_handler_AH_() {
%lastattr=(pkg=>$pkg,ref=>$ref,type=>$data);
}
else {
- my $handler = $pkg->can($attr);
+ my $type = ref $ref;
+ my $handler = $pkg->can("_ATTR_${type}_${attr}");
next unless $handler;
my $decl = [$pkg, $ref, $attr, $data,
$raw{$handler}, $phase{$handler}];
diff --git a/lib/Attribute/Handlers/t/multi.t b/lib/Attribute/Handlers/t/multi.t
index cddab91153..db00b1c933 100644
--- a/lib/Attribute/Handlers/t/multi.t
+++ b/lib/Attribute/Handlers/t/multi.t
@@ -184,3 +184,20 @@ ok(1,52 ,"# Skip, no difference between lexical handlers and normal handlers pri
ok( $match, 52 );
}
+
+# The next two check for the phase invariance that Marcel spotted.
+# Subject: Attribute::Handlers phase variance
+# Message-Id: <54EDDB80-FD75-11D6-A18D-00039379E28A@noug.at>
+
+my ($code_applied, $scalar_applied);
+sub Scotty :ATTR(CODE,BEGIN) { $code_applied = $_[5] }
+{
+no warnings 'redefine';
+sub Scotty :ATTR(SCALAR,CHECK) { $scalar_applied = $_[5] }
+}
+
+sub warp_coil :Scotty {}
+my $photon_torpedo :Scotty;
+
+ok( $code_applied eq 'BEGIN', 53, "# phase variance" );
+ok( $scalar_applied eq 'CHECK', 54 );