私は Delphi 2009 Trial をチェックしていますが、すぐにジェネリック関連の問題に遭遇します。
次のコードはコンパイルされず、Equals() メソッドで E2015 が返される理由がまったくわかりません。
type
TPrimaryKey<T> = class(TObject)
strict private
fValue: T;
public
constructor Create(AValue: T);
function Equals(Obj: TObject): boolean; override;
function GetValue: T;
end;
constructor TPrimaryKey<T>.Create(AValue: T);
begin
inherited Create;
fValue := AValue;
end;
function TPrimaryKey<T>.Equals(Obj: TObject): boolean;
begin
Result := (Obj <> nil) and (Obj is TPrimaryKey<T>)
and (TPrimaryKey<T>(Obj).GetValue = fValue);
end;
function TPrimaryKey<T>.GetValue: T;
begin
Result := fValue;
end;
fValue と GetValue() の結果を比較できないとコンパイラが判断するのはなぜですか?