Skip to content

Commit 5f73dc3

Browse files
committed
Forgot this bit in my last commit
1 parent 50d2a3d commit 5f73dc3

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

lib/perl5i/2/Signatures.pm

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@ use Sub::Name;
1212
sub import {
1313
my $class = shift;
1414

15-
my %opts = @_;
16-
$opts{into} ||= caller;
15+
my %opts = @_;
16+
$opts{into} ||= caller;
1717
$opts{invocant} ||= '$self';
1818

1919
my %def_opts = %opts;
2020
delete $def_opts{invocant};
2121

2222
# Define "method"
2323
$class->install_methodhandler(
24-
name => 'method',
25-
%opts
24+
name => 'method',
25+
%opts
2626
);
2727

2828
# Define "func"
2929
$class->install_methodhandler(
30-
name => 'func',
31-
%def_opts
30+
name => 'func',
31+
%def_opts
3232
);
3333
}
3434

@@ -44,7 +44,7 @@ sub parse_proto {
4444
my $invocant = $self->{invocant};
4545

4646
my $inject = '';
47-
if( $invocant ) {
47+
if ($invocant) {
4848
$invocant = $1 if $proto =~ s{^(\$\w+):\s*}{};
4949
$inject .= "my ${invocant} = shift;";
5050
}
@@ -53,51 +53,54 @@ sub parse_proto {
5353
return $inject;
5454
}
5555

56-
5756
sub code_for {
58-
my ($self, $name) = @_;
57+
my ( $self, $name ) = @_;
5958

6059
my $signature = $self->{perl5i}{signature};
6160
my $is_method = $self->{invocant} ? 1 : 0;
6261

63-
if (defined $name) {
62+
if ( defined $name ) {
6463
my $pkg = $self->get_curstash_name;
6564
$name = join( '::', $pkg, $name )
66-
unless( $name =~ /::/ );
65+
unless ( $name =~ /::/ );
6766
return sub (&) {
6867
my $code = shift;
68+
( undef, undef, my $end_line ) = caller();
6969
# So caller() gets the subroutine name
7070
no strict 'refs';
7171
*{$name} = subname $name => $code;
7272

7373
$self->set_signature(
74-
code => $code,
75-
signature => $signature,
76-
is_method => $is_method,
74+
code => $code,
75+
signature => $signature,
76+
is_method => $is_method,
77+
end_line => $end_line,
7778
);
7879

7980
return;
8081
};
81-
} else {
82+
}
83+
else {
8284
return sub (&) {
8385
my $code = shift;
86+
( undef, undef, my $end_line ) = caller();
8487

8588
$self->set_signature(
86-
code => $code,
87-
signature => $signature,
88-
is_method => $is_method,
89+
code => $code,
90+
signature => $signature,
91+
is_method => $is_method,
92+
end_line => $end_line,
8993
);
9094
return $code;
9195
};
9296
}
9397
}
9498

95-
9699
sub set_signature {
97100
my $self = shift;
98101
my %args = @_;
99102

100-
my $sig = perl5i::2::CODE::signature($args{code});
103+
my $sig = perl5i::2::CODE::signature( $args{code} );
101104
return $sig if $sig;
102105

103106
$sig = perl5i::2::Signature->new(

0 commit comments

Comments
 (0)