-
-
Save teodozjan/b7183c81c966cfeee3bd to your computer and use it in GitHub Desktop.
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 sub trait_mod:<is>(Method $m, :$must!){ | |
note "trait only if stub is present in base class activated" | |
} | |
multi sub trait_mod:<is>(Method $m, :$override!){ | |
note "trait only if method overrides activated"; | |
} | |
#multi trait_mod:<is>(Any $type, :$OverrideContractedClass!) { | |
# die $type; | |
#} | |
my class OverrideContractedClassHOW is Metamodel::ClassHOW { | |
method new_type(:$name, :$repr, :$ver, :$auth){ | |
die "new type"; | |
} | |
method add_method($obj, $name, $code){ | |
note "add_method"; | |
nextsame; | |
} | |
method add_parent(Mu $obj, Mu $parent){ | |
note "add_parent"; | |
nextsame; | |
} | |
method add_role(Mu $obj, Mu $role ){ | |
note "??DSAd"; | |
} | |
} | |
my module EXPORTHOW {} | |
EXPORTHOW.WHO.<class> = OverrideContractedClassHOW; | |
role Incomplete { | |
method bar {...} | |
method foo {"bar"} | |
} | |
class Complete does Incomplete { | |
method bar is must { 42} | |
method foo is override { "42" } | |
} | |
#say Incomplete.^methods; | |
my Complete $cl = Complete.new; | |
say $cl.bar; | |
say $cl.^roles; | |
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>(Method:D $c, :$must!) { | |
# my $name = $c.name; | |
die $c.invocant; | |
#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 }; | |
method m2() { ... }; | |
} | |
class C does R { | |
method m1() { | |
# all fine here | |
} | |
method m2() is must { | |
# 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
[31m===[0mSORRY![31m===[0m Error while compiling meta.pl | |
Method 'm1' must be implemented by R because it is required by a role | |
at meta.pl:15 | |
------> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment