Generic interface method delegation incompatibility with Delphi
Original Reporter info from Mantis: kyan
-
Reporter name: Constantine Yannakopoulos
Original Reporter info from Mantis: kyan
- Reporter name: Constantine Yannakopoulos
Description:
In Delphi when you need to delegate the implementation of an interface method to a method with a different name you can use the syntax:
procedure ISomeIntf.SomeMethod = SomeOtherMethod;
With generic interfaces/classes in Delphi mode this syntax is incompatible with Delphi. This does not compile in FPC:
type
IGenericIntf<T> = interface
function SomeMethod: T;
end;
TGenericClass<T> = class(TInterfacedObject, IGenericIntf<T>)
private
protected
function GenericIntf_SomeMethod: T;
function IGenericIntf<T>.SomeMethod = GenericIntf_SomeMethod;
end;
And when you use a type alias:
TGenericClass<T> = class(TInterfacedObject, IGenericIntf<T>)
private
type
IntfType = IGenericIntf<T>;
protected
function GenericIntf_SomeMethod: T;
function IntfType.SomeMethod = GenericIntf_SomeMethod;
end;
it compiles in FPC but not in Delphi XE, so you need to ifdef.
It would be good if the first syntax worked in FPC as well.
Mantis conversion info:
- Mantis ID: 21064
- OS: Windows
- OS Build: 7 x64
- Platform: Win64
- Version: 2.7.1
- Fixed in version: 3.0.0
- Fixed in revision: 21656 (#75bf094e)
- Monitored by: » kyan (Constantine Yannakopoulos)