Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 75bf644

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Fix scoping for derived classes.
Belonging to [master]: - #2317 - OpenModelica/OpenModelica-testsuite#898
1 parent c282ec9 commit 75bf644

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Compiler/NFFrontEnd/NFInst.mo

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -749,16 +749,20 @@ algorithm
749749

750750
case Class.DERIVED_CLASS()
751751
algorithm
752+
node := InstNode.replaceClass(cls, node);
752753
// Merge outer modifiers and attributes.
753754
mod := Modifier.fromElement(InstNode.definition(node), InstNode.level(parent), InstNode.parent(node));
754755
mod := Modifier.merge(outerMod, mod);
755756
attributes := mergeDerivedAttributes(attributes, cls.attributes, node);
756757

757-
// Instantiate the base class and create a new instance node.
758-
(base_node, attributes) := instClass(cls.baseClass, mod, attributes, parent);
758+
// Mark the base class node as a base class.
759+
base_node := InstNode.setNodeType(
760+
InstNodeType.BASE_CLASS(node, InstNode.definition(cls.baseClass)), cls.baseClass);
761+
762+
// Instantiate the base class and update the nodes.
763+
(base_node, attributes) := instClass(base_node, mod, attributes);
759764
cls.baseClass := base_node;
760765
cls.attributes := attributes;
761-
node := InstNode.replaceClass(cls, node);
762766

763767
// Update the dimensions and the parent's type with the new class instance.
764768
cls.dims := list(Dimension.setScope(dim, node) for dim in cls.dims);
@@ -1722,7 +1726,7 @@ algorithm
17221726

17231727
case Class.DERIVED_CLASS()
17241728
algorithm
1725-
sections := instExpressions(cls.baseClass, scope, sections);
1729+
sections := instExpressions(cls.baseClass, cls.baseClass, sections);
17261730

17271731
if not listEmpty(cls.dims) then
17281732
cls.dims := list(instDimension(d, InstNode.info(node))

0 commit comments

Comments
 (0)