Hi

I found problem with is operator using with generics
This program is not compile
error is: Class or Object types "TList$LongInt" and "TList$ShortString"
are not related
But I think it should be possible


{$mode objfpc}

type
   generic TList<_T>=class(TObject)
   public
     data : _T;
     procedure Add(item: _T);
   end;

procedure TList.Add(item: _T);
begin
  data:=item;
end;


type
  TMyIntList = specialize TList<integer>;
  TMyStringList = specialize TList<string>;




var
  ilist : TMyIntList;
  slist : TMyStringList;
begin
  ilist := TMyIntList.Create;
  slist := TMyStringList.Create;
  if sList is tObject then writeln('slist object') else halt(1);
  if iList is tObject then writeln('ilist is  tobject') else halt(2);
  if ilist is tMyStringList then halt(3) else writeln('iList is no
tMyStringList ');

end.



Darek

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to