@@ -53,8 +53,18 @@ sub import {
5353 # determine the wrapper, -into is supported for compatibility reasons
5454 my $wrapper = $options -> { -wrapper } || ' MooseX::Types' ;
5555
56- $args [0]-> {into } = $options -> { -into }
57- if exists $options -> { -into };
56+ # It's a little gross to calculate the calling package here when
57+ # Sub::Exporter is going to do it again, but we need to give Sub::Defer a
58+ # fully qualified name if we give it a name at all, and we want to give it
59+ # a name. Otherwise it guesses at the name and will use its caller, which
60+ # in this case ends up being MooseX::Types, which is wrong.
61+ my $into ;
62+ if (exists $options -> { -into }) {
63+ $into = $args [0]-> {into } = $options -> { -into }
64+ }
65+ else {
66+ $into = caller (($options -> {into_level } || 0) + 1)
67+ }
5868
5969 my %ex_util ;
6070
@@ -79,7 +89,7 @@ sub import {
7989 my $check_name = " is_${type_short} " ;
8090 push @{ $ex_spec {exports } },
8191 $check_name ,
82- sub { $wrapper -> check_export_generator($type_short , $type_full , $undef_msg ) };
92+ sub { $wrapper -> check_export_generator(" ${into} :: $check_name " , $type_short , $type_full , $undef_msg ) };
8393
8494 # only export coercion helper if full (for libraries) or coercion is defined
8595 next TYPE
@@ -89,7 +99,7 @@ sub import {
8999 my $coercion_name = " to_${type_short} " ;
90100 push @{ $ex_spec {exports } },
91101 $coercion_name ,
92- sub { $wrapper -> coercion_export_generator($type_short , $type_full , $undef_msg ) };
102+ sub { $wrapper -> coercion_export_generator(" ${into} :: $coercion_name " , $type_short , $type_full , $undef_msg ) };
93103 $ex_util { $type_short }{to }++; # shortcut to remember this exists
94104 }
95105
0 commit comments