#2510
This commit is contained in:
Ivan Bondarev 2021-10-05 20:45:56 +02:00
parent d963ccdfa9
commit 72a49dc833
3 changed files with 61 additions and 0 deletions

View file

@ -0,0 +1,27 @@
var i: integer;
type
t1<T> = class
procedure p0;
begin
i := 1;
end;
end;
// Обязательно промежуточный класс между t1 и t3
t2<T> = partial class(t1<T>) end;
// Обязательно t3 НЕ шаблонный
t3 = partial class(t2<byte>)
end;
// Обязательно объявить t2 и t3 дважды
t2<T> = partial class(t1<T>) end;
t3 = partial class(t2<byte>)
// Обязательно вызвать p0 из второго тела t3
procedure p1 := self.p0;
end;
begin
t3.Create.p1;
assert(i = 1);
end.

View file

@ -0,0 +1,33 @@

var i: integer;
type
t0<T> = class end;
function f0<T>(q: t0<T>): T;
begin
Result := default(T);
i := 1;
end;
type
t1<T> = partial class end;
t2<T> = partial class(t0<t1<T>>) end;
t1<T> = partial class
// Обязательно как угодно использовать t2<T>, имено с <T>
v0: t2<T>;
end;
t2<T> = partial class(t0<t1<T>>) end;
t1<T> = partial class
//Ошибка: Нельзя преобразовать тип t1<T> к t1<T>
function f1: t1<T> := f0(default(t2<T>));
end;
begin
var o := new t1<integer>;
var o2 := o.f1;
assert(o2 = nil);
assert(i = 1);
end.

View file

@ -3787,6 +3787,7 @@ namespace PascalABCCompiler.TreeConverter
if (type_instances != null)
foreach (generic_type_instance_info gti in type_instances)
{
if (!(gti.pseudo_instance.base_type != null && context.converted_type.IsPartial))
gti.pseudo_instance.SetBaseType(tn);
}
}