Перенес из ошибок назад в правильные.
Вернул странное недокументированное поведение присваивания обобщенной функции делегату
This commit is contained in:
parent
da16d41c58
commit
d2440264e8
17
TestSuite/delegates23.pas
Normal file
17
TestSuite/delegates23.pas
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
var i: integer;
|
||||||
|
|
||||||
|
procedure p0(p: byte->());
|
||||||
|
begin
|
||||||
|
Inc(i);
|
||||||
|
end;
|
||||||
|
procedure p1<T>(o: T);
|
||||||
|
begin
|
||||||
|
Inc(i);
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
p0(p1&<byte>);
|
||||||
|
//Ошибка: Нельзя преобразовать тип procedure(o: T) к Action<byte>
|
||||||
|
p0(p1);
|
||||||
|
assert(i = 2);
|
||||||
|
end.
|
||||||
23
TestSuite/delegates25.pas
Normal file
23
TestSuite/delegates25.pas
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
var i: integer;
|
||||||
|
|
||||||
|
procedure p0(p: byte->());
|
||||||
|
begin
|
||||||
|
p(1);
|
||||||
|
Inc(i);
|
||||||
|
end;
|
||||||
|
|
||||||
|
type
|
||||||
|
t1 = class
|
||||||
|
static procedure p1<T>(o: T) := exit;
|
||||||
|
procedure p2<T>(o: T) := exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
// OK
|
||||||
|
p0(t1.p1&<byte>);
|
||||||
|
p0(t1.Create.p2&<byte>);
|
||||||
|
// А эти 2 падают
|
||||||
|
p0(t1.p1);
|
||||||
|
p0(t1.Create.p2);
|
||||||
|
assert(i = 4);
|
||||||
|
end.
|
||||||
|
|
@ -1255,9 +1255,13 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
|
|
||||||
//issue #2161 - SSM 12.03.2020
|
//issue #2161 - SSM 12.03.2020
|
||||||
//issue #348
|
//issue #348
|
||||||
if ((formal_param_type == SystemLibrary.SystemLibrary.object_type || formal_param_type.IsDelegate)
|
if (formal_param_type == SystemLibrary.SystemLibrary.object_type
|
||||||
&& factparams[i].type is delegated_methods dm1
|
&& factparams[i].type is delegated_methods dm1
|
||||||
&& !dm1.proper_methods[0].function.is_generic_function) // SSM 23.06.2025 issue #3290
|
&& !dm1.proper_methods[0].function.is_generic_function
|
||||||
|
||
|
||||||
|
formal_param_type.IsDelegate
|
||||||
|
&& factparams[i].type is delegated_methods
|
||||||
|
) // SSM 23.06.2025 issue #3290
|
||||||
{
|
{
|
||||||
possible_type_convertions ptci = new possible_type_convertions();
|
possible_type_convertions ptci = new possible_type_convertions();
|
||||||
ptci.first = null;
|
ptci.first = null;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue