fpc/tests/tbs/tb0182.pp
paul 8166148a37 compiler: 'static' keyword:
- deprecate -St compiler switch
  - remove $STATIC directive
  - unconditionally enable 'static' keyword usage
  - adopt tests, samplecfg, fpc.cft, error messages

git-svn-id: trunk@14569 -
2010-01-07 19:02:09 +00:00

51 lines
1.1 KiB
ObjectPascal

{ Old file: tbs0215.pp }
{ more bugss with static methods OK 0.99.11 (PM) }
{ allow static keyword }
{ submitted by Andrew Wilson }
Program X;
Type
PY=^Y;
Y=Object
A : LongInt;
P : PY; static;
Constructor Init(NewA:LongInt);
Procedure StaticMethod; static;
Procedure VirtualMethod; virtual;
End;
Constructor Y.Init(NewA:LongInt);
Begin
A:=NewA;
P:=@self;
End;
Procedure Y.StaticMethod;
Begin
Writeln(P^.A); // Compiler complains about using A.
P^.VirtualMethod; // Same with the virtual method.
With P^ do begin
Writeln(A); // These two seem to compile, but I
VirtualMethod; // can't get them to work. It seems to
End; // be the same problem as last time, so
End; // I'll check it again when I get the
// new snapshot.
Procedure Y.VirtualMethod;
Begin
Writeln('VirtualMethod ',A);
End;
var T1,T2 : PY;
Begin
New(T1,init(1));
New(T2,init(2));
T1^.VirtualMethod;
T2^.VirtualMethod;
Y.StaticMethod;
T1^.StaticMethod;
T2^.StaticMethod;
End.