use Scalar::Util 'blessed';
use Carp 'confess';
+use Class::Load 'is_class_loaded';
+
use Moose::Deprecated;
use Moose::Exporter;
);
sub init_meta {
- # This used to be called as a function. This hack preserves
- # backwards compatibility.
- if ( $_[0] ne __PACKAGE__ ) {
- Moose::Deprecated::deprecated(
- feature => 'Moose::init_meta',
- message => 'Calling Moose::init_meta as a function is deprecated.'
- . ' Doing so will throw an error in Moose 2.0200.'
- );
-
- return __PACKAGE__->init_meta(
- for_class => $_[0],
- base_class => $_[1],
- metaclass => $_[2],
- );
- }
-
shift;
my %args = @_;
my $metaclass = $args{metaclass} || 'Moose::Meta::Class';
my $meta_name = exists $args{meta_name} ? $args{meta_name} : 'meta';
+ Moose->throw_error("The Metaclass $metaclass must be loaded. (Perhaps you forgot to 'use $metaclass'?)")
+ unless is_class_loaded($metaclass);
+
Moose->throw_error("The Metaclass $metaclass must be a subclass of Moose::Meta::Class.")
unless $metaclass->isa('Moose::Meta::Class');
Moose::Meta::TypeCoercion::Union
Moose::Meta::Method
- Moose::Meta::Method::Accessor
Moose::Meta::Method::Constructor
Moose::Meta::Method::Destructor
Moose::Meta::Method::Overridden
Moose::Meta::Role::Application::ToInstance
);
-Moose::Meta::Mixin::AttributeCore->meta->make_immutable(
+$_->make_immutable(
inline_constructor => 0,
constructor_name => undef,
+ # these are Class::MOP accessors, so they need inlining
+ inline_accessors => 1
+ ) for grep { $_->is_mutable }
+ map { $_->meta }
+ qw(
+ Moose::Meta::Method::Accessor
+ Moose::Meta::Method::Delegation
+ Moose::Meta::Mixin::AttributeCore
);
1;