From 39086fedab4518c30ff34c92ea390d5ae8c3f964 Mon Sep 17 00:00:00 2001 From: Elizabeth Mattijsen Date: Mon, 8 Oct 2018 21:08:22 +0200 Subject: [PATCH] Hash.of/name/default/dynamic can only be called on instances And since a Hash nowadays *always* has a descriptor, we can remove the check for that. --- src/core/Hash.pm6 | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/core/Hash.pm6 b/src/core/Hash.pm6 index 5154addc392..d94138cc1a4 100644 --- a/src/core/Hash.pm6 +++ b/src/core/Hash.pm6 @@ -213,21 +213,12 @@ my class Hash { # declared in BOOTSTRAP } # introspection - method name() { - nqp::isnull($!descriptor) ?? Nil !! $!descriptor.name - } - method keyof() { - Str(Any) - } - method of() { - nqp::isnull($!descriptor) ?? Mu !! $!descriptor.of - } - method default() { - nqp::isnull($!descriptor) ?? Any !! $!descriptor.default - } - method dynamic() { - nqp::isnull($!descriptor) ?? False !! nqp::hllbool($!descriptor.dynamic) - } + method keyof() { Str(Any) } # overridden by TypedHash + + method of(Hash:D:) { $!descriptor.of } + method name(Hash:D:) { $!descriptor.name } + method default(Hash:D:) { $!descriptor.default } + method dynamic(Hash:D:) { nqp::hllbool($!descriptor.dynamic) } method push(+values) { fail X::Cannot::Lazy.new(:action, :what(self.^name))