From: Jesse Luehrs Date: Mon, 20 Jun 2011 13:19:45 +0000 (-0500) Subject: don't load_class if a metaclass already exists X-Git-Tag: 2.0010~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8c3531f6c745d07e7c6ea969777fc5df8bd82212;p=gitmo%2FMoose.git don't load_class if a metaclass already exists otherwise this breaks things like: package Foo; use MooseX::Thing; ... when MooseX::Thing both applies roles and re-exports Moose::Role stuff, because at the time that MooseX::Thing::init_meta is called, the package is empty (it won't get anything in it until Moose::Role::init_meta is called). --- diff --git a/lib/Moose/Util.pm b/lib/Moose/Util.pm index fb2a409..130a982 100644 --- a/lib/Moose/Util.pm +++ b/lib/Moose/Util.pm @@ -137,7 +137,10 @@ sub _apply_all_roles { return unless @role_metas; - Class::MOP::load_class($applicant) unless blessed($applicant); + Class::MOP::load_class($applicant) + unless blessed($applicant) + || Class::MOP::class_of($applicant); + my $meta = ( blessed $applicant ? $applicant : Moose::Meta::Class->initialize($applicant) ); if ( scalar @role_metas == 1 ) {