在一些代码我固定起来,这使得大量使用泛型和接口类型,我得到错误delphi编译错误E2134是什么意思?
E2134, Type '<void>' has no type info.
我相信这是因为我在一个重构的中间,其中一些深度嵌套组所有使用泛型的单元都不同步,但错误不会发生在我可以使用错误消息修复代码的地方,因为代码没有问题,错误出现的位置。
这里是上下文,嘲笑,因为我不能发布的代码中,有太多:
unit GenericThing;
...
interface
...
type
...
IThingListOf<ThingT> = interface(IThingContainer)
function getEnumerator: TEnumerator<ThingT>;
function getCount: Integer;
function getThing(Index: integer): ThingT;
function getFirst: ThingT;
function IndexOf(value: ThingT): integer;
function addItem(const Thing: ThingT): ThingT;
function removeItem(const Thing: ThingT): Integer;
procedure clear;
procedure Sort; overload;
procedure Sort(const AComparer: IComparer<ThingT>); overload;
property Count: integer read getCount;
property First: ThingT read getFirst;
property Items[Index: integer]: ThingT read getThing; default;
end;
// error appears on whatever line number comes after the declaration of IThingListOf<ThingT>...end;
function AnythingYouLikeHere:Integer; // there is nothign wrong with this line, but you get the E2134 here.
看来,问题出在IThingContainer本身:
IThingContainer = interface ...
...
procedure DoSomething(const Param);
end;
的在“const Param”之上没有类型信息。在我看来,这是一个奇怪的(腋下)帕斯卡尔/德尔福,你完全违反了沃斯的强打字理念。它与C中的“void *”指针类似,或Delphi中的“指针”类型,但除了像标准的pre-object-pascal RTL函数(如Move)之类的地方,它很少被使用上。在我看来,在泛型中使用的接口中的非类型化参数应该允许或不允许,但有时不允许,并且不允许其他时间。
这是1978年从2009年开始
BRILLIANT。谢谢。 – 2010-08-11 18:33:52