Skip to content

Commit

Permalink
Include post constraint in Parameter.ACCEPTS
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Mar 7, 2016
1 parent 2f78f05 commit bb0eab2
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/core/Parameter.pm
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,30 @@ my class Parameter { # declared in BOOTSTRAP
return False;
}

# we have a post constraint
if nqp::islist($!post_constraints) {

# callable means runtime check, so no match
return False
if nqp::istype(nqp::atpos($!post_constraints,0),Callable);

# other doesn't have a post constraint
my Mu $opc := nqp::getattr(o,Parameter,'$!post_constraints');
return False unless nqp::islist($opc);

# other post constraint is a Callable, so runtime check, so no match
return False if nqp::istype(nqp::atpos($opc,0),Callable);

# not same literal value
return False
unless nqp::atpos($!post_constraints,0) eqv nqp::atpos($opc,0);
}

# we don't, other *does* have a post constraint
elsif nqp::islist(nqp::getattr(o,Parameter,'$!post_constraints')) {
return False;
}

# it's a match!
True;
}
Expand Down

0 comments on commit bb0eab2

Please sign in to comment.