Permalink
Browse files

Make sure .perl work correctly for typed hashes

  • Loading branch information...
1 parent f45f221 commit 6933c1d36d06b71666cb3b0dfb0b8a0dbe493aff @lizmat lizmat committed Jul 8, 2013
Showing with 10 additions and 0 deletions.
  1. +10 −0 src/core/Hash.pm
View
@@ -189,6 +189,11 @@ my class Hash {
nqp::unbox_s($key.Str),
bindval)
}
+ multi method perl(::?CLASS:D \SELF:) {
+ "Hash[{TValue.perl}].new("
+ ~ self.pairs.map({.perl}).join(', ')
+ ~ ')';
+ }
}
my role TypedHash[::TValue, ::TKey] does Associative[TValue] {
has $!keys;
@@ -262,6 +267,11 @@ my class Hash {
Nil
}
}
+ multi method perl(::?CLASS:D \SELF:) {
+ "Hash[{TValue.perl},{TKey.perl}].new("
+ ~ self.pairs.map({.perl}).join(', ')
+ ~ ')';
+ }
}
method PARAMETERIZE_TYPE(Mu $t, |c) {
c.elems ??

0 comments on commit 6933c1d

Please sign in to comment.