Compiler picks up wrong Self for class method variables
Original Reporter info from Mantis: kluug.net @onpok
-
Reporter name: Ondrej Pokorny
Original Reporter info from Mantis: kluug.net @onpok
- Reporter name: Ondrej Pokorny
Description:
If class method is referenced from object instance to a variable, it fails to set Self to the class.
Steps to reproduce:
Compile the following program.
program test;
{$mode objfpc}{$H+}
type
TCallback = procedure of object;
TTestObject = class (TObject)
public
class procedure Test;
end;
class procedure TTestObject.Test;
begin
writeln(Self.ClassName); // Self should point to TTestObject (class)
end;
var
Callback: TCallback;
O: TTestObject;
begin
O := TTestObject.Create;
Callback := @O.Test;
Callback();
ReadLn;
end.
Additional information:
The bug is independent on the mode. It can be reproduced in Delphi mode as well.
Mantis conversion info:
- Mantis ID: 29491
- Version: 3.1.1
- Fixed in version: 3.1.1
- Fixed in revision: 34395 (#f64556c1)
- Monitored by: » Vincent (Vincent Snijders)