How do I fully qualify type identifiers in generic methods in Delphi?
Question
This question came up when trying to assign the OnUDPRead event on an Indy IdUDPServer component. (DelphiXE Update 1)
The following auto-generated code gives a syntax error "Expected '>' but '.' found":
procedure TForm1.IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
AData: TArray<System.Byte>; ABinding: TIdSocketHandle);
I can work around this by changing the declaration to:
procedure TForm1.IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
AData: TArray<Byte>; ABinding: TIdSocketHandle);
For future reference, how do I fully qualify a type identifier in a generic method?
Solution
Fully qualified type identifiers are not (yet) supported. But you can circumvent this using a type alias:
type
TMyByte = System.Byte;
procedure TForm1.IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
AData: TArray<TMyByte>; ABinding: TIdSocketHandle);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow