@@ -782,7 +782,7 @@ algorithm
782782 // Instantiate local components.
783783 ClassTree . applyLocalComponents(cls_tree,
784784 function instComponent(attributes = attributes, innerMod = Modifier . NOMOD (),
785- useBinding = useBinding));
785+ originalAttr = NONE (), useBinding = useBinding));
786786
787787 // Remove duplicate elements.
788788 cls_tree := ClassTree . replaceDuplicates(cls_tree);
@@ -1026,7 +1026,8 @@ algorithm
10261026 function instExtends(attributes = attributes, useBinding = useBinding, visibility = vis));
10271027
10281028 ClassTree . applyLocalComponents(cls_tree,
1029- function instComponent(attributes = attributes, innerMod = Modifier . NOMOD (), useBinding = useBinding));
1029+ function instComponent(attributes = attributes, innerMod = Modifier . NOMOD (),
1030+ originalAttr = NONE (), useBinding = useBinding));
10301031 then
10311032 ();
10321033
@@ -1300,6 +1301,7 @@ function instComponent
13001301 input Component . Attributes attributes "Attributes to be propagated to the component." ;
13011302 input Modifier innerMod;
13021303 input Boolean useBinding "Ignore the component's binding if false." ;
1304+ input Option < Component . Attributes > originalAttr = NONE ();
13031305protected
13041306 Component comp;
13051307 SCode . Element def;
@@ -1322,8 +1324,8 @@ algorithm
13221324
13231325 if Modifier . isRedeclare(outer_mod) then
13241326 checkOuterComponentMod(outer_mod, def, comp_node);
1325- instComponentDef(def, Modifier . NOMOD (), cc_mod, NFComponent . DEFAULT_ATTR , useBinding,
1326- comp_node, parent, isRedeclared = true );
1327+ instComponentDef(def, Modifier . NOMOD (), cc_mod, NFComponent . DEFAULT_ATTR ,
1328+ useBinding, comp_node, parent, originalAttr , isRedeclared = true );
13271329
13281330 Modifier . REDECLARE (element = rdcl_node, mod = outer_mod) := outer_mod;
13291331 cc_smod := SCode . getConstrainingMod(def);
@@ -1337,7 +1339,7 @@ algorithm
13371339 InstNode . setModifier(outer_mod, rdcl_node);
13381340 redeclareComponent(rdcl_node, node, Modifier . NOMOD (), cc_mod, attributes, node);
13391341 else
1340- instComponentDef(def, outer_mod, cc_mod, attributes, useBinding, comp_node, parent);
1342+ instComponentDef(def, outer_mod, cc_mod, attributes, useBinding, comp_node, parent, originalAttr );
13411343 end if ;
13421344end instComponent;
13431345
@@ -1349,6 +1351,7 @@ function instComponentDef
13491351 input Boolean useBinding;
13501352 input InstNode node;
13511353 input InstNode parent;
1354+ input Option < Component . Attributes > originalAttr = NONE ();
13521355 input Boolean isRedeclared = false ;
13531356algorithm
13541357 () := match component
@@ -1381,10 +1384,12 @@ algorithm
13811384 parent_res := Class . restriction(InstNode . getClass(parent));
13821385 attr := instComponentAttributes(component. attributes, component. prefixes);
13831386 attr := checkDeclaredComponentAttributes(attr, parent_res, node);
1384- // attr := mergeComponentAttributes(attributes, attr, node,
1385- // Restriction.isFunction(parent_res));
13861387 attr := mergeComponentAttributes(attributes, attr, node, parent_res);
13871388
1389+ if isSome(originalAttr) then
1390+ attr := mergeRedeclaredComponentAttributes(Util . getOption(originalAttr), attr, node);
1391+ end if ;
1392+
13881393 // Create the untyped component and update the node with it. We need the
13891394 // untyped component in instClass to make sure everything is scoped
13901395 // correctly during lookup, but the class node the component should have
@@ -1485,7 +1490,7 @@ algorithm
14851490 rdcl_node := InstNode . setNodeType(rdcl_type, redeclareNode);
14861491 rdcl_node := InstNode . copyInstancePtr(originalNode, rdcl_node);
14871492 rdcl_node := InstNode . updateComponent(InstNode . component(redeclareNode), rdcl_node);
1488- instComponent(rdcl_node, outerAttr, constrainingMod, true );
1493+ instComponent(rdcl_node, outerAttr, constrainingMod, true , SOME ( Component . getAttributes(orig_comp)) );
14891494 rdcl_comp := InstNode . component(rdcl_node);
14901495
14911496 new_comp := match (orig_comp, rdcl_comp)
@@ -1506,9 +1511,7 @@ algorithm
15061511 end if ;
15071512
15081513 condition := orig_comp. condition;
1509-
1510- // Merge the attributes of the redeclare and the original element.
1511- attr := mergeRedeclaredComponentAttributes(orig_comp. attributes, rdcl_comp. attributes, redeclareNode);
1514+ attr := rdcl_comp. attributes;
15121515
15131516 // Use the dimensions of the redeclare if any, otherwise take them from the original.
15141517 dims := if arrayEmpty(rdcl_comp. dimensions) then orig_comp. dimensions else rdcl_comp. dimensions;
0 commit comments