No access to the nested type in generic
Original Reporter info from Mantis: Kverde
-
Reporter name:
Original Reporter info from Mantis: Kverde
- Reporter name:
Description:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils;
type
generic TMyGenericType<_T> = class
public
end;
{ TMyClass }
generic TMyClass<_T> = class
public
type
TMyGenericTypeSpec = specialize TMyGenericType<_T>;
public
procedure Test;
end;
{ TMyClass2 }
generic TMyClass2<_T> = class
public
type
TMyClassSpec = specialize TMyClass<Integer>;
public
procedure Test2;
end;
implementation
{ TMyClass2 }
procedure TMyClass2.Test2;
var
Enum: TMyClassSpec.TMyGenericTypeSpec; //Error: Error in type definition
begin
Enum := TMyClassSpec.TMyGenericTypeSpec.Create;
Enum.Destroy;
end;
{ TMyClass }
procedure TMyClass.Test;
begin
end;
end.
Additional information:
but if you change the way you compiled
{ TMyClass2 }
TMyClass2 = class
public
type
TMyClassSpec = specialize TMyClass<Integer>;
public
procedure Test2;
end;
Mantis conversion info:
- Mantis ID: 24690
- Fixed in version: 3.0.0
- Fixed in revision: 27861 (#639a59df)