Re: [perl #129212] problem mixing in role with multi builds

2016-10-17 Thread mt1957

Hi,

Revisiting the problem using rakudo version 2016.10-31-g6ed3a68 built on 
MoarVM version 2016.10 implementing Perl 6.c.


The issue still exist but tried to rewrite things to get it working


role RR1 {
  submethod BUILD ( Int :$i ) { say $i // 'No i'; }
}

role RR2 {
  submethod BUILD ( Str :$t ) { say $t // 'No t'; }
}

class CC {
  multi submethod BUILD ( Int :$i! ) {
say "Integer $i";
self does RR1;
  }

  multi submethod BUILD ( Str :$t! ) {
say "String $t";
self does RR2;
  }
}

for  {
  when 'i' {
my CC $c .= new(:i(10));
  }

  when 't' {
my CC $c .= new(:t);
  }
}


This version works, but output is

String text1
No t
Integer 10
No i

This means that the BUILD submethods in the roles are called without 
arguments, while the signatures must be the same from the use in the 
class. The required '!' must be removed(no arguments delivered).


The roles, if needed, must be initialized with a later call, e.g. via 
method init(Int $i) to get the values in the role.


Removing the submethods BUILD from the roles will trigger again the 
exception;


Cannot resolve caller BUILD(CC+{RR1}: ); none of these signatures match:
(CC $: Str :$t!, *%_)
(CC $: Int :$i!, *%_)
  in block  at Does.pl6 line 23
  in block  at Does.pl6 line 20


Greetings
Marcel


[perl #129212] problem mixing in role with multi builds

2016-09-06 Thread via RT
# New Ticket Created by  mt1957 
# Please include the string:  [perl #129212]
# in the subject line of all future correspondence about this issue. 
# https://rt.perl.org/Ticket/Display.html?id=129212 >


Hi,

I get the following error using version 2016.08.1-66-g1ff1aae built on 
MoarVM version 2016.08
implementing Perl 6.c.

Cannot resolve caller BUILD(CC+{RR}: ); none of these signatures match:
  (CC $: Str :$t!, *%_)
  (CC $: Int :$i!, *%_)
in block  at Build2.pl6 line 15



The code which generates the error (on the line with '$c does RR');


role RR { }

class CC {

multi submethod BUILD ( Str :$t! ) { }
multi submethod BUILD ( Int :$i! ) { }
}

my CC $c .= new(:t);
$c does RR;


Removing the last line and add a trait 'does' to the class works but is 
not what I want.

Greetings,
Marcel


P.s. I've sent this mail before to rakudobug but I did not see it appear 
in the list. Sorry for duplication if it did appear somewhere else.