line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sub::Meta::TypeSub; |
2
|
3
|
|
|
3
|
|
927
|
use 5.010; |
|
3
|
|
|
|
|
22
|
|
3
|
3
|
|
|
3
|
|
19
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
58
|
|
4
|
3
|
|
|
3
|
|
27
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
138
|
|
5
|
3
|
|
|
3
|
|
513
|
use parent qw(Type::Tiny); |
|
3
|
|
|
|
|
356
|
|
|
3
|
|
|
|
|
16
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
20001
|
use Types::Standard qw(InstanceOf); |
|
3
|
|
|
|
|
65539
|
|
|
3
|
|
|
|
|
23
|
|
8
|
|
|
|
|
|
|
|
9
|
39
|
|
|
39
|
1
|
130
|
sub submeta_type { my $self = shift; return $self->{submeta_type} } |
|
39
|
|
|
|
|
99
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
## override |
12
|
|
|
|
|
|
|
sub new { |
13
|
7
|
|
|
7
|
1
|
7545
|
my $class = shift; |
14
|
7
|
100
|
|
|
|
34
|
my %params = ( @_ == 1 ) ? %{ $_[0] } : @_; |
|
1
|
|
|
|
|
3
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
## no critic (Subroutines::ProtectPrivateSubs) |
17
|
7
|
100
|
|
|
|
27
|
Type::Tiny::_croak "Need to supply submeta_type" unless exists $params{submeta_type}; |
18
|
|
|
|
|
|
|
|
19
|
5
|
100
|
|
|
|
14
|
if (!exists $params{name}) { |
20
|
4
|
100
|
|
|
|
24
|
$params{name} = $params{submeta_type}->submeta_strict_check ? 'StrictSub' : 'Sub'; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
5
|
|
|
|
|
30
|
return $class->SUPER::new(%params); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
## override |
27
|
3
|
|
|
3
|
1
|
16
|
sub can_be_inlined { return !!0 } |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
## override |
30
|
|
|
|
|
|
|
sub _build_display_name { ## no critic (ProhibitUnusedPrivateSubroutines) |
31
|
3
|
|
|
3
|
|
444
|
my $self = shift; |
32
|
3
|
|
|
|
|
7
|
return sprintf('%s[%s]', $self->name, $self->submeta_type->submeta->display); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
## override |
36
|
|
|
|
|
|
|
sub _build_constraint { ## no critic (ProhibitUnusedPrivateSubroutines) |
37
|
3
|
|
|
3
|
|
103
|
my $self = shift; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
return sub { |
40
|
16
|
|
|
16
|
|
1983
|
my $sub = shift; |
41
|
16
|
|
|
|
|
30
|
my $other_meta = $self->submeta_type->coerce($sub); |
42
|
16
|
|
|
|
|
27
|
$self->submeta_type->check($other_meta) |
43
|
|
|
|
|
|
|
} |
44
|
3
|
|
|
|
|
14
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
## override |
47
|
|
|
|
|
|
|
sub get_message { |
48
|
2
|
|
|
2
|
1
|
3527
|
my $self = shift; |
49
|
2
|
|
|
|
|
3
|
my $sub = shift; |
50
|
|
|
|
|
|
|
|
51
|
2
|
|
|
|
|
11
|
my $default = $self->SUPER::get_message($sub); |
52
|
2
|
|
|
|
|
6189
|
my $meta = $self->submeta_type->coerce($sub); |
53
|
|
|
|
|
|
|
|
54
|
2
|
|
|
|
|
30
|
state $SubMeta = InstanceOf['Sub::Meta']; |
55
|
|
|
|
|
|
|
|
56
|
2
|
|
|
|
|
108
|
my $message = "$default\n"; |
57
|
2
|
100
|
|
|
|
11
|
if ($SubMeta->check($meta)) { |
58
|
1
|
|
|
|
|
11
|
$message .= $self->submeta_type->get_detail_message($meta); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
else { |
61
|
1
|
|
|
|
|
8
|
my $s = Type::Tiny::_dd($sub); ## no critic (Subroutines::ProtectPrivateSubs) |
62
|
1
|
|
|
|
|
10
|
$message .= " Cannot find submeta of `$s`"; |
63
|
|
|
|
|
|
|
} |
64
|
2
|
|
|
|
|
26
|
return $message; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
__END__ |