Skip to content

Commit

Permalink
Fix eqv for parameters typed with parameterizations
Browse files Browse the repository at this point in the history
In particular, curryings defined in different compunits would be
represented by different typeobjects but be the same type in nature. For
example, `Positional[Foo]` is the same positional currying even if
sourced from different modules.

Fixes a bug with 'method implementation required by role'.
  • Loading branch information
vrurg committed Nov 15, 2020
1 parent 42a0d13 commit 0dc9664
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/core.c/Parameter.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -646,10 +646,14 @@ multi sub infix:<eqv>(Parameter:D \a, Parameter:D \b) {
# different nominal or coerce type
my \atype = nqp::getattr(a,Parameter,'$!type');
my \btype = nqp::getattr(b,Parameter,'$!type');
# (atype is btype) && (btype is atype) ensures type equivalence. Works for different curryings of a parametric role
# which are parameterized with the same argument. nqp::eqaddr is not applicable here because if coming from
# different compunits the curryings would be different typeobject instances.
return False
unless
(atype.HOW.archetypes.generic && btype.HOW.archetypes.generic)
|| nqp::eqaddr(atype, btype);
|| (nqp::istype(atype, btype)
&& nqp::istype(btype, atype));

# different flags
return False
Expand Down

0 comments on commit 0dc9664

Please sign in to comment.