From: Brandon L Black Date: Sat, 14 Apr 2007 13:04:35 +0000 (+0000) Subject: Fix for overloading to method name string, from Ittetsu Miyazaki X-Git-Tag: 0.16~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=030b48e2742e3db51f6c2a40edf4077dd2d8285f;p=gitmo%2FClass-C3.git Fix for overloading to method name string, from Ittetsu Miyazaki --- diff --git a/ChangeLog b/ChangeLog index ecf8e1d..547dc58 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ Revision history for Perl extension Class::C3. + - Fix for overloading to method name string, + from Ittetsu Miyazaki. + 0.14 Tues, Sep 19, 2006 - Fix for rt.cpan.org #21558 - converted to Module::Build diff --git a/lib/Class/C3.pm b/lib/Class/C3.pm index a9158ed..cb775b6 100644 --- a/lib/Class/C3.pm +++ b/lib/Class/C3.pm @@ -120,6 +120,10 @@ sub _apply_method_dispatch_table { ${"${class}::()"} = $MRO{$class}->{has_overload_fallback} if $MRO{$class}->{has_overload_fallback}; foreach my $method (keys %{$MRO{$class}->{methods}}) { + if ( $method =~ /^\(/ ) { + my $orig = $MRO{$class}->{methods}->{$method}->{orig}; + ${"${class}::$method"} = $$orig if defined $$orig; + } *{"${class}::$method"} = $MRO{$class}->{methods}->{$method}->{code}; } } diff --git a/t/21_C3_with_overload.t b/t/21_C3_with_overload.t index d6bd9b4..80b45a8 100644 --- a/t/21_C3_with_overload.t +++ b/t/21_C3_with_overload.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 8; +use Test::More tests => 9; BEGIN { use_ok('Class::C3'); @@ -30,6 +30,20 @@ BEGIN { use warnings; use base 'OverloadingTest'; use Class::C3; + + package BaseTwo; + use overload ( + q{fallback} => 1, + q{""} => 'str', ### character + ); + sub str { + return 'BaseTwo str'; + } + + package OverloadInheritTwo; + use Class::C3; + use base qw/BaseTwo/; + } Class::C3::initialize(); @@ -52,5 +66,10 @@ eval { ok(!$@, '... this should not throw an exception'); ok($result, '... and we should get the true value'); +eval { + my $obj = bless {}, 'OverloadInheritTwo'; +}; +is($@, '', "Overloading to method name string"); + #use Data::Dumper; #diag Dumper { Class::C3::_dump_MRO_table }