Skip to content

Commit

Permalink
work around X::Parameter::Default::TypeCheck not understanding native…
Browse files Browse the repository at this point in the history
… parameters
  • Loading branch information
timo committed Jul 2, 2015
1 parent d9e3070 commit 9b4463d
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/Perl6/Actions.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -3917,17 +3917,19 @@ Compilation unit '$file' contained the following violations:
sub check_param_default_type($/, $value) {
if nqp::existskey(%*PARAM_INFO, 'nominal_type') {
my $expected := %*PARAM_INFO<nominal_type>;
unless nqp::istype($value, $expected) {
# Ensure both types are composed before complaining,
# or we give spurious errors on stubbed things or
# things we're in the middle of compiling.
my $got_comp := try $value.HOW.is_composed($value);
my $exp_comp := try $expected.HOW.is_composed($expected);
if $got_comp && $exp_comp {
$<default_value>[0].CURSOR.typed_sorry(
'X::Parameter::Default::TypeCheck',
got => $value,
expected => %*PARAM_INFO<nominal_type>);
if nqp::objprimspec($expected) == 0 {
unless nqp::istype($value, $expected) {
# Ensure both types are composed before complaining,
# or we give spurious errors on stubbed things or
# things we're in the middle of compiling.
my $got_comp := try $value.HOW.is_composed($value);
my $exp_comp := try $expected.HOW.is_composed($expected);
if $got_comp && $exp_comp {
$<default_value>[0].CURSOR.typed_sorry(
'X::Parameter::Default::TypeCheck',
got => $value,
expected => %*PARAM_INFO<nominal_type>);
}
}
}
}
Expand Down

0 comments on commit 9b4463d

Please sign in to comment.