Created
January 24, 2017 22:10
-
-
Save lizmat/1badd87639f599e73fdddfecf6ed1ca5 to your computer and use it in GitHub Desktop.
Attempt at fixing role A { method m {} }; role B does A {}; class C does A does B {} : apparently just checking for =:= is not enough
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
diff --git a/src/Perl6/Metamodel/RoleToRoleApplier.nqp b/src/Perl6/Metamodel/RoleToRoleApplier.nqp | |
index b115bc5..4f34cff 100644 | |
--- a/src/Perl6/Metamodel/RoleToRoleApplier.nqp | |
+++ b/src/Perl6/Metamodel/RoleToRoleApplier.nqp | |
@@ -86,7 +86,18 @@ my class RoleToRoleApplier { | |
$target.HOW.add_method($target, $name, @add_meths[0]); | |
} | |
else { | |
- $target.HOW.add_collision($target, $name, %meth_providers{$name}); | |
+ my $first := @impl_meths[0]; | |
+ my int $i := 0; | |
+ while ($i := $i + 1) < +@impl_meths { | |
+ last unless @impl_meths[$i] =:= $first; | |
+ } | |
+ # possible collisions are all the same | |
+ if $i == +@impl_meths { | |
+ $target.HOW.add_method($target, $name, $first); | |
+ } | |
+ else { | |
+ $target.HOW.add_collision($target, $name, %meth_providers{$name}); | |
+ } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment