Can't specialize a generic class A from a generic class B using B as the type on which to specialize A
Original Reporter info from Mantis: Hixie
-
Reporter name: Ian Hickson
Original Reporter info from Mantis: Hixie
- Reporter name: Ian Hickson
Description:
A type in a generic can't specialize another generic using the self-reference type as a parameter to the second generic.
e.g. this fails:
generic TBar<Y> = class
type
TSelfSpecializedFoo = specialize TFoo<TBar>; // <-- this fails
end;
Steps to reproduce:
{$MODE OBJFPC} { -*- text -*- }
program tests;
type
generic TFoo<X> = class
end;
generic TBar<Y> = class
type
TIntegerSpecializedFoo = specialize TFoo<Integer>;
TSelfSpecializedFoo = specialize TFoo<TBar>; // <-- this fails
function SelfTest(): TBar; // returns a TBar<Y>
// TSpecializedBar = specialize TBar<Y>; // this rightly would not compile since TBar here refers to the specialized TBar<Y>
end;
function TBar.SelfTest(): TBar;
begin
Result := Self;
end;
begin
end.
Additional information:
Compilable test case available at: http://junkyard.damowmow.com/467
Mantis conversion info:
- Mantis ID: 19511
- Build: trunk compiled 2011-06-05
- Version: 2.5.1
- Fixed in version: 3.0.0
- Monitored by: » Basil Peace (Basil Peace)