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

Cannot use multi methods in Roles #4423

Closed
p6rt opened this issue Jul 21, 2015 · 5 comments
Closed

Cannot use multi methods in Roles #4423

p6rt opened this issue Jul 21, 2015 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jul 21, 2015

Migrated from rt.perl.org#125658 (status was 'rejected')

Searchable as RT125658$

@p6rt
Copy link
Author

p6rt commented Jul 21, 2015

From adriaan.larmuseau@gmail.com

Bug report #​124393 states that one cannot use stub multi methods in roles,
but multi methods do not work with roles in general.
Consider the following example​:

role A {
  multi method a(Int , Int --> Mu​:D) { False };
  multi method a(Bool​:D $handle, Int $int --> Mu​:D) { False };
}

class Test does A {
  multi method a(Int $stream, Int $int) { True }
  multi method a(Bool​:D $handle, Int $int) { True }
}

# test
my $test = Test.new();
my Bool $b = True;
$test.a($b,5);

Produces the following output​:

Ambiguous call to 'a'; these signatures all match​:
:(Test $​: Bool​:D $handle, Int $int, *%_)
:(Test $​: Bool​:D $handle, Int $int, *%_)
  in block <unit> at test.pl​:17

For perl6 --version​:
This is perl6 version 2015.06-293-g27f88c4 built on MoarVM version
2015.06-98-gf22142b

@p6rt
Copy link
Author

p6rt commented Jul 21, 2015

From @FROGGS

I think it works as designed.

What you seem to want is what class inheritence does.
Roles on the other hand mix their methods into the applied class.
So the class consumes these methods as if they were defined within that class.

@p6rt
Copy link
Author

p6rt commented Jul 21, 2015

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

@p6rt
Copy link
Author

p6rt commented Jul 22, 2015

From @moritz

I agree with Tobias Leich's reasoning. Rejecting ticket.

@p6rt
Copy link
Author

p6rt commented Jul 22, 2015

@moritz - Status changed from 'open' to 'rejected'

@p6rt p6rt closed this as completed Jul 22, 2015
@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
Development

No branches or pull requests

1 participant