Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Routines declaring of/returns T are Callable[T].
So you can pass them to something wanting a `T &foo` parameter.
  • Loading branch information
jnthn committed Oct 6, 2015
1 parent fbac827 commit b6c528d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/core/traits.pm
Expand Up @@ -301,7 +301,8 @@ multi sub trait_mod:<of>(Routine:D $target, Mu:U $type) {
X::Redeclaration.new(what => 'return type for', symbol => $target,
postfix => " (previous return type was {$sig.returns.^name})").throw
if $sig.has_returns;
$sig.set_returns($type)
$sig.set_returns($type);
$target.^mixin(Callable.^parameterize($type))
}

multi sub trait_mod:<is>(Routine:D $r, :$hidden-from-backtrace!) {
Expand Down Expand Up @@ -332,7 +333,8 @@ multi sub trait_mod:<returns>(Routine:D $target, Mu:U $type) {
X::Redeclaration.new(what => 'return type for', symbol => $target,
postfix => " (previous return type was {$sig.returns.^name})").throw
if $sig.has_returns;
$sig.set_returns($type)
$sig.set_returns($type);
$target.^mixin(Callable.^parameterize($type))
}

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

0 comments on commit b6c528d

Please sign in to comment.