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

Private methods aren't carried along in role summation when two roles are being composed into one class in Rakudo #2666

Closed
p6rt opened this issue Mar 10, 2012 · 5 comments

Comments

@p6rt
Copy link

p6rt commented Mar 10, 2012

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

Searchable as RT111664$

@p6rt
Copy link
Author

p6rt commented Mar 10, 2012

From @masak

<felher> nom​: role R { my method !foo() { say 42 } }; class C does R {
method bar() { self!foo() } }; C.bar
<p6eval> rakudo a8086d​: OUTPUT«42␤»
<masak> nom​: role R1 { method !foo { say "R1" } }; role R2 { method
!foo { say "R2" } }; class C does R1 does R2 { method bar { self!foo()
} }; say C.new.bar
<p6eval> rakudo a8086d​: OUTPUT«Private method 'foo' not found on type
C␤ in method dispatch​:<!> at src/gen/CORE.setting​:777␤ in method bar
at /tmp/diNxcNUBGu​:1␤ in block <anon> at /tmp/diNxcNUBGu​:1␤␤»
<masak> huh!
<masak> nom​: role R1 { method !foo { "R1" } }; class C does R1 {
method bar { self!foo() } }; say C.new.bar
<p6eval> rakudo a8086d​: OUTPUT«R1␤»
<masak> so... if private methods in a role collide... none of them
gets installed?
<jnthn> masak​: Yeah, I've found the issue
<jnthn> masak​: RoleToRoleApplier doesn't copy private methods
<masak> oh.
<masak> then why did felher's oneliner work?
<jnthn> masak​: Because RoleToRoleApplier never gets used there
<jnthn> masak​: Because only one role is being applied
<masak> aaaaaaah.
<jnthn> So we don't need to compute the summation.
* masak submits rakudobug
<jnthn> masak​: OK. Testing a patch locally for it.

@p6rt
Copy link
Author

p6rt commented Mar 10, 2012

From @jnthn

On Sat Mar 10 06​:24​:21 2012, masak wrote​:

<felher> nom​: role R { my method !foo() { say 42 } }; class C does R {
method bar() { self!foo() } }; C.bar
<p6eval> rakudo a8086d​: OUTPUT«42␤»
<masak> nom​: role R1 { method !foo { say "R1" } }; role R2 { method
!foo { say "R2" } }; class C does R1 does R2 { method bar { self!foo()
} }; say C.new.bar
<p6eval> rakudo a8086d​: OUTPUT«Private method 'foo' not found on type
C␤ in method dispatch​:<!> at src/gen/CORE.setting​:777␤ in method bar
at /tmp/diNxcNUBGu​:1␤ in block <anon> at /tmp/diNxcNUBGu​:1␤␤»
<masak> huh!
<masak> nom​: role R1 { method !foo { "R1" } }; class C does R1 {
method bar { self!foo() } }; say C.new.bar
<p6eval> rakudo a8086d​: OUTPUT«R1␤»
<masak> so... if private methods in a role collide... none of them
gets installed?
<jnthn> masak​: Yeah, I've found the issue
<jnthn> masak​: RoleToRoleApplier doesn't copy private methods
<masak> oh.
<masak> then why did felher's oneliner work?
<jnthn> masak​: Because RoleToRoleApplier never gets used there
<jnthn> masak​: Because only one role is being applied
<masak> aaaaaaah.
<jnthn> So we don't need to compute the summation.
* masak submits rakudobug
<jnthn> masak​: OK. Testing a patch locally for it.

Now, the case here correctly complains about a conflict. Tagging test
needed.

/jnthn

@p6rt
Copy link
Author

p6rt commented Mar 10, 2012

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

@p6rt
Copy link
Author

p6rt commented Jun 28, 2012

From @moritz

Now tested in S14-roles/conflicts.t

@p6rt
Copy link
Author

p6rt commented Jun 28, 2012

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant