[fpc-pascal] specialization of inner class of generic class
Frank Fischer
frank.fischer at mathematik.tu-chemnitz.de
Tue Jan 3 14:00:25 CET 2012
Hi,
I'm a fpc newbie and currently playing around with generic classes.
Consider the following code:
===== test.pas =====
{$mode objfpc}
program Test;
type
generic TGen<_T> = class
public
type
TInner = class
procedure Func;
end;
end;
TInst = specialize TGen<Integer>;
procedure TGen.TInner.Func;
begin
end;
begin
end.
====================
When I compile this program with fpc 2.6.0 I get the following error:
% fpc test.pas
Free Pascal Compiler version 2.6.0 [2011/12/23] for i386
Copyright (c) 1993-2011 by Florian Klaempfl and others
Target OS: Linux for i386
Compiling test.pas
test.pas(8,20) Error: Forward declaration not solved "TGen$LongInt.TInner.Func;"
test.pas(20) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
It seems as if the line TInst = specialize TGen<Integer> is not
sufficient to specialize the inner class TInner of TGen<Integer>. What
do I have to do to get a correct specialization of the inner class?
Thanks in advance and sorry if this is a stupid question.
Frank
More information about the fpc-pascal
mailing list