Skip to content

Instantly share code, notes, and snippets.

@lumimies
Created October 16, 2012 10:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lumimies/3898515 to your computer and use it in GitHub Desktop.
Save lumimies/3898515 to your computer and use it in GitHub Desktop.
Core dump from rakudo
use v6;
class X::Overload::Missing is Exception {
has $.type;
has $.method;
method message() {
"Method $.method of type $.type doesn't override anything"
}
}
multi trait_mod:<is>(Method:D $m, :$overload!) {
my $pkg := $m.signature.params[0].type;
my $m_name := $m.name;
for $pkg.HOW.parents($pkg) -> $p {
return if $p.HOW.methods($p).grep(*.name == $m_name);
}
X::Overload::Missing.new(:type($pkg), :method($m)).throw;
}
# testing...
class A {
method foo {}
}
class B is A {
method foo is overload {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment