Skip to content

Instantly share code, notes, and snippets.

@moritz
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save moritz/2c6ed01eef0029dabdeb to your computer and use it in GitHub Desktop.
Save moritz/2c6ed01eef0029dabdeb to your computer and use it in GitHub Desktop.
Attempt to mimic Java's @OverRide
use v6;
multi trait_mod:<is>(Routine:D $m, Mu:$declared-in!) {
my $name = $m.name;
unless $declared-in.^can($name) {
die "Method $name claims to be declared in {$declared-in.^name}, but there's no such method in {$declared-in.^name}!\n";
}
}
role R {
method m1() { 42 };
}
class C {
method m1() is declared-in(R) {
# all fine here
}
method m2() is declared-in(R) {
# should bomb
}
}
===SORRY!=== Error while compiling meta.pl
Method m2 claims to be declared in R, but there's no such method in R!
at meta.pl:18
------>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment