bug0215.pp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. { $OPT=-St }
  2. { allow static keyword }
  3. { submitted by Andrew Wilson }
  4. Program X;
  5. {$ifdef go32v2}
  6. uses dpmiexcp;
  7. {$endif go32v2}
  8. Type
  9. PY=^Y;
  10. Y=Object
  11. A : LongInt;
  12. P : PY; static;
  13. Constructor Init(NewA:LongInt);
  14. Procedure StaticMethod; static;
  15. Procedure VirtualMethod; virtual;
  16. End;
  17. Constructor Y.Init(NewA:LongInt);
  18. Begin
  19. A:=NewA;
  20. P:=@self;
  21. End;
  22. Procedure Y.StaticMethod;
  23. Begin
  24. Writeln(P^.A); // Compiler complains about using A.
  25. P^.VirtualMethod; // Same with the virtual method.
  26. With P^ do begin
  27. Writeln(A); // These two seem to compile, but I
  28. VirtualMethod; // can't get them to work. It seems to
  29. End; // be the same problem as last time, so
  30. End; // I'll check it again when I get the
  31. // new snapshot.
  32. Procedure Y.VirtualMethod;
  33. Begin
  34. Writeln('VirtualMethod ',A);
  35. End;
  36. var T1,T2 : PY;
  37. Begin
  38. New(T1,init(1));
  39. New(T2,init(2));
  40. T1^.VirtualMethod;
  41. T2^.VirtualMethod;
  42. Y.StaticMethod;
  43. T1^.StaticMethod;
  44. T2^.StaticMethod;
  45. End.