Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MMD is dispatching too many times. #1286

Closed
p6rt opened this issue Sep 17, 2009 · 6 comments
Closed

MMD is dispatching too many times. #1286

p6rt opened this issue Sep 17, 2009 · 6 comments
Labels

Comments

@p6rt
Copy link

@p6rt p6rt commented Sep 17, 2009

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

Searchable as RT69192$

@p6rt
Copy link
Author

@p6rt p6rt commented Sep 17, 2009

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
Copy link
Author

@p6rt p6rt commented Sep 17, 2009

@p6rt
Copy link
Author

@p6rt p6rt commented Sep 17, 2009

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@&#8203;28272 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
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<S12/"Multisubs and Multimethods">
 # L<S12/"Multi dispatch">
@@ -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, <empty>, '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, <Str>, 'multi method called once on Str signature';
+    }
+
+    {
+        my RT69192 $bot .= new();
+        $bot does R5 does R6;
+        $bot.*rt69192( 69192 );
+        is $bot.order, <Num>, 'multi method called once on Num signature';
+    }
+}
+
 # vim: ft=perl6

@p6rt
Copy link
Author

@p6rt p6rt commented Sep 17, 2009

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

@p6rt
Copy link
Author

@p6rt p6rt commented Oct 27, 2009

From @kyleha

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

@p6rt
Copy link
Author

@p6rt p6rt commented Oct 27, 2009

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

@p6rt p6rt closed this Oct 27, 2009
@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant