tw24453.pp 946 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. unit tw24453;
  2. {$mode delphi}{$H+}
  3. interface
  4. uses
  5. Classes, SysUtils;
  6. type
  7. { TIterator }
  8. TIterator<T> = class
  9. end;
  10. TAncestor<T> = class
  11. public type
  12. TAncestorIterator = class(TIterator<T>)
  13. end;
  14. end;
  15. TTestClass<T> = class(TAncestor<T>)
  16. private
  17. // this compiler recognise
  18. fAncIterator: TAncestor<T>.TAncestorIterator;
  19. protected
  20. // this however does not compile, compiler error is
  21. // ugenericsnestedclassdeclaration.pas(29,39) Fatal: Syntax error, ";" expected but "." found
  22. // the same problem as with result type is with arguments of methods aswell
  23. function GetIterator: TAncestor<T>.TAncestorIterator;
  24. // this compile, but not compatible with delphi (at least with delphi XE2, which I am using)
  25. //function GetIterator: TAncestorIterator<T>;
  26. end;
  27. implementation
  28. function TTestClass<T>.GetIterator: TAncestor<T>.TAncestorIterator;
  29. begin
  30. Result := fAncIterator;
  31. end;
  32. end.