Skip to content
Permalink
Browse files

Fix for #2169

ContainerDescriptor $!default gets instantiated alongside with $!of if
necessary.

Possible problem: if instantiation will be issued based on
ContainerDescriptor.is_generic() return then in cases when $!of is a
non-generic value but the default is set to a generic then default won't
be instantiated. At this moment such situation is not possible because
rakudo dies when `is default` parameter is a generic.
  • Loading branch information...
vrurg committed Mar 4, 2019
1 parent 845433b commit c0134d2ab8a46b01a21ef54efa0ce4da12011210
Showing with 7 additions and 1 deletion.
  1. +7 −1 src/Perl6/Metamodel/BOOTSTRAP.nqp
@@ -1154,10 +1154,16 @@ class ContainerDescriptor {
$!of.HOW.archetypes.generic
}

method is_default_generic() {
$!default.HOW.archetypes.generic
}

method instantiate_generic($type_environment) {
my $ins_of := $!of.HOW.instantiate_generic($!of, $type_environment);
my $ins_default := self.is_default_generic ?? $!default.HOW.instantiate_generic($!default, $type_environment) !! $!default;
my $ins := nqp::clone(self);
nqp::bindattr($ins, $?CLASS, '$!of', $ins_of);
nqp::bindattr($ins, $?CLASS, '$!default', $ins_default);
$ins
}
}
@@ -1212,7 +1218,7 @@ class ContainerDescriptor::BindArrayPos2D does ContainerDescriptor::Whence {
$self
}

method name() {
method name() {
'element at [' ~ $!one ~ ',' ~ $!two ~ ']' # XXX name ?
}
method assigned($scalar) {

0 comments on commit c0134d2

Please sign in to comment.
You can’t perform that action at this time.