Skip to content

Commit 2a9ec19

Browse files
committed
Improve multiple inheritance support
Current algorithm doesn't support multiple inheritance when inheritance depth is more than 1 on two parents. It'll not parse the "_add" or "_remove" attributes on a second parent which is at the same level as that of a parent that defines the attribute. This change ensures that second parent which is at the same level as that of a parent that defines the attribute is parsed for "_add" or "_remove" attributes. However, this change will parse the parent which defines the attributes twice, once to evaluate the attribute and then to evaluate the "_add" or "_remove" attribute. But, no target is allowed to define an attribute and also "_add" or "_remove" for the same attribute. Signed-off-by: Devaraj Ranganna <[email protected]>
1 parent 1a071d4 commit 2a9ec19

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tools/targets/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,10 @@ def __getattr_cumulative(self, attrname):
292292
# inheritance level, left to right order to figure out all the
293293
# other classes that change the definition by adding or removing
294294
# elements
295-
for idx in range(self.resolution_order[def_idx][1] - 1, -1, -1):
295+
highest_order = 0
296+
for t in self.resolution_order:
297+
highest_order = highest_order if highest_order > t[1] else t[1]
298+
for idx in range(highest_order - 1, -1, -1):
296299
same_level_targets = [tar[0] for tar in self.resolution_order
297300
if tar[1] == idx]
298301
for tar in same_level_targets:

0 commit comments

Comments
 (0)