Skip to content

Instantly share code, notes, and snippets.

@lizmat
Created January 24, 2017 22:10
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 lizmat/1badd87639f599e73fdddfecf6ed1ca5 to your computer and use it in GitHub Desktop.
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
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