By using the keyword redeclare it is possible to modify the type and/or the prefixes and possibly the dimension sizes of a declared element. This kind of modification is called a redeclaration. In most cases a declaration that can be redeclared must include the prefix replaceable.
The element in a redeclaration must have a type that is either a subtype of the replaceable element in the modified class or a subtype of a constraining type. An example is shown below with the concepts of redeclaration.
The redeclaration of the R1 element changes its type from Resistor to TempResistor and its prefix from discrete to parameter.
The MiniCircuitRed class can be rewritten as the MiniCircuit2
The next example illustrates a redeclaration used in an extends clause.
The redeclaration redeclare RedA2 a(y=2) is used in an extends clause to replace the original declaration RedA a(x=1) from class RedB, but merging the original nested modifier (x=1) with the modifiers in the redeclaration to effectively get RedA2 a(x=1,y=2). The type of the redeclared field a in class RedB is changed from RedA to RedA2 in class RedB2 which is correct since RedA2 is a subtype of RedA.
The class RedB, is equivalent to the class B2expanded below.