summaryrefslogtreecommitdiff
path: root/lib/Type/Params
diff options
context:
space:
mode:
authorToby Inkster <mail@tobyinkster.co.uk>2022-09-12 09:52:38 +0100
committerToby Inkster <mail@tobyinkster.co.uk>2022-09-12 09:52:38 +0100
commitdcf3d28c77617824e6578d97809534b44270deca (patch)
tree7de28c3a1ea9237d77e390a566d01c6bf0429346 /lib/Type/Params
parent3e3825afa876a5e975cfb0555cdd0b76bc79b818 (diff)
Get signature_for working with the multi option; was easier than expected
Diffstat (limited to 'lib/Type/Params')
-rw-r--r--lib/Type/Params/Alternatives.pm7
-rw-r--r--lib/Type/Params/Signature.pm9
2 files changed, 8 insertions, 8 deletions
diff --git a/lib/Type/Params/Alternatives.pm b/lib/Type/Params/Alternatives.pm
index cb214abd..6372748d 100644
--- a/lib/Type/Params/Alternatives.pm
+++ b/lib/Type/Params/Alternatives.pm
@@ -39,6 +39,7 @@ sub alternatives { $_[0]{alternatives} ||= [] }
sub sig_class { $_[0]{sig_class} }
sub meta_alternatives { $_[0]{meta_alternatives} ||= $_[0]->_build_meta_alternatives }
sub parameters { [] }
+sub goto_next { $_[0]{base_options}{goto_next} }
sub _build_meta_alternatives {
my $self = shift;
@@ -57,13 +58,12 @@ sub _build_meta_alternative {
my ( $self, $alt ) = @_;
if ( is_CodeRef $alt ) {
- return {
- closure => $alt,
- };
+ return { closure => $alt };
}
elsif ( is_HashRef $alt ) {
my %opts = (
%{ $self->base_options },
+ goto_next => !!0, # don't propagate
%$alt,
want_source => !!0,
want_object => !!0,
@@ -75,6 +75,7 @@ sub _build_meta_alternative {
elsif ( is_ArrayRef $alt ) {
my %opts = (
%{ $self->base_options },
+ goto_next => !!0, # don't propagate
positional => $alt,
want_source => !!0,
want_object => !!0,
diff --git a/lib/Type/Params/Signature.pm b/lib/Type/Params/Signature.pm
index c5503e7b..c841876f 100644
--- a/lib/Type/Params/Signature.pm
+++ b/lib/Type/Params/Signature.pm
@@ -755,8 +755,9 @@ sub _make_return_list {
sub _make_return_expression {
my ( $self, %args ) = @_;
+ my $list = join q{, }, $self->_make_return_list;
+
if ( $self->goto_next ) {
- my $list = join( q{, }, $self->_make_return_list );
if ( $list eq '@_' ) {
return sprintf 'goto( $__NEXT__ )';
}
@@ -766,12 +767,10 @@ sub _make_return_expression {
}
}
elsif ( $args{is_early} or not exists $args{is_early} ) {
- return sprintf 'return( %s )',
- join( q{, }, $self->_make_return_list );
+ return sprintf 'return( %s )', $list;
}
else {
- return sprintf '( %s )',
- join( q{, }, $self->_make_return_list );
+ return sprintf '( %s )', $list;
}
}