[PATCH] Using a forward declared subtype is incompatible with a typed generic declaration.
Original Reporter info from Mantis: AndrewH @andrewd207
-
Reporter name:
Original Reporter info from Mantis: AndrewH @andrewd207
- Reporter name:
Description:
TA = class; // forward
TB = class; // forward TB = class(TA)
TBaseAList&LtPos;T: TA> = class // no problems using forward declared TA
end;
TAList = class(TBaseAList&LtPos;TA>); // no problem
TBList = class(TBaseAList&LtPos;TB>); // message: expected TA got TB!
TA = class
end;
TB = class(TA)
end;
The attached patch makes this work. I'm not sure how Delphi behaves as I don't have it.
Steps to reproduce:
program Project1;
{$IFDEF FPC}
{$mode delphi}{$H+}
{$ENDIF}
type
TA = class; // forward
TB = class; // forward TB = class(TA)
//TC = class; // forward
TBaseAList<T: TA> = class // no problems
Foo: T;
end;
TAList = class(TBaseAList<TA>); // no problem
TBList = class(TBaseAList<TB>); // message: expected TA got TB!
//TCList = class(TBaseAList<TC>); // indicates that TC should inherit from TA
TA = class
end;
TB = class(TA)
end;
//TC = class(TObject); // not related to TA and should always fail.
begin
end.
Mantis conversion info:
- Mantis ID: 37953
- Version: 3.3.1
- Monitored by: » @sergy.larin (Sergey Larin)