title: Is it possible to move the descendant of generic class to implementation section?
body: <p>I would like to clean concrete classes from interface section, but the compiler doesn't allow to make it.
  Whether there is an opportunity to make so that the external code couldn't address to concrete classes?</p>
  
  <pre><code>unit Unit2;
  
  interface
  
  uses
    System.SysUtils
    , System.Generics.Collections
    , System.Win.Registry
    ;
  type
    IMyRegistry&lt;T&gt; = interface
      procedure WriteValue(const Key, Ident: string; const AValue: T);
      function ReadValue(const Key, Ident: string; const ADefVal: T): T;
    end;
  
    TMyRegistry&lt;T&gt; = class abstract(TInterfacedObject, IMyRegistry&lt;T&gt;)
    strict private
      class var FDefaultReg: IMyRegistry&lt;T&gt;;
      class var FRegistry: TRegistry;
      class var FDefKey: string;
    private
      class function GetDefKey: string;
      class function GetInstance: IMyRegistry&lt;T&gt;; static;
    protected
      procedure WriteValue(const Key, Ident: string; const AValue: T); virtual; abstract;
      function ReadValue(const Key, Ident: string; const ADefVal: T): T; virtual; abstract;
      function GoToKey(const AKeyName: string; const ACreateKey: Boolean = False): Boolean;
      class property InnerRegistry: TRegistry read FRegistry;
    public
      class constructor Create;
      class destructor Destroy;
      class property Default: IMyRegistry&lt;T&gt; read GetInstance;
    end;
  
    TDefaultMyRegistry&lt;T&gt; = class(TMyRegistry&lt;T&gt;)
    protected
      procedure WriteValue(const Key, Ident: string; const AValue: T); override;
      function ReadValue(const Key, Ident: string; const ADefVal: T): T; override;
    end;
  
    TMyRegistryFactory = class
    public
      class function GetMyRegistryConcrete&lt;T&gt;: IMyRegistry&lt;T&gt;;
    end;
  
    //TMyRegInteger = class(TMyRegistry&lt;Integer&gt;)
    //protected
      //procedure WriteValue(const Key, Ident: string; const AValue: Integer); override;
      //function ReadValue(const Key, Ident: string; const ADefVal: Integer): Integer; override;
    //end;
  
    EMyRegGenericException = class(Exception);
      EMyRegTypeNotSupported = class(EMyRegGenericException);
  
  const
    cCompanyName = 'MyCompany';
    cProgramName = 'MyProgram';
  
  resourcestring
    SRegTypeNotSupported = 'Operations are not supported for values of type "%s"';
  
  implementation
  
  uses
    Winapi.Windows
    , System.TypInfo;
  
  type
    TMyRegInteger = class(TMyRegistry&lt;Integer&gt;)
    protected
      procedure WriteValue(const Key, Ident: string; const AValue: Integer); override;
      function ReadValue(const Key, Ident: string; const ADefVal: Integer): Integer; override;
    end;    
  
  
  { TMyRegistry&lt;T&gt; }
  
  class constructor TMyRegistry&lt;T&gt;.Create;
  begin
    inherited;
    FDefaultReg := TDefaultMyRegistry&lt;T&gt;.Create;
    FRegistry := TRegistry.Create;
    FRegistry.RootKey := HKEY_CURRENT_USER;
    FDefKey := GetDefKey;
  end;
  
  class destructor TMyRegistry&lt;T&gt;.Destroy;
  begin
    FreeAndNil(FRegistry);
    inherited;
  end;
  
  class function TMyRegistry&lt;T&gt;.GetDefKey: string;
  const
    cDefKey = '\Software\%s\%s\';
  begin
    Result := Format(cDefKey, [cCompanyName, cProgramName]);
  end;
  
  class function TMyRegistry&lt;T&gt;.GetInstance: IMyRegistry&lt;T&gt;;
  begin
    Result := FDefaultReg;
  end;
  
  function TMyRegistry&lt;T&gt;.GoToKey(const AKeyName: string;  const ACreateKey: Boolean): Boolean;
  var
    sDestKeyName: string;
  begin
    sDestKeyName := FDefKey + AKeyName;
    Result := FRegistry.OpenKey(sDestKeyName, False);
    if not Result and ACreateKey then
      Result := FRegistry.OpenKey(sDestKeyName, ACreateKey);
  end;
  
  
  { TDefaultMyRegistry&lt;T&gt; }
  
  function TDefaultMyRegistry&lt;T&gt;.ReadValue(const Key, Ident: string;  const ADefVal: T): T;
  var
    tmpReg: IMyRegistry&lt;T&gt;;
  begin
    Assert(TypeInfo(T) &lt;&gt; nil, 'Тип не определен');
    Result := ADefVal;
    if GoToKey(Key) then
      if InnerRegistry.ValueExists(Ident) then
      begin
        tmpReg := TMyRegistryFactory.GetMyRegistryConcrete&lt;T&gt;;
        if Assigned(tmpReg) then
          Result := tmpReg.ReadValue(Key, Ident, ADefVal);
      end;
  end;
  
  procedure TDefaultMyRegistry&lt;T&gt;.WriteValue(const Key, Ident: string; const AValue: T);
  var
    tmpReg: IMyRegistry&lt;T&gt;;
  begin
    inherited;
    if GoToKey(Key, True) then
    begin
      tmpReg := TMyRegistryFactory.GetMyRegistryConcrete&lt;T&gt;;
      if Assigned(tmpReg) then
        tmpReg.WriteValue(Key, Ident, AValue);
    end;
  end;
  
  
  { TMyRegistryFactory }
  
  class function TMyRegistryFactory.GetMyRegistryConcrete&lt;T&gt;: IMyRegistry&lt;T&gt;;
  begin
    Result := nil;
    if TypeInfo(T) = TypeInfo(Integer) then
      Result := IMyRegistry&lt;T&gt;(IMyRegistry&lt;Integer&gt;(TMyRegInteger.Create)) //&lt;&lt;&lt;  [DCC Error] Unit2.pas(155): E2506 Method ...
    else
      raise EMyRegTypeNotSupported.CreateFmt(
        SRegTypeNotSupported, [PTypeInfo(TypeInfo(T))^.Name]);
  end;
  
  
  { TMyRegInteger }
  
  function TMyRegInteger.ReadValue(const Key, Ident: string;
    const ADefVal: Integer): Integer;
  begin
    Result := InnerRegistry.ReadInteger(Ident);
  end;
  
  procedure TMyRegInteger.WriteValue(const Key, Ident: string; const AValue: Integer);
  begin
    inherited;
    InnerRegistry.WriteInteger(Ident, AValue);
  end;
  
  end.
  </code></pre>
  
  <p>If to move a class declaration 'TMyRegInteger' to implementation section, then the compiler reports about an error:
  "[DCC Error] Unit2.pas(155): E2506 Method of parameterized type declared in interface section must not use local symbol '.TMyRegInteger'"</p>
  
  <p>in </p>
  
  <pre><code>class function TMyRegistryFactory.GetMyRegistryConcrete&lt;T&gt;: IMyRegistry&lt;T&gt;;
  begin
    Result := nil;
    if TypeInfo(T) = TypeInfo(Integer) then
      Result := IMyRegistry&lt;T&gt;(IMyRegistry&lt;Integer&gt;(TMyRegInteger.Create)) //&lt;&lt;&lt;&lt;&lt;
  </code></pre>