X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMRO%2FCompat.pm;h=a1022a924c8389bd8b57ff26832f8a9fb82276b1;hb=fd0bf4907d5da3aeb7616c8d7fa524bf0a52499f;hp=c6834ed909c0171cac5fe16bae7d02c93f9bdc03;hpb=075fa6f645389e45028c83b353d76c4a862b528f;p=gitmo%2FMRO-Compat.git diff --git a/lib/MRO/Compat.pm b/lib/MRO/Compat.pm index c6834ed..a1022a9 100644 --- a/lib/MRO/Compat.pm +++ b/lib/MRO/Compat.pm @@ -170,22 +170,25 @@ section for additional details. sub __set_mro { my ($classname, $type) = @_; + if(!defined $classname || !$type) { die q{Usage: mro::set_mro($classname, $type)}; } + if($type eq 'c3') { eval "package $classname; use Class::C3"; die $@ if $@; } - if($type ne 'dfs') { - die q{Invalid mro type "$type"}; + elsif($type eq 'dfs') { + # In the dfs case, check whether we need to undo C3 + if(defined $Class::C3::MRO{$classname}) { + Class::C3::_remove_method_dispatch_table($classname); + } + delete $Class::C3::MRO{$classname}; } - - # In the dfs case, check whether we need to undo C3 - if(defined $Class::C3::MRO{$classname}) { - Class::C3::_remove_method_dispatch_table($classname); + else { + die qq{Invalid mro type "$type"}; } - delete $Class::C3::MRO{$classname}; return; }