﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
1659	Redeclare with recursive modifier doesn't work	Per Östlund	Per Östlund	"Several Fluid models use StaticPipe, which both redeclares Medium and sets a modifier on the flowModel component that uses flowModel itself. If Medium is redeclared to be a medium which redeclares density in this case, then we get a type mismatch when the modifier is elaborated. This is caused by flowModel.states not having been updated to the correct ThermodynamicState class. Medium.density therefore gets the type of it's input to be PartialSimpleMedium.ThermodynamicState, as redeclared by OneTank, but flowModel.states will still be PartialMedium.ThermodynamicState since it's type will only be updated when flowModel has been instantiated. Here is a model which shows this problem:
{{{
model StaticPipe 
  extends PartialStraightPipe;
  FlowModel flowModel(redeclare final package Medium = Medium, 
    vs = Medium.density(flowModel.states));
end StaticPipe;

partial model PartialStraightPipe 
  replaceable package Medium = PartialMedium;
  replaceable model FlowModel = PartialStaggeredFlowModel;
end PartialStraightPipe;

model PartialStaggeredFlowModel 
  replaceable package Medium = PartialMedium;
  input Medium.ThermodynamicState states;
  input Real vs;
end PartialStaggeredFlowModel;

partial package PartialMedium 
  replaceable record ThermodynamicState 
  end ThermodynamicState;

  replaceable partial function density 
    input ThermodynamicState state;
    output Real d;
  end density;
end PartialMedium;

partial package PartialSimpleMedium 
  extends PartialMedium;

  redeclare record extends ThermodynamicState 
    Real p;
    Real T;
  end ThermodynamicState;

  redeclare function extends density 
  algorithm
    d := 0;
  end density;
end PartialSimpleMedium;

model OneTank 
  StaticPipe pipe(redeclare package Medium = PartialSimpleMedium);
end OneTank;
}}}"	defect	closed	high		Instantiation		fixed		Per Östlund Adrian Pop
