Skip to content

Commit

Permalink
Simplify Parameter.perl wrt to post constraints
Browse files Browse the repository at this point in the history
- only need to look at &where if we have post-constraints
- only need to call &where if there is one, otherwise just string (for now)
- remove obvious erroneous "return Nil", shouldn't affect .perl
  • Loading branch information
lizmat committed Mar 9, 2019
1 parent 70d61b2 commit 99ba0ea
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/core/Parameter.pm6
Expand Up @@ -535,7 +535,7 @@ my class Parameter { # declared in BOOTSTRAP
True;
}

multi method perl(Parameter:D: Mu:U :$elide-type = Any, :&where = -> $ { 'where { ... }' }) {
multi method perl(Parameter:D: Mu:U :$elide-type = Any, :&where) {
my $perl = '';
my $rest = '';
my $type = $!nominal_type.^name;
Expand Down Expand Up @@ -610,9 +610,7 @@ my class Parameter { # declared in BOOTSTRAP
$rest ~= ' ' ~ $sig;
}
unless nqp::isnull(@!post_constraints) {
my $where = &where(self);
return Nil without $where;
$rest ~= " $where";
$rest ~= " $_" with &where ?? &where(self) !! 'where { ... }';
}
$rest ~= " = $!default_value.perl()" if $default;
if $name or $rest {
Expand Down

0 comments on commit 99ba0ea

Please sign in to comment.