Como me qualifico totalmente identificadores de tipo em métodos genéricos em Delphi?

StackOverflow https://stackoverflow.com/questions/4222379

  •  26-09-2019
  •  | 
  •  

Pergunta

Esta pergunta surgiu ao tentar atribuir o evento Onudpread em um componente IndudpServer. (Delphixe Atualização 1)

O código gerado automaticamente seguinte fornece um erro de sintaxe "esperado '>' mas '. encontrado":

procedure TForm1.IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
  AData: TArray<System.Byte>; ABinding: TIdSocketHandle);

Eu posso contornar isso alterando a declaração para:

procedure TForm1.IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
  AData: TArray<Byte>; ABinding: TIdSocketHandle);

Para referência futura, como qualifico totalmente um identificador de tipo em um método genérico?

Foi útil?

Solução

Os identificadores do tipo totalmente qualificado ainda não são (ainda) suportados. Mas você pode contornar isso usando um alias de tipo:

type
  TMyByte = System.Byte;

procedure TForm1.IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
  AData: TArray<TMyByte>; ABinding: TIdSocketHandle);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top