Raku / old-issue-tracker

Tickets from RT
https://github.com/Raku/old-issue-tracker/issues
2 stars 1 forks source link

MMD is dispatching too many times. #1286

Closed p6rt closed 15 years ago

p6rt commented 15 years ago

Migrated from rt.perl.org#69192 (status was 'resolved')

Searchable as RT69192$

p6rt commented 15 years ago

From @Timbus

It seems when you add more than one role with the same multimethod name to a class at runtime, any methods of that same name inherited from the first role appear to get called three times if called with the '.*' or '.+' operators. Attached is a simple test case for it.

Expected output​: A A2 B

Actual output​: A A A A2 A2 A2 B

p6rt commented 15 years ago

From @Timbus

Test.p6

p6rt commented 15 years ago

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/S12-methods/multi.t

commit 652203cdd73b00a2296712186ad8888fa07b8fec Author​: kyle \kyle@​c213334d\-75ef\-0310\-aa23\-eaa082d1ae64 Date​: Thu Sep 17 15​:34​:17 2009 +0000

  [t/spec] Test for RT 69192  
  git-svn-id​: http://svn.pugscode.org/pugs@​28272 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch ```diff diff --git a/t/spec/S12-methods/multi.t b/t/spec/S12-methods/multi.t index 30c913c..1266708 100644 --- a/t/spec/S12-methods/multi.t +++ b/t/spec/S12-methods/multi.t @@ -2,7 +2,7 @@ use v6; use Test; -plan 16; +plan 19; # L # L @@ -113,4 +113,39 @@ is Bar.new.a("not an Int"), 'Any-method in Foo'; 'call order is correct for class, role, parent' } +# RT 69192 +{ + role R5 { + multi method rt69192() { push @.order, 'empty' } + multi method rt69192(Str $a) { push @.order, 'Str' } + } + role R6 { + multi method rt69192(Num $a) { push @.order, 'Num' } + } + class RT69192 { has @.order } + + { + my RT69192 $bot .= new(); + $bot does R5 does R6; + $bot.*rt69192; + #?rakudo todo 'RT #69192' + is $bot.order, , 'multi method called once on empty signature'; + } + + { + my RT69192 $bot .= new(); + $bot does R5 does R6; + $bot.*rt69192('RT #69192'); + #?rakudo todo 'RT #69192' + is $bot.order, , 'multi method called once on Str signature'; + } + + { + my RT69192 $bot .= new(); + $bot does R5 does R6; + $bot.*rt69192( 69192 ); + is $bot.order, , 'multi method called once on Num signature'; + } +} + # vim: ft=perl6 ```
p6rt commented 15 years ago

The RT System itself - Status changed from 'new' to 'open'

p6rt commented 15 years ago

From @kyleha

The sample code now runs as expected, and the tests pass, so I'm calling this resolved.

p6rt commented 15 years ago

@kyleha - Status changed from 'open' to 'resolved'