Skip to content

Disregarded final keyword on redeclare clause #605

Description

@AntoineGautier

Pulling the MBL feature branch related to lbl-srg/modelica-buildings#4697 and regenerating templates.json, the parameters from the cfg record now appear in the configuration panel of VAVBoxCoolingOnly.

partial model PartialAirTerminal
  replaceable parameter 
    Buildings.Templates.ZoneEquipment.Configuration.PartialAirTerminal cfg

model VAVBox "Interface class for VAV terminal unit"
  extends Buildings.Templates.ZoneEquipment.Interfaces.PartialAirTerminal(  // <-- Intermediary extends with final redeclare
    redeclare final Buildings.Templates.ZoneEquipment.Configuration.VAVBox cfg
   
model VAVBoxCoolingOnly "VAV terminal unit cooling only"
  extends Buildings.Templates.ZoneEquipment.Interfaces.VAVBox 

These parameters should not be displayed since their declaring class has a final keyword at the redeclare site.

The same construct is used in VAVMultiZone, but with no intermediary extends statement.

partial model PartialAirHandler "Interface class for air handler"
    replaceable parameter 
    Buildings.Templates.AirHandlersFans.Configuration.PartialAirHandler cfg;

model VAVMultiZone "Multiple-zone VAV"
  extends Buildings.Templates.AirHandlersFans.Interfaces.PartialAirHandler( // <-- Direct extends with final redeclare
    redeclare final Buildings.Templates.AirHandlersFans.Configuration.VAVMultiZone cfg

That latter case works: parameters from cfg are not displayed.

[EDIT] The issue is not due to the nested redeclare but to the fact that parameters within cfg have final bindings in the case of the VAVMultiZone, and don't in the case of VAVBoxCoolingOnly. In both cases the final redeclare of the declaring class does not propagate to the declared parameters.

Per https://specification.modelica.org/maint/3.6/inheritance-modification-and-redeclaration.html#final-element-modification-prevention:

All elements of a final element are also final.

However, Modelica tools' behavior varies. After redeclare final Buildings.Templates.ZoneEquipment.Configuration.VAVBox cfg, Dymola (2026x) removes the cfg record from the parameter dialog and prevents any modification of inside parameters in derived classes (final overriding error). OCT does not even warn against that.

To match the MLS, ctrl-flow should propagate the final keyword to all elements of the redeclared type.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions