Skip to content

Can not use "specialize" to resolve forward declaration

TFoo is defined as a class.

specialize TGen<TBar> is declaring a class, fulfilling that requirement. Yet it gives an error.

It can be worked around, by declaring the specialized class as base class instead.

program Project1;
type
  generic TGen<_A> = class
    FA: _A;
  end;

  TFoo = class;

  TBar = class
    f: TFoo;
  end;

  TFoo = specialize TGen<TBar>;   // project1.lpr(13,10) Error: Duplicate identifier "TFoo"
  //TFoo = class(specialize TGen<TBar>)  end;

begin
end.

Error also happens without the circle: TFoo = specialize TGen;

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information