Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work around weirdness with MX::MarkAsMethods and overloading roles
Marking overload subs like ("" as methods caused them to be copied from the class to the role. This made the class _look_ like it implemented overloading for the op, but overloading wasn't actually enabled, causing weird errors.
- Loading branch information
Showing
4 changed files
with
54 additions
and
1 deletion.
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,38 @@ | ||
use strict; | ||
use warnings; | ||
|
||
use Moose (); | ||
# Needed to load MarkAsMethods if we're running from a git checkout | ||
BEGIN { $Moose::VERSION ||= 42 } | ||
|
||
use Test::More; | ||
use Test::Exception; | ||
use Test::Requires { | ||
'MooseX::MarkAsMethods' => 0, | ||
}; | ||
|
||
{ | ||
package Role2; | ||
use Moose::Role; | ||
use MooseX::MarkAsMethods; | ||
use overload q{""} => '_stringify'; | ||
sub _stringify {ref $_[0]} | ||
} | ||
|
||
{ | ||
package Class2; | ||
use Moose; | ||
with 'Role2'; | ||
} | ||
|
||
lives_ok { | ||
my $class2 = Class2->new; | ||
is( | ||
"$class2", | ||
'Class2', | ||
'Class2 got stringification overloading from Role2' | ||
); | ||
} | ||
'No error creating a Class2 object'; | ||
|
||
done_testing; |