.Clone ignores type of inherited attributes

Hey,

the following situation makes some problems atm.

On the server side I cache an array of tariffs. So I need to copy the content If a client requests the data.
Normally, I call .clone to return the whole array w/o losing the cache. Now, I have a class containing an attribute that owns an attribute which can be from different types (the ancestor is always “TValidity”). The clone function seems to ignore the class type of the validity attribute. The following code shows my actual workaround.

function TTicketController.GetTariffs(AUserID: Integer): TTariffs;
var Iterator: TTariff;
    Tariff: TTariff;
begin
  Result:= TTariffs.Create;
  for Iterator in FTariffData.GetTariffs(tcAll) do
  begin
    Tariff:= Iterator.Clone as TTariff;
    // Tariff.CostLevel.Validity will always be TValidity, wrong!
    if Iterator.CostLevel.Validity is TSeasonalValidity then
    begin
      Tariff.CostLevel.Validity.Free;
      Tariff.CostLevel.Validity:= Iterator.CostLevel.Validity.Clone as TValidity;
    end;
    Result.Add(Tariff);
  end;
end;

Is this a known problem or something that you won’t follow up?

Thanks!

I can’t reproduce this with simple testcase: testcase.zip (110.1 KB)

This is the correct testcase:
testcase2.zip (4.7 MB)

Thanks, logged as bugs://80508

I logged with low priority

Any news? This is very weird…

bugs://80508 got closed with status fixed.