This commit is contained in:
Бондарев Иван 2020-08-16 19:23:58 +02:00
parent 70c2755ea1
commit 9071a4786a
2 changed files with 34 additions and 1 deletions

22
TestSuite/generics40.pas Normal file
View file

@ -0,0 +1,22 @@
var i: integer;
type
t1<T> = class;
t0 = class
public function f1<T>: t1<T> := nil;
end;
t1<T> = class(t0) end;
procedure p1<T>(q: t1<T>);
begin
Inc(i);
end;
procedure p1(q: t0) := p1(q.f1&<byte>);
begin
p1(new t0);
assert(i = 1);
end.

View file

@ -2088,7 +2088,18 @@ namespace PascalABCCompiler.TreeConverter
is_alone_method_defined, syntax_tree_visitor.context, loc, syntax_nodes_parameters);
if (inst == null)
{
set_of_possible_functions.RemoveAt(i);
try
{
inst = generic_convertions.DeduceFunction(func, parameters, true, syntax_tree_visitor.context, loc, syntax_nodes_parameters);
}
catch
{
}
if (inst == null)
set_of_possible_functions.RemoveAt(i);
else
set_of_possible_functions[i] = inst;
}
else
{