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,

Don Z.


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

Reply via email to