Skip to content

Commit de0e355

Browse files
committed
Add a way to set the default parent class in NQPClassHOW, to try and help resolve a circular dependency.
1 parent cc282da commit de0e355

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/metamodel/how/NQPClassHOW.pm

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ knowhow NQPClassHOW {
1616
has @!multi_methods_to_incorporate;
1717
has @!parents;
1818
has @!roles;
19+
has $!default_parent;
1920

2021
# Vtable and mapping of method names to slots.
2122
has @!vtable;
@@ -46,6 +47,7 @@ knowhow NQPClassHOW {
4647

4748
method BUILD(:$name) {
4849
$!name := $name;
50+
$!default_parent := NQPMu; # XXX Temporary workaround
4951
}
5052

5153
# Create a new meta-class instance, and then a new type object
@@ -99,6 +101,10 @@ knowhow NQPClassHOW {
99101
}
100102
@!parents[+@!parents] := $parent;
101103
}
104+
105+
method set_default_parent($obj, $parent) {
106+
$!default_parent := $parent;
107+
}
102108

103109
method add_role($obj, $role) {
104110
for @!roles {
@@ -133,10 +139,10 @@ knowhow NQPClassHOW {
133139
RoleToClassApplier.apply($obj, @instantiated_roles);
134140
}
135141

136-
# If we have no parents and we're not called NQPMu then add NQPMu as
137-
# our parent.
142+
# If we have no parents and we're not called NQPMu then add the
143+
# default parent.
138144
if +@!parents == 0 && $!name ne 'NQPMu' {
139-
self.add_parent($obj, NQPMu)
145+
self.add_parent($obj, $!default_parent)
140146
}
141147

142148
# Some things we only do if we weren't already composed once, like building

0 commit comments

Comments
 (0)