line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
526
|
use 5.014; |
|
1
|
|
|
|
|
2
|
|
2
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
19
|
|
3
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
59
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Kavorka::TraitFor::Sub::override; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
8
|
|
|
|
|
|
|
our $VERSION = '0.037'; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
3
|
use Moo::Role; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
9
|
|
11
|
1
|
|
|
1
|
|
215
|
use Types::Standard qw(Any); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
12
|
1
|
|
|
1
|
|
308
|
use Carp qw(croak); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
50
|
|
13
|
1
|
|
|
1
|
|
3
|
use namespace::sweep; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
before install_sub => sub |
16
|
|
|
|
|
|
|
{ |
17
|
|
|
|
|
|
|
my $self = shift; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
croak("The 'override' trait cannot be applied to lexical methods") |
20
|
|
|
|
|
|
|
if $self->is_lexical; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
croak("The 'override' trait cannot be applied to anonymous methods") |
23
|
|
|
|
|
|
|
if $self->is_anonymous; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
croak("The 'override' trait may only be applied to methods") |
26
|
|
|
|
|
|
|
if $self->invocation_style ne 'method'; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my ($pkg, $name) = ($self->qualified_name =~ /^(.+)::(\w+)$/); |
29
|
|
|
|
|
|
|
return if $pkg->can($name); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
croak("Method '$name' does not exist in inheritance hierarchy; cannot override"); |
32
|
|
|
|
|
|
|
}; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |