On 30.04.2012 17:45, Donald R. Ziesig wrote:
Hi All!

I am working on a generic type library and ran into a problem at compile
time.

type
generic TMyType<T> = class
*
*
*
function IndexOf( Item : T ) : Integer; overload;
functionIndexOf( aName : String) : Integer; overload;

// generics1.pas Error: Function is already declared Public\Forward
"TMyType.IndexOf(AnsiString):LongInt;"

// or, reverse the declarations:

function IndexOf( aName : String ) : Integer; overload;
function IndexOf( Item : T ) : Integer; overload;

// generics1.pas Error: Function is already declared Public\Forward
"TMyType.IndexOf(<undefined type>):LongInt;"

end;

Similar errors occur in implementation of the overloaded subprograms, as
in:

// generics1.pas Error: function header "IndexOf" doesn't match forward
: var name changes aName => Item


The obvious work-around is to avoid overloading with generic types as
parameters, but that is really a hack in this case.

Keep up the GREAT work,

What version of FPC did you try with? If it was 2.6.0 or 2.6.1 or anything older then please try with a recent trunk version. I fixed this problem some weeks ago. If you already tested with a recent trunk version of FPC than please open a bug report for the compiler with a simple example that does not depend on the LCL and should compile.

Regards,
Sven


--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to