Skip to content

Commit

Permalink
Make .HOW on a role give back the metaclass, rather than pun the role…
Browse files Browse the repository at this point in the history
… and give back the metaclass of the punned class. Correcting this also required fixing something that relied on the old broken behavior.
  • Loading branch information
jnthn committed Aug 17, 2009
1 parent b60cef0 commit 17c4b9d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/builtins/guts.pir
Expand Up @@ -264,15 +264,18 @@ to find a real, non-subtype and stash that away for fast access later.
real_type = refinee
got_real_type:

# If it's an un-disambiguated role, dis-ambiguate.
$I0 = isa real_type, 'Perl6Role'
# Create subclass. If it's a role, pun it.
.local pmc parrot_class, type_obj, subset
type_obj = refinee
$I0 = isa type_obj, 'Perl6Role'
unless $I0 goto ambig_role_done
type_obj = type_obj.'!select'()
ambig_role_done:
$I0 = isa type_obj, 'P6role'
unless $I0 goto role_done
real_type = real_type.'!select'()
type_obj = type_obj.'!pun'()
role_done:

# Create subclass.
.local pmc parrot_class, subset
parrot_class = p6meta.'get_parrotclass'(refinee)
parrot_class = p6meta.'get_parrotclass'(type_obj)
subset = subclass parrot_class

# Override accepts.
Expand All @@ -291,6 +294,10 @@ to find a real, non-subtype and stash that away for fast access later.
subset = p6meta.'register'(subset)

# Mark it a subtype and stash away real type, refinee and refinement.
$I0 = isa real_type, 'Perl6Role'
unless $I0 goto real_type_done
real_type = real_type.'!select'()
real_type_done:
setprop subset, 'subtype_realtype', real_type
setprop subset, 'subtype_refinement', refinement
setprop subset, 'subtype_refinee', refinee
Expand Down
2 changes: 2 additions & 0 deletions src/pmc/p6role.pmc
Expand Up @@ -39,6 +39,8 @@ pmclass P6role extends Role need_ext dynpmc group perl6_group {
return SUPER(name);
if (Parrot_str_equal(interp, name, CONST_STRING(interp, "Scalar")))
return SUPER(name);
if (Parrot_str_equal(interp, name, CONST_STRING(interp, "HOW")))
return SUPER(name);
first_char = Parrot_str_substr(interp, name, 0, 1, NULL, 0);
if (Parrot_str_equal(interp, first_char, CONST_STRING(interp, "!")))
return SUPER(name);
Expand Down

0 comments on commit 17c4b9d

Please sign in to comment.