From d2440264e85de6f401b84eed643bbaba6c08db85 Mon Sep 17 00:00:00 2001 From: Mikhalkovich Stanislav Date: Wed, 25 Jun 2025 19:09:36 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=BD=D0=B5=D1=81=20?= =?UTF-8?q?=D0=B8=D0=B7=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BE=D0=BA=20=D0=BD?= =?UTF-8?q?=D0=B0=D0=B7=D0=B0=D0=B4=20=D0=B2=20=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=D1=8C=D0=BD=D1=8B=D0=B5.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Вернул странное недокументированное поведение присваивания обобщенной функции делегату --- TestSuite/delegates23.pas | 17 ++++++++++++++ TestSuite/delegates25.pas | 23 +++++++++++++++++++ .../convertion_data_and_alghoritms.cs | 10 +++++--- 3 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 TestSuite/delegates23.pas create mode 100644 TestSuite/delegates25.pas diff --git a/TestSuite/delegates23.pas b/TestSuite/delegates23.pas new file mode 100644 index 000000000..c5854ab41 --- /dev/null +++ b/TestSuite/delegates23.pas @@ -0,0 +1,17 @@ +var i: integer; + +procedure p0(p: byte->()); +begin + Inc(i); +end; +procedure p1(o: T); +begin + Inc(i); +end; + +begin + p0(p1&); + //Ошибка: Нельзя преобразовать тип procedure(o: T) к Action + p0(p1); + assert(i = 2); +end. \ No newline at end of file diff --git a/TestSuite/delegates25.pas b/TestSuite/delegates25.pas new file mode 100644 index 000000000..d2b1b58b3 --- /dev/null +++ b/TestSuite/delegates25.pas @@ -0,0 +1,23 @@ +var i: integer; + +procedure p0(p: byte->()); +begin + p(1); + Inc(i); +end; + +type + t1 = class + static procedure p1(o: T) := exit; + procedure p2(o: T) := exit; + end; + +begin + // OK + p0(t1.p1&); + p0(t1.Create.p2&); + // А эти 2 падают + p0(t1.p1); + p0(t1.Create.p2); + assert(i = 4); +end. \ No newline at end of file diff --git a/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs b/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs index 20fad8d10..9496911d9 100644 --- a/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs +++ b/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs @@ -1255,9 +1255,13 @@ namespace PascalABCCompiler.TreeConverter //issue #2161 - SSM 12.03.2020 //issue #348 - if ((formal_param_type == SystemLibrary.SystemLibrary.object_type || formal_param_type.IsDelegate) - && factparams[i].type is delegated_methods dm1 - && !dm1.proper_methods[0].function.is_generic_function) // SSM 23.06.2025 issue #3290 + if (formal_param_type == SystemLibrary.SystemLibrary.object_type + && factparams[i].type is delegated_methods dm1 + && !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(); ptci.first = null;