From 32616a72698aeed49ae31cdfead3fb05a619d73d Mon Sep 17 00:00:00 2001 From: Mikhalkovich Stanislav Date: Fri, 26 Jun 2020 14:07:44 +0300 Subject: [PATCH] fix #2180 --- Configuration/GlobalAssemblyInfo.cs | 2 +- Configuration/Version.defs | 4 ++-- Release/pabcversion.txt | 2 +- ReleaseGenerators/PascalABCNET_version.nsh | 2 +- TestSuite/CompilationSamples/SF.pas | 10 +++++++++ TestSuite/extSelf.pas | 21 +++++++++++++++++++ .../TreeConversion/syntax_tree_visitor.cs | 10 +++++++++ bin/Lib/SF.pas | 10 +++++++++ 8 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 TestSuite/extSelf.pas diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index ec0557875..4d406e51e 100644 --- a/Configuration/GlobalAssemblyInfo.cs +++ b/Configuration/GlobalAssemblyInfo.cs @@ -15,7 +15,7 @@ internal static class RevisionClass public const string Major = "3"; public const string Minor = "6"; public const string Build = "3"; - public const string Revision = "2528"; + public const string Revision = "2529"; public const string MainVersion = Major + "." + Minor; public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision; diff --git a/Configuration/Version.defs b/Configuration/Version.defs index 4171f3d4e..b5be3150e 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ -%COREVERSION%=3 -%REVISION%=2528 %MINOR%=6 +%REVISION%=2529 +%COREVERSION%=3 %MAJOR%=3 diff --git a/Release/pabcversion.txt b/Release/pabcversion.txt index 9baa8bf6d..e02212c86 100644 --- a/Release/pabcversion.txt +++ b/Release/pabcversion.txt @@ -1 +1 @@ -3.6.3.2528 +3.6.3.2529 diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index 61995384a..55e61c065 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.6.3.2528' +!define VERSION '3.6.3.2529' diff --git a/TestSuite/CompilationSamples/SF.pas b/TestSuite/CompilationSamples/SF.pas index 361ecd3a4..3f5893f72 100644 --- a/TestSuite/CompilationSamples/SF.pas +++ b/TestSuite/CompilationSamples/SF.pas @@ -39,6 +39,16 @@ function RlnR3 := ReadlnReal3; function RlnC3 := ReadlnChar3; function RlnS3 := ReadlnString3; +function RI4 := ReadInteger4; +function RR4 := ReadReal4; +function RC4 := ReadChar4; +function RS4 := ReadString4; + +function RlnI4 := ReadInteger4; +function RlnR4 := ReadlnReal4; +function RlnC4 := ReadlnChar4; +function RlnS4 := ReadlnString4; + function RAI(n: integer) := ReadArrInteger(n); function RAR(n: integer) := ReadArrReal(n); diff --git a/TestSuite/extSelf.pas b/TestSuite/extSelf.pas new file mode 100644 index 000000000..c6775639b --- /dev/null +++ b/TestSuite/extSelf.pas @@ -0,0 +1,21 @@ +// #2180 +type + t1 = class end; + +function f1(self: t1; x: integer): integer; extensionmethod; +begin + Result := x * x; +end; + +type + t2 = class(t1) + procedure test; + begin + Assert(f1(4)=16); + Assert(Self.f1(4)=16); + end; + end; + +begin + t2.Create.test; +end. diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index ed20d291a..1c5ef87ad 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -7303,6 +7303,16 @@ namespace PascalABCCompiler.TreeConverter //lroman// #endregion + // #2180 - в уникальной ситуации, когда из метода потомка вызывается метод расширения класса-предка добавлять Self (!) + // Это значит, что dereferencing_value - это идентификатор и sil состоит только (?) из методов расширения + if (_method_call.dereferencing_value is ident) + { + if (sil.Select(s=>s.sym_info).Where(s=>s is function_node).All(s => (s as function_node).is_extension_method)) + { + var en0 = convert_strong(new ident("Self")); + exprs.AddElementFirst(en0); + } + } expr_node = convertion_data_and_alghoritms.create_full_function_call(exprs, sil, mcloc, context.converted_type, context.top_function, proc_wait, _method_call.parameters?.expressions); } diff --git a/bin/Lib/SF.pas b/bin/Lib/SF.pas index 361ecd3a4..3f5893f72 100644 --- a/bin/Lib/SF.pas +++ b/bin/Lib/SF.pas @@ -39,6 +39,16 @@ function RlnR3 := ReadlnReal3; function RlnC3 := ReadlnChar3; function RlnS3 := ReadlnString3; +function RI4 := ReadInteger4; +function RR4 := ReadReal4; +function RC4 := ReadChar4; +function RS4 := ReadString4; + +function RlnI4 := ReadInteger4; +function RlnR4 := ReadlnReal4; +function RlnC4 := ReadlnChar4; +function RlnS4 := ReadlnString4; + function RAI(n: integer) := ReadArrInteger(n); function RAR(n: integer) := ReadArrReal(n);