pascalabcnet/TestSuite/where22.pas
Ivan Bondarev 0e3a3c232e fix #2736
2023-12-28 11:24:30 +01:00

22 lines
567 B
ObjectPascal
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

type
t1<TSelf> = interface
where TSelf: t1<TSelf>;
function f: integer;
end;
//Ошибка: Невозможно инстанцировать, так как тип TSelf не реализует интерфейс t1<TSelf>
t2<TSelf> = interface(t1<TSelf>)
where TSelf: t2<TSelf>;
// А если так то работает:
// where TSelf: t1<TSelf>, t2<TSelf>;
end;
TClass = class(t2<TClass>)
public function f: integer;
begin
Result := 1;
end;
end;
begin
var obj := new TClass;
assert(obj.f = 1);
end.