【发布时间】:2019-03-12 08:41:06
【问题描述】:
下面的 Delphi 代码在 Foo 函数中没有编译错误,但 Foo2 函数编译。这让我发疯,有没有人有想法?
type
IA<T> = Interface
end;
TA<T> = class(TInterfacedObject, IA<T>)
function Foo<V> : IA<V>;
end;
TB<U,T> = class(TA<T>)
end;
TC = class
function Foo2<T,V> : IA<V>;
end;
implementation
{ TA<T> }
function TA<T>.Foo<V>: IA<V>;
begin
Result := TB<T,V>.Create;
end;
{ TC }
function TC.Foo2<T,V>: IA<V>;
begin
Result := TB<T,V>.Create;
end;
【问题讨论】: