Created
May 15, 2014 18:53
-
-
Save moritz/f524eb792eadfe38ed5a to your computer and use it in GitHub Desktop.
Attempt to mimic Java's @OverRide
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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