Skip to content

Commit

Permalink
Fix for setting core classes language version
Browse files Browse the repository at this point in the history
new_type method can be called before CORE started compiling. But compose
method is the right place.
  • Loading branch information
vrurg committed Sep 1, 2019
1 parent 9dc6cb8 commit 617999c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/Perl6/Metamodel/ClassHOW.nqp
@@ -1,7 +1,7 @@
class Perl6::Metamodel::ClassHOW
does Perl6::Metamodel::Naming
does Perl6::Metamodel::Documenting
does Perl6::Metamodel::Versioning
does Perl6::Metamodel::LanguageRevision
does Perl6::Metamodel::Stashing
does Perl6::Metamodel::AttributeContainer
does Perl6::Metamodel::MethodContainer
Expand Down Expand Up @@ -52,7 +52,7 @@ class Perl6::Metamodel::ClassHOW
my $obj := nqp::settypehll($new_type, 'perl6');
$metaclass.set_name($obj, $name // "<anon|{$anon_id++}>");
self.add_stash($obj);
$metaclass.set_ver($obj, $ver);
$metaclass.set_ver($obj, $ver) if $ver;
$metaclass.set_auth($obj, $auth) if $auth;
$metaclass.set_api($obj, $api) if $api;
$metaclass.setup_mixin_cache($obj);
Expand Down Expand Up @@ -92,6 +92,11 @@ class Perl6::Metamodel::ClassHOW
method compose($the-obj, :$compiler_services) {
my $obj := nqp::decont($the-obj);

# Set class language version if class belongs to the CORE
if $*COMPILING_CORE_SETTING {
self.set_language_version($the-obj);
}

# Instantiate all of the roles we have (need to do this since
# all roles are generic on ::?CLASS) and pass them to the
# composer.
Expand Down
4 changes: 4 additions & 0 deletions src/Perl6/Metamodel/LanguageRevision.nqp
Expand Up @@ -6,6 +6,10 @@ role Perl6::Metamodel::LanguageRevision

# The only allowed version format is 6.X
method set_language_version($obj, $ver = NQPMu) {
# Don't override if version is already set
if self.ver($obj) {
return
}
if nqp::isconcrete($ver) {
nqp::die("Language version must be a string in '6.<rev>' format, got `$ver`.")
unless (nqp::iseq_i(nqp::chars($ver), 3) && nqp::eqat($ver, '6.', 0))
Expand Down
3 changes: 0 additions & 3 deletions src/Perl6/Metamodel/Versioning.nqp
Expand Up @@ -8,9 +8,6 @@ role Perl6::Metamodel::Versioning {
method api($obj) { $!api // '' }

method set_ver($obj, $ver) {
if $*COMPILING_CORE_SETTING && !$ver {
$ver := nqp::getcomp('perl6').language_version;
}
$!ver := $ver if $ver
}
method set_auth($obj, $auth) { $!auth := $auth }
Expand Down

0 comments on commit 617999c

Please sign in to comment.