Reputation: 1084
I would like to do
M_type(redeclare package L=L2) m2_instance;
but does not work. Instead I can write
model M2_type
extends M_type(redeclare package L=L2);
end M2_type;
M2_type m2_instance;
Is here not a shorter way to do this and avoid declaring M2_type?
Upvotes: 2
Views: 315
Reputation: 6655
The redeclare modifier must be moved to the instance name.
M_type(redeclare package L=L2) m2_instance; // wrong syntax
M_type m2_instance(redeclare package L=L2); // correct
Below is a small package, which demonstrates everything and simulates perfectly fine in Dymola 2021x and OpenModelica 1.16.2.
package Redeclaration
package L1
constant Real x = 1;
end L1;
package L2
constant Real x = 2;
end L2;
model M_type
replaceable package L = L1;
Real x = L.x;
end M_type;
model Example
M_type m_instance(redeclare package L=L2);
end Example;
end Redeclaration;
Upvotes: 9