Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fix Perl5 classes unable to override Mu's methods
Even Mu's methods trump fallbacks, so we have to explicitly pass them through to the marshalled Perl 5 object or package, same as we do with Any's methods. As Mu's methods are integral to Perl 6's workings, we cannot just wrapp all of them. Instead, only pass through <note print put say split> as those should be safe.
- Loading branch information
Showing
5 changed files
with
84 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package Shadow; | ||
|
|
||
| sub new { | ||
| return bless {}; | ||
| } | ||
|
|
||
| sub list { | ||
| return 'list'; | ||
| } | ||
|
|
||
| sub end { | ||
| return 'end'; | ||
| } | ||
|
|
||
| sub say { | ||
| return 'say'; | ||
| } | ||
|
|
||
| sub print { | ||
| return 'print'; | ||
| } | ||
|
|
||
| sub note { | ||
| return 'note'; | ||
| } | ||
|
|
||
| sub put { | ||
| return 'put'; | ||
| } | ||
|
|
||
| sub split { | ||
| return 'split'; | ||
| } | ||
|
|
||
| 1; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #!/usr/bin/env perl6 | ||
|
|
||
| use v6; | ||
| use Test; | ||
|
|
||
| use lib:from<Perl5> 't/lib'; | ||
| use Shadow:from<Perl5>; | ||
|
|
||
| my constant @methods = <list end say print note put split>; | ||
|
|
||
| plan @methods.elems * 2; | ||
|
|
||
| for @methods -> $name { | ||
| is(Shadow."$name"(), $name); | ||
| } | ||
|
|
||
| my $shadow = Shadow.new; | ||
| for @methods -> $name { | ||
| is($shadow."$name"(), $name); | ||
| } | ||
|
|
||
| # vim: ft=perl6 |