This commit is contained in:
Ivan Bondarev 2023-12-28 11:24:30 +01:00
parent 9721cf3c67
commit 0e3a3c232e
2 changed files with 35 additions and 2 deletions

22
TestSuite/where22.pas Normal file
View file

@ -0,0 +1,22 @@
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.

View file

@ -665,6 +665,17 @@ namespace PascalABCCompiler.TreeRealization
break; break;
} }
} }
else if (interf is common_generic_instance_type_node cictn && base_class is common_generic_instance_type_node cbctn)
{
foreach (type_node impltn in cictn.ImplementingInterfaces)
{
if (is_type_or_original_generics_equal(impltn, cbctn))
{
implements = true;
break;
}
}
}
else if (interf is compiled_type_node ictn && base_class is compiled_type_node bctn) else if (interf is compiled_type_node ictn && base_class is compiled_type_node bctn)
{ {
if (ictn.compiled_type.AssemblyQualifiedName != null && ictn.compiled_type.AssemblyQualifiedName == bctn.compiled_type.AssemblyQualifiedName) if (ictn.compiled_type.AssemblyQualifiedName != null && ictn.compiled_type.AssemblyQualifiedName == bctn.compiled_type.AssemblyQualifiedName)