This commit is contained in:
Ivan Bondarev 2021-01-07 11:59:49 +01:00
parent 22f46b4a01
commit 499767fe5b
4 changed files with 46 additions and 1 deletions

View file

@ -0,0 +1,13 @@
type
c1<T1, T2> = class where T1: List<T2>;
end;
c2<T2, T3> = class(c1<T2, T3>) where T3: List<T2>;
end;
begin
new c2<List<string>, string>;
end.

18
TestSuite/where16.pas Normal file
View file

@ -0,0 +1,18 @@
type
c1<T1> = class where T1: c1<T1>;
end;
//Ошибка: Несоответствие спецификатора whеre спецификатору where базового класса
c2<T2> = class(c1<T2>) where T2: c1<T2>;
end;
c3 = class(c1<c3>)
end;
begin
new c2<c3>;
new c3;
end.

13
TestSuite/where17.pas Normal file
View file

@ -0,0 +1,13 @@
type
c1<T1, T2> = class where T1: List<T2>;
end;
c2<T2, T3> = class(c1<T2, T3>) where T2: List<T3>;
end;
begin
new c2<List<string>, string>;
end.

View file

@ -12589,8 +12589,9 @@ namespace PascalABCCompiler.TreeConverter
AddError(ctn.loc, "WHERE_SPECIFIER_MISMATCH"); AddError(ctn.loc, "WHERE_SPECIFIER_MISMATCH");
if (t.methods.Length > thist.methods.Length) if (t.methods.Length > thist.methods.Length)
AddError(ctn.loc, "WHERE_SPECIFIER_MISMATCH"); AddError(ctn.loc, "WHERE_SPECIFIER_MISMATCH");
if (t.base_type != SystemLibrary.SystemLibrary.object_type && t.base_type != thist.base_type) if (t.base_type != SystemLibrary.SystemLibrary.object_type && !type_table.is_type_or_original_generics_equal(t.base_type as type_node, thist.base_type as type_node))
AddError(ctn.loc, "WHERE_SPECIFIER_MISMATCH"); AddError(ctn.loc, "WHERE_SPECIFIER_MISMATCH");
} }
} }
} }