On Wed, Jul 04, 2012 at 11:16:02AM -0500, Christopher J. Madsen wrote: > After MooseX-Types 0.35 was released, I started getting failure reports > for a number of my modules that use it. This turned out to be caused by > this issue: > > use Moose::Util::TypeConstraints; > # { package Foo::Role; use Moose::Role; } > my $type = role_type('Foo::Role'); > $type->is_subtype_of('Bar'); > > This dies: Can't call method "does_role" on an undefined value at > Moose/Meta/TypeConstraint/Role.pm line 101. > > Uncommenting the definition of Foo::Role will remove the error. But > it's often necessary to define types (and subtypes) involving roles > before the role itself is defined. For instance, in a tree structure, a > role might declare attributes using such types. > > It would be possible to work around this in MooseX-Types, but it seems > more straightforward to fix the root issue in > Moose::Meta::TypeConstraint::Role, and that's what I did. > > Please review branch rfc/undef-role. It adds a test to demonstrate the > problem and then fixes it by checking the return value of > Class::MOP::class_of($self->role) before calling methods on it. > > I've run "MOOSE_TEST_MD=MooseX prove -b t/author-test-my-dependents.t" > on it, and don't get any additional failures (over the ones that happen > on master). > > Related RT tickets: > https://rt.cpan.org/Ticket/Display.html?id=77299 > https://rt.cpan.org/Ticket/Display.html?id=77303 > > Thanks.
Merged, thanks. -doy