From fe40b8e807bb446d00110464015c877ca7417567 Mon Sep 17 00:00:00 2001 From: Vadim Belman Date: Wed, 13 Dec 2023 16:59:24 -0500 Subject: [PATCH] Make BOOTSTRAP JVM compatible again JVM doesn't implement nqp::p6capturelexwith --- src/Perl6/Metamodel/ParametricRoleHOW.nqp | 4 ++++ src/Perl6/bootstrap.c/BOOTSTRAP.nqp | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/Perl6/Metamodel/ParametricRoleHOW.nqp b/src/Perl6/Metamodel/ParametricRoleHOW.nqp index 38870f978a..f701a88aee 100644 --- a/src/Perl6/Metamodel/ParametricRoleHOW.nqp +++ b/src/Perl6/Metamodel/ParametricRoleHOW.nqp @@ -167,7 +167,9 @@ class Perl6::Metamodel::ParametricRoleHOW my $error; try { my @result := $!body_block(|@pos_args, |%named_args); + nqp::scwbdisable(); $type_env := nqp::ifnull(Perl6::Metamodel::Configuration.type_env_from(@result[1]), @result[1]); + nqp::scwbenable(); CATCH { $error := $!; } @@ -195,6 +197,8 @@ class Perl6::Metamodel::ParametricRoleHOW } method specialize_with($obj, $conc, $type_env, @pos_args) { + # Here we instantiate generics bound to implementation detail lexicals !INS_OF_*. Perhaps, it'd make more + # sense to move this semantics into role body, where a TypeEnv instance would eventaully be created. my $hll-typeenv := nqp::can($type_env, 'instantiate'); my $ctx := $hll-typeenv ?? $type_env.ctx !! $type_env; my $ctx-iter := nqp::iterator($ctx); diff --git a/src/Perl6/bootstrap.c/BOOTSTRAP.nqp b/src/Perl6/bootstrap.c/BOOTSTRAP.nqp index 81ed3f9f47..236364a08c 100644 --- a/src/Perl6/bootstrap.c/BOOTSTRAP.nqp +++ b/src/Perl6/bootstrap.c/BOOTSTRAP.nqp @@ -1743,7 +1743,12 @@ BEGIN { $type.HOW.instantiate_generic($type, $type_environment)); } if nqp::isconcrete($ci) { +#?if !jvm nqp::bindattr($ins, Attribute, '$!container_initializer', nqp::p6capturelexwhere($ci.clone())); +#?endif +#?if jvm + nqp::bindattr($ins, Attribute, '$!container_initializer', $ci.clone()); +#?endif } my $cd_ins := $cd; if $cd.is_generic { @@ -1783,7 +1788,12 @@ BEGIN { $pkg.HOW.instantiate_generic($pkg, $type_environment)); } if nqp::defined($bc) { +#?if !jvm nqp::bindattr($ins, Attribute, '$!build_closure', nqp::p6capturelexwhere($bc.clone())); +#?endif +#?if jvm + nqp::bindattr($ins, Attribute, '$!build_closure', $bc.clone()); +#?endif } $ins }));