Skip to content

Instantly share code, notes, and snippets.

@moritz
Created May 15, 2014 18:53
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 moritz/f524eb792eadfe38ed5a to your computer and use it in GitHub Desktop.
Save moritz/f524eb792eadfe38ed5a 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 $interface, :$declared-in!) {
my $name = $m.name;
unless $interface.^can($name) {
die "Method $name clames to be declared in {$interface.^name}, but there's no such method in {$interface.^name}!\n";
}
}
role R {
method m1() { ... };
}
class C {
method m1() is declared-in(R) {
# all fine here
}
method m2() is declared-in(R) {
# should bomb
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment