在一些代碼我固定起來,這使得大量使用泛型和接口類型,我得到錯誤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