[Catalyst-commits] r10801 - in Catalyst-Runtime/5.80/trunk: . lib

t0m at dev.catalyst.perl.org t0m at dev.catalyst.perl.org
Sun Jul 5 22:51:39 GMT 2009


Author: t0m
Date: 2009-07-05 22:51:39 +0000 (Sun, 05 Jul 2009)
New Revision: 10801

Modified:
   Catalyst-Runtime/5.80/trunk/Changes
   Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
Log:
Fix warning, and only warn if really needed

Modified: Catalyst-Runtime/5.80/trunk/Changes
===================================================================
--- Catalyst-Runtime/5.80/trunk/Changes	2009-07-04 03:28:15 UTC (rev 10800)
+++ Catalyst-Runtime/5.80/trunk/Changes	2009-07-05 22:51:39 UTC (rev 10801)
@@ -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:

Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm	2009-07-04 03:28:15 UTC (rev 10800)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm	2009-07-05 22:51:39 UTC (rev 10801)
@@ -1109,21 +1109,25 @@
     $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;




More information about the Catalyst-commits mailing list