|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
  
 
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package Type::Coercion::Union;  | 
| 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
3
 | 
22
 | 
 
 | 
 
 | 
  
22
  
 | 
 
 | 
1349
 | 
 use 5.008001;  | 
| 
 
 | 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
93
 | 
    | 
| 
4
 | 
22
 | 
 
 | 
 
 | 
  
22
  
 | 
 
 | 
135
 | 
 use strict;  | 
| 
 
 | 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
98
 | 
    | 
| 
 
 | 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
581
 | 
    | 
| 
5
 | 
22
 | 
 
 | 
 
 | 
  
22
  
 | 
 
 | 
130
 | 
 use warnings;  | 
| 
 
 | 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
48
 | 
    | 
| 
 
 | 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1105
 | 
    | 
| 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 BEGIN {  | 
| 
8
 | 
22
 | 
 
 | 
 
 | 
  
22
  
 | 
 
 | 
83
 | 
 	$Type::Coercion::Union::AUTHORITY = 'cpan:TOBYINK';  | 
| 
9
 | 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
975
 | 
 	$Type::Coercion::Union::VERSION   = '2.004000';  | 
| 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 $Type::Coercion::Union::VERSION =~ tr/_//d;  | 
| 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
14
 | 
22
 | 
 
 | 
 
 | 
  
22
  
 | 
 
 | 
148
 | 
 use Scalar::Util qw< blessed >;  | 
| 
 
 | 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
53
 | 
    | 
| 
 
 | 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1193
 | 
    | 
| 
15
 | 
22
 | 
 
 | 
 
 | 
  
22
  
 | 
 
 | 
154
 | 
 use Types::TypeTiny ();  | 
| 
 
 | 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
82
 | 
    | 
| 
 
 | 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
11275
 | 
    | 
| 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
17
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
7
 | 
 sub _croak ($;@) { require Error::TypeTiny; goto \&Error::TypeTiny::croak }  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
    | 
| 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
19
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 require Type::Coercion;  | 
| 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our @ISA = 'Type::Coercion';  | 
| 
21
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub _preserve_type_constraint {  | 
| 
23
 | 
65
 | 
 
 | 
 
 | 
  
65
  
 | 
 
 | 
120
 | 
 	my $self = shift;  | 
| 
24
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	$self->{_union_of} = $self->{type_constraint}->type_constraints  | 
| 
25
 | 
65
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
1013
 | 
 		if $self->{type_constraint};  | 
| 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
27
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
28
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub _maybe_restore_type_constraint {  | 
| 
29
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
3
 | 
 	my $self = shift;  | 
| 
30
 | 
1
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
4
 | 
 	if ( my $union = $self->{_union_of} ) {  | 
| 
31
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
 		return Type::Tiny::Union->new( type_constraints => $union );  | 
| 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	}  | 
| 
33
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
 	return;    # uncoverable statement  | 
| 
34
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
36
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub type_coercion_map {  | 
| 
37
 | 
17
 | 
 
 | 
 
 | 
  
17
  
 | 
  
1
  
 | 
30
 | 
 	my $self = shift;  | 
| 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	  | 
| 
39
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
39
 | 
 	Types::TypeTiny::assert_TypeTiny( my $type = $self->type_constraint );  | 
| 
40
 | 
17
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
41
 | 
 	$type->isa( 'Type::Tiny::Union' )  | 
| 
41
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 		or _croak  | 
| 
42
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 		"Type::Coercion::Union must be used in conjunction with Type::Tiny::Union";  | 
| 
43
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 		  | 
| 
44
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
23
 | 
 	my @c;  | 
| 
45
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
41
 | 
 	for my $tc ( @$type ) {  | 
| 
46
 | 
34
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
63
 | 
 		next unless $tc->has_coercion;  | 
| 
47
 | 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
43
 | 
 		push @c, @{ $tc->coercion->type_coercion_map };  | 
| 
 
 | 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
52
 | 
    | 
| 
48
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	}  | 
| 
49
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
67
 | 
 	return \@c;  | 
| 
50
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 } #/ sub type_coercion_map  | 
| 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
52
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub add_type_coercions {  | 
| 
53
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
  
1
  
 | 
13
 | 
 	my $self = shift;  | 
| 
54
 | 
1
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
5
 | 
 	_croak "Adding coercions to Type::Coercion::Union not currently supported"  | 
| 
55
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 		if @_;  | 
| 
56
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
57
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
58
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub _build_moose_coercion {  | 
| 
59
 | 
  
0
  
 | 
 
 | 
 
 | 
  
0
  
 | 
 
 | 
0
 | 
 	my $self = shift;  | 
| 
60
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	  | 
| 
61
 | 
  
0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
 	my %options = ();  | 
| 
62
 | 
  
0
  
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
0
 | 
 	$options{type_constraint} = $self->type_constraint  | 
| 
63
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 		if $self->has_type_constraint;  | 
| 
64
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 		  | 
| 
65
 | 
  
0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
 	require Moose::Meta::TypeCoercion::Union;  | 
| 
66
 | 
  
0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
 	my $r = "Moose::Meta::TypeCoercion::Union"->new( %options );  | 
| 
67
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	  | 
| 
68
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
 	return $r;  | 
| 
69
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 } #/ sub _build_moose_coercion  | 
| 
70
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
71
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub can_be_inlined {  | 
| 
72
 | 
3
 | 
 
 | 
 
 | 
  
3
  
 | 
  
1
  
 | 
5
 | 
 	my $self = shift;  | 
| 
73
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	  | 
| 
74
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
8
 | 
 	Types::TypeTiny::assert_TypeTiny( my $type = $self->type_constraint );  | 
| 
75
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	  | 
| 
76
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
10
 | 
 	for my $tc ( @$type ) {  | 
| 
77
 | 
6
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
15
 | 
 		next       unless $tc->has_coercion;  | 
| 
78
 | 
6
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
15
 | 
 		return !!0 unless $tc->coercion->can_be_inlined;  | 
| 
79
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	}  | 
| 
80
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	  | 
| 
81
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
8
 | 
 	!!1;  | 
| 
82
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 } #/ sub can_be_inlined  | 
| 
83
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
84
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  | 
| 
85
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
86
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __END__  |