Object with interface aliases calls wrong method
Original Reporter info from Mantis: smcilwain
-
Reporter name: Sean J McIlwain
Original Reporter info from Mantis: smcilwain
- Reporter name: Sean J McIlwain
Description:
Following code compiles, but calls the wrong method upon execution.
Should call GetChild, but ends up calling RemoveChild instead.
Additional information:
program bug9;
{$mode delphi}
type
ITest = interface(IInterface)
['{FE6B16A6-A898-4B09-A46E-0AAC5E0A4E14}']
function Parent: ITest;
end;
ITestEx = interface(ITest)
['{82449E91-76BE-4F4A-B873-1865042D5CAF}']
function Parent: ITestEx;
function GetChild: ITestEx;
procedure RemoveChild;
end;
TTest = class(TInterfacedObject, ITestEx)
function ITestEx.Parent = ParentEx;
{ ITest }
function Parent: ITest;
{ ITestEx }
function ParentEx: ITestEx;
function GetChild: ITestEx;
procedure RemoveChild;
end;
{ ITest }
function TTest.Parent: ITest;
begin;
Result := nil;
end;
{ ITestEx }
function TTest.ParentEx: ITestEx;
begin;
Result := nil
end;
function TTest.GetChild: ITestEx;
begin;
WriteLn('TTest.GetChild');
Result := nil
end;
procedure TTest.RemoveChild;
begin;
WriteLn('TTest.RemoveChild');
end;
var E: ITestEx;
begin
E := TTest.Create;
WriteLn('Calling GetChild');
E.GetChild();
WriteLn('Stop');
end.
Mantis conversion info:
- Mantis ID: 11862
- Version: 2.3.1
- Fixed in version: 2.2.4
- Fixed in revision: 12146 (#47cdad34)