Skip to content

Commit

Permalink
Fix #6221 (#7505)
Browse files Browse the repository at this point in the history
- Use a relaxed context when instantiating record constructors, to allow
  e.g. partial classes in them.
  • Loading branch information
perost committed May 31, 2021
1 parent b7d5bf7 commit d8f7882
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions OMCompiler/Compiler/NFFrontEnd/NFRecord.mo
Expand Up @@ -109,6 +109,7 @@ protected
InstNode ctor_node, out_rec;
Component out_comp;
Class ctor_cls;
InstContext.Type ctor_context;
algorithm
// The node we get is usually a record instance, with applied modifiers and so on.
// So the first thing we do is to create a "pure" instance of the record.
Expand All @@ -126,9 +127,10 @@ algorithm
ctor_node := InstNode.replaceClass(Class.NOT_INSTANTIATED(), node);
end try;

ctor_context := InstContext.set(context, NFInstContext.RELAXED);
ctor_node := InstNode.setNodeType(NFInstNode.InstNodeType.ROOT_CLASS(InstNode.parent(node)), ctor_node);
ctor_node := Inst.instantiate(ctor_node, context = context, instPartial = true);
Inst.instExpressions(ctor_node, context = context);
ctor_node := Inst.instantiate(ctor_node, context = ctor_context);
Inst.instExpressions(ctor_node, context = ctor_context);

// Collect the record fields.
(inputs, locals, all_params) := collectRecordParams(ctor_node);
Expand Down

0 comments on commit d8f7882

Please sign in to comment.