为什么以类型作为键的 TDictionary 声明会引发内部 L2095 错误?
Why does the declaration of a TDictionary with a type as key throw an internal L2095 error?
有人知道为什么以下代码会引发内部 L2095 错误吗?
显然编译器有问题,字典的键是 class 类型。
有人知道解决方法吗?
(PS:当我不包含 TestDict := TDictTest.Create;
部分或当密钥不是 class 类型时,不会抛出错误)
TTestClass = class
end;
TTypeOfTestClass = type of TTestClass;
TDictTest = TDictionary<TTypeOfTestClass,Integer>;
var
TestDict: TDictTest;
implementation
initialization
TestDict := TDictTest.Create;
TestDict.Free
回答后添加:
显然这是关于我本能地使用“type of
”而不是“class of
”。 “Type of
”被编译器接受,因此造成混乱。
参考与此相关的问题:What "type of" declaration represents in Delphi and how can it be used
我什至认为 "type of ..." 是不允许的。使用
TTypeOfTestClass = class of TTestClass;
相反。
有人知道为什么以下代码会引发内部 L2095 错误吗?
显然编译器有问题,字典的键是 class 类型。
有人知道解决方法吗?
(PS:当我不包含 TestDict := TDictTest.Create;
部分或当密钥不是 class 类型时,不会抛出错误)
TTestClass = class
end;
TTypeOfTestClass = type of TTestClass;
TDictTest = TDictionary<TTypeOfTestClass,Integer>;
var
TestDict: TDictTest;
implementation
initialization
TestDict := TDictTest.Create;
TestDict.Free
回答后添加:
显然这是关于我本能地使用“type of
”而不是“class of
”。 “Type of
”被编译器接受,因此造成混乱。
参考与此相关的问题:What "type of" declaration represents in Delphi and how can it be used
我什至认为 "type of ..." 是不允许的。使用
TTypeOfTestClass = class of TTestClass;
相反。