+
+
+ - Die if Moo and Moo::Role are imported into the same package
+
1.000006 - 2012-11-16
- Don't use $_ as loop variable when calling arbitrary code (RT#81072)
- Bump Role::Tiny prereq to fix method modifier breakage on 5.10.0
my $target = caller;
my $class = shift;
strictures->import;
+ if ($Moo::Role::INFO{$target} and $Moo::Role::INFO{$target}{is_role}) {
+ die "Cannot import Moo into a role";
+ }
return if $MAKERS{$target}; # already exported into this package
- $MAKERS{$target} = {};
+ $MAKERS{$target} = { is_class => 1 };
_install_tracked $target => extends => sub {
$class->_set_superclasses($target, @_);
$class->_maybe_reset_handlemoose($target);
my $target = caller;
my ($me) = @_;
strictures->import;
+ if ($Moo::MAKERS{$target} and $Moo::MAKERS{$target}{is_class}) {
+ die "Cannot import Moo::Role into a Moo class";
+ }
return if $INFO{$target}; # already exported into this package
- $INFO{$target} = {};
+ $INFO{$target} = { is_role => 1 };
# get symbol table reference
my $stash = do { no strict 'refs'; \%{"${target}::"} };
_install_tracked $target => has => sub {
--- /dev/null
+use strictures 1;
+use Test::More;
+
+# Compile-time exceptions, so need stringy eval; hence not Test::Fatal.
+{
+ local $@;
+ ok not eval q { package XXX; use Moo; use Moo::Role; 1; };
+ like $@, qr{Cannot import Moo::Role into a Moo class};
+}
+
+{
+ local $@;
+ ok not eval q { package YYY; use Moo::Role; use Moo; 1; };
+ like $@, qr{Cannot import Moo into a role};
+}
+
+done_testing;