bug0187.pp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. program test;
  2. type
  3. Tbaseclass = object
  4. constructor Init;
  5. destructor Done;
  6. procedure Run; virtual;
  7. end;
  8. Totherclass = object(Tbaseclass)
  9. procedure Run; virtual;
  10. end;
  11. constructor Tbaseclass.Init;
  12. begin
  13. writeln('Init');
  14. Run;
  15. end;
  16. destructor Tbaseclass.Done;
  17. begin
  18. writeln('Done');
  19. end;
  20. procedure Tbaseclass.Run;
  21. begin
  22. writeln('Base method');
  23. end;
  24. procedure Totherclass.Run;
  25. begin
  26. writeln('Inherited method');
  27. end;
  28. var base : Tbaseclass;
  29. other : Totherclass;
  30. // asmrec : Tasmrec;
  31. testfield : longint;
  32. begin
  33. // Uncommenting here and commenting the init in the WIth solves it.
  34. // Base.Init;
  35. with base do
  36. begin
  37. Init;
  38. Run;
  39. Done;
  40. end;
  41. // Uncommenting here and commenting the init in the WIth solves it.
  42. // Other.init;
  43. with other do
  44. begin
  45. Init;
  46. Run;
  47. Done;
  48. end;
  49. { Calls Tbaseclass.Run when it should call Totherclass.Run }
  50. end.