Skip to content
Permalink
Browse files

Add Parameter.coerce_type

So we can introspect the type we should coerce to.  Also adapt
Parameter.perl to take the coerce_type into account.

Fixes R#2416
  • Loading branch information...
lizmat committed Oct 23, 2018
1 parent 64b3dbd commit 0243275defec300098202e25bea7412f041ccacb
Showing with 3 additions and 0 deletions.
  1. +3 −0 src/core/Parameter.pm6
@@ -108,6 +108,7 @@ my class Parameter { # declared in BOOTSTRAP
}

method type() { $!nominal_type }
method coerce_type() { $!coerce_type }
method named_names() {
nqp::if(
@!named_names && (my int $elems = nqp::elems(@!named_names)),
@@ -332,6 +333,8 @@ my class Parameter { # declared in BOOTSTRAP
my $perl = '';
my $rest = '';
my $type = $!nominal_type.^name;
$type = $!coerce_type.^name ~ "($type)"
unless nqp::isnull($!coerce_type);
my $modifier = self.modifier;

$perl ~= "::$_ " for @($.type_captures);

0 comments on commit 0243275

Please sign in to comment.
You can’t perform that action at this time.