E2506接口部分中声明的参数化类型的方法不得使用本地符号

Wod*_*dzu 11 delphi generics compiler-errors delphi-2009

可能有人给我解释一下是什么原因,创建一个泛型类时,我必须把我的私人的constans的接口部分?这是在扼杀我的设计,我不希望别人看到应该是私密的东西.

unit Unit38;

interface

uses
  Generics.Collections;

type
  TSimpleClass<T> = class(TObject)
  private
    procedure DoSomethingInternal(const SomeString: string);
  public
    procedure DoSomething;
  end;

implementation

const
  MyString = 'some string'; //Why this must be public?

{ TSimpleClass<T> }

procedure TSimpleClass<T>.DoSomething;
begin
  DoSomethingInternal(MyString); //Compiler error
end;

procedure TSimpleClass<T>.DoSomethingInternal(const SomeString: string);
begin
  //-------
end;

end.
Run Code Online (Sandbox Code Playgroud)

谢谢.

Mar*_*ema 6

D2010中的错误相同,因此D2010的泛型修复程序没有解决这个问题.这是一个错误:http://qc.embarcadero.com/wc/qcmain.aspx?d = 79747

已在Build 15.0.3863.33207中修复.我认为是XE

关于此问题的另一个问题是:http://qc.embarcadero.com/wc/qcmain.aspx?d = 78022,它涉及枚举并且仍处于打开状态.

顺便提一下,关于错误的文档并不是很清楚.看到:

E2506接口部分中声明的参数化类型的方法不得使用本地符号'%s'

它涉及泛型类中的类var,不能在类的构造函数中赋予文字(!)值,修复是参数化构造函数...不知道为什么,但我想它与编译器限制有关.