Skip to content

Commit 8feb3e7

Browse files
committed
Simplify .infer logic, vrurg++
Now with .^mro(:roles), we don't need to handle them separately.
1 parent 513ad89 commit 8feb3e7

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

src/core.c/Any-iterable-methods.pm6

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2381,8 +2381,8 @@ Consider using a block if any of these are necessary for your mapping code."
23812381

23822382
method !slow-infer($iterator, Mu $type is copy, Mu $pulled is copy) {
23832383
# set up types to check
2384-
my $mro := nqp::clone(nqp::getattr($type.^mro,List,'$!reified'));
2385-
my $roles := nqp::clone(nqp::getattr($type.^roles,List,'$!reified'));
2384+
my $mro :=
2385+
nqp::clone(nqp::getattr($type.^mro(:roles),List,'$!reified'));
23862386

23872387
nqp::repeat_until(
23882388
nqp::eqaddr(($pulled := $iterator.pull-one),IterationEnd)
@@ -2392,21 +2392,6 @@ Consider using a block if any of these are necessary for your mapping code."
23922392
nqp::stmts( # not the same base type
23932393
nqp::shift($mro),
23942394
($type := nqp::atpos($mro,0)), # assume next type for now
2395-
nqp::if( # check all roles, if any left
2396-
nqp::elems($roles),
2397-
nqp::stmts(
2398-
(my $new-roles := nqp::list),
2399-
nqp::while(
2400-
nqp::elems($roles),
2401-
nqp::if(
2402-
nqp::istype((my $role := nqp::pop($roles)),$type)
2403-
&& nqp::istype($pulled,$role),
2404-
($type := nqp::unshift($new-roles,$role))
2405-
)
2406-
),
2407-
($roles := $new-roles)
2408-
)
2409-
)
24102395
)
24112396
)
24122397
);

0 commit comments

Comments
 (0)