Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Get of and returns trait to set return type for routines (not checked…
… yet).
  • Loading branch information
jnthn committed Jul 9, 2011
1 parent c23e04f commit 6b6bc4e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/Perl6/Metamodel/BOOTSTRAP.pm
Expand Up @@ -224,7 +224,11 @@ Signature.HOW.add_method(Signature, 'instantiate_generic', sub ($self, $type_env
}
pir::setattribute__0PPsP($ins, Signature, '$!params', @ins_params)
});

Signature.HOW.add_method(Signature, 'set_returns', sub ($self, $type) {
nqp::bindattr(pir::perl6_decontainerize__PP($self),
Signature, '$!returns', pir::perl6_decontainerize__PP($type));
});

# class Parameter {
# has str $!variable_name
# has $!named_names
Expand Down
5 changes: 4 additions & 1 deletion src/core/traits.pm
Expand Up @@ -54,10 +54,13 @@ multi trait_mod:<of>(Mu:U $target, Mu:U $type) {
# XXX Ensure we can do this, die if not.
$target.HOW.set_of($target, $type);
}
multi trait_mod:<of>(Routine:D $target, Mu:U $type) {
$target.signature.set_returns($type)
}

proto trait_mod:<returns>(|$) { * }
multi trait_mod:<returns>(Routine:D $target, Mu:U $type) {
# XXX TODO
$target.signature.set_returns($type)
}

proto trait_mod:<as>(|$) { * }
Expand Down

0 comments on commit 6b6bc4e

Please sign in to comment.