From: Tomas Doran Date: Sun, 5 Jul 2009 22:51:39 +0000 (+0000) Subject: Fix warning, and only warn if really needed X-Git-Tag: 5.80025~15 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=4ffa3785756fc4df4b834f936f1f3acfcf7116f0 Fix warning, and only warn if really needed --- diff --git a/Changes b/Changes index 0431880..23532c2 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ # This file documents the revision history for Perl extension Catalyst. + Bug fixes: + - Fix replace_constructor warning to actually work if you make your + application class immutable without that option. + 5.80007 2009-06-30 23:54:34 Bug fixes: diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 0226a1c..133c657 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -1109,21 +1109,25 @@ EOF $class->log->_flush() if $class->log->can('_flush'); # Make sure that the application class becomes immutable at this point, - # which ensures that it gets an inlined constructor. This means that it - # works even if the user has added a plugin which contains a new method. - # Note however that we have to do the work on scope end, so that method - # modifiers work correctly in MyApp (as you have to call setup _before_ - # applying modifiers). B::Hooks::EndOfScope::on_scope_end { return if $@; my $meta = Class::MOP::get_metaclass_by_name($class); - if ( $meta->is_immutable && ! { $meta->immutable_options }->{inline_constructor} ) { + if ( + $meta->is_immutable + && ! { $meta->immutable_options }->{replace_constructor} + && ( + $class->isa('Class::Accessor::Fast') + || $class->isa('Class::Accessor') + ) + ) { warn "You made your application class ($class) immutable, " - . "but did not inline the constructor.\n" - . "This will break catalyst, please pass " - . "(replace_constructor => 1) when making your class immutable.\n"; + . "but did not inline the\nconstructor. " + . "This will break catalyst, as your app \@ISA " + . "Class::Accessor(::Fast)?\nPlease pass " + . "(replace_constructor => 1)\nwhen making your class immutable.\n"; } - $meta->make_immutable(replace_constructor => 1) unless $meta->is_immutable; + $meta->make_immutable(replace_constructor => 1) + unless $meta->is_immutable; }; $class->setup_finalize;