diff options
author | Toby Inkster <mail@tobyinkster.co.uk> | 2022-09-11 20:01:05 +0100 |
---|---|---|
committer | Toby Inkster <mail@tobyinkster.co.uk> | 2022-09-11 20:01:05 +0100 |
commit | fb7dfa2991494d58c8920788acd62c123c18d245 (patch) | |
tree | a46380f5434a6f3c205ea9118e257a781f769438 /lib/Type/Params | |
parent | 8d76cdd3c129c44596b66edb11e4577f5fc73bc9 (diff) |
Make sure multisig provides make_class_pp_code. Mite might be able to use it. (Though Mite probably copes badly with multisig.)
Diffstat (limited to 'lib/Type/Params')
-rw-r--r-- | lib/Type/Params/Alternatives.pm | 14 | ||||
-rw-r--r-- | lib/Type/Params/Signature.pm | 9 |
2 files changed, 22 insertions, 1 deletions
diff --git a/lib/Type/Params/Alternatives.pm b/lib/Type/Params/Alternatives.pm index 43552645..cb749a2b 100644 --- a/lib/Type/Params/Alternatives.pm +++ b/lib/Type/Params/Alternatives.pm @@ -66,6 +66,7 @@ sub _build_meta_alternative { %{ $self->base_options }, %$alt, want_source => !!0, + want_object => !!0, want_details => !!1, ); my $sig = $self->sig_class->new_from_v2api( \%opts ); @@ -76,6 +77,7 @@ sub _build_meta_alternative { %{ $self->base_options }, positional => $alt, want_source => !!0, + want_object => !!0, want_details => !!1, ); my $sig = $self->sig_class->new_from_v2api( \%opts ); @@ -155,5 +157,17 @@ sub _make_return_list { '@$return'; } +sub make_class_pp_code { + my $self = shift; + + return join( + qq{\n}, + grep { length $_ } + map { $_->{object}->make_class_pp_code } + grep { ref $_->{object} } + @{ $self->meta_alternatives } + ); +} + 1; diff --git a/lib/Type/Params/Signature.pm b/lib/Type/Params/Signature.pm index e4e7869a..67b9e0c6 100644 --- a/lib/Type/Params/Signature.pm +++ b/lib/Type/Params/Signature.pm @@ -68,7 +68,7 @@ sub new { ); } - if ( defined $self->{bless} and $self->{bless} eq 1 ) { + if ( defined $self->{bless} and $self->{bless} eq 1 and not $self->{named_to_list} ) { my $klass_key = $self->_klass_key; $self->{bless} = ( $klass_cache{$klass_key} ||= sprintf( '%s%d', $self->{class_prefix}, ++$klass_id ) ); $self->{oo_trace} = 1 unless exists $self->{oo_trace}; @@ -905,6 +905,9 @@ sub make_class_pp { sub make_class_pp_code { my $self = shift; + return '' + unless $self->is_named && $self->bless && !$self->named_to_list; + my $coderef = $self->_new_code_accumulator; my $attr = $self->class_attributes; @@ -946,6 +949,9 @@ sub return_wanted { if ( $self->{want_source} ) { return $coderef->code; } + elsif ( $self->{want_object} ) { # undocumented for now + return $self; + } elsif ( $self->{want_details} ) { return { min_args => $self->{min_args}, @@ -954,6 +960,7 @@ sub return_wanted { source => $coderef->code, closure => $coderef->compile, named => $self->is_named, + object => $self, }; } |