Last active
August 29, 2015 14:01
-
-
Save moritz/2c6ed01eef0029dabdeb 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:$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 | |
} | |
} |
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
===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