This commit is contained in:
parent
a1867f0421
commit
4f3fcec941
|
|
@ -14,8 +14,9 @@
|
|||
|
||||
c2<T1,T2> = class
|
||||
// Если объявить сначала "where T1" - тоже должно работать
|
||||
where T1: T2;
|
||||
where T2: IComparable<T1>;
|
||||
where T1: T2;
|
||||
|
||||
|
||||
function f1(o: T1): integer;
|
||||
begin
|
||||
|
|
@ -25,6 +26,20 @@
|
|||
|
||||
end;
|
||||
|
||||
c3<T1,T2> = class
|
||||
// Если объявить сначала "where T1" - тоже должно работать
|
||||
where T1: T2, System.ICloneable;
|
||||
where T2: IComparable<T1>;
|
||||
|
||||
|
||||
function f1(o: T1): integer;
|
||||
begin
|
||||
//Ошибка: Неизвестное имя 'CompareTo'
|
||||
var c := o.Clone();
|
||||
Result := o.CompareTo(o);
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
begin
|
||||
var a := new c1<string,string>;
|
||||
|
|
@ -32,4 +47,7 @@ begin
|
|||
|
||||
var b := new c2<string,string>;
|
||||
assert(b.f1('abc') = 0);
|
||||
|
||||
var c := new c3<string,string>;
|
||||
assert(c.f1('abc') = 0);
|
||||
end.
|
||||
|
|
@ -12984,9 +12984,10 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
if (ctn.base_type != null && ctn.base_type.is_generic_parameter && ctn.base_type.ImplementingInterfaces != null && ctn.base_type.ImplementingInterfaces.Count > 0)
|
||||
{
|
||||
foreach (type_node tn in ctn.ImplementingInterfaces)
|
||||
foreach (type_node tn in ctn.base_type.ImplementingInterfaces)
|
||||
{
|
||||
type_table.AddInterface(ctn, tn, null);
|
||||
InitInterfaceScope(ctn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue