Skip to content
Permalink
Browse files

Unbreak subclassing of Parameter

With this, the regression reported in  #2829 that broke
`Cro::OpenAPI::RoutesFromDefinition` is now resolved.

It's covered for now by a Rakudo test, though arguably we should
consider the ability to do this spec and add spectest coverage also.
  • Loading branch information...
jnthn committed Apr 18, 2019
1 parent e352962 commit d31fb27064f078b8cf2f962b9ebc154f650af4b8
Showing with 17 additions and 29 deletions.
  1. +11 −28 src/core/Parameter.pm6
  2. +6 −1 t/02-rakudo/99-misc.t
@@ -88,34 +88,17 @@ my class Parameter { # declared in BOOTSTRAP
}
}

multi method new(Parameter:U:
Str:D :$name = "",
Int:D :$flags = 0,
Bool:D :$named = False,
Bool:D :$optional = False,
Bool:D :$mandatory = False,
Bool:D :$is-copy = False,
Bool:D :$is-raw = False,
Bool:D :$is-rw = False,
Bool:D :$multi-invocant = True,
) {
nqp::create(self)!SET-SELF(
$name, $flags, $named, $optional, $mandatory,
$is-copy, $is-raw, $is-rw, $multi-invocant, %_
)
}

method !SET-SELF(
Str:D $name is copy,
Int:D $flags is copy,
Bool:D $named is copy,
Bool:D $optional is copy,
Bool:D $mandatory is copy,
Bool:D $is-copy,
Bool:D $is-raw,
Bool:D $is-rw,
Bool:D $multi-invocant,
%args # type / default / where / sub_signature captured through %_
submethod BUILD(
Str:D $name is copy = "",
Int:D $flags is copy = 0,
Bool:D $named is copy = False,
Bool:D $optional is copy = False,
Bool:D $mandatory is copy = False,
Bool:D $is-copy = False,
Bool:D $is-raw = False,
Bool:D $is-rw = False,
Bool:D $multi-invocant = True,
*%args # type / default / where / sub_signature captured through %_
) {

if $name { # specified a name?
@@ -2,7 +2,7 @@ use lib <t/packages/>;
use Test;
use Test::Helpers;

plan 9;
plan 10;

subtest '.lang-ver-before method on Perl6::World' => {
plan 5;
@@ -151,3 +151,8 @@ subtest 'Distribution::Resource can be stringified', {
lives-ok { Distribution::Resource.Str }, 'Can use .Str';
lives-ok { Distribution::Resource.gist }, 'Can use .gist';
}

class ParameterChild is Parameter {
has $.foobar
}
is ParameterChild.new(foobar => 'Baz').foobar, 'Baz', 'Subclassing of Parameter works';

0 comments on commit d31fb27

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