From 59e1bfc8bca18ae839079ab024393e19874f693f Mon Sep 17 00:00:00 2001 From: miks1965 Date: Mon, 7 May 2018 14:21:01 +0300 Subject: [PATCH] tests for bug List IndexOf --- Configuration/GlobalAssemblyInfo.cs | 2 +- Configuration/Version.defs | 4 ++-- ReleaseGenerators/PascalABCNET_version.nsh | 2 +- TestSuite/inheritanceFromListInt.pas | 12 ++++++++++++ TestSuite/inheritanceFromListStudent.pas | 13 +++++++++++++ TreeConverter/TreeRealization/generics.cs | 2 ++ TreeConverter/TreeRealization/types.cs | 4 ++-- 7 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 TestSuite/inheritanceFromListInt.pas create mode 100644 TestSuite/inheritanceFromListStudent.pas diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index 98e4b3fc2..a97b28a4e 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 = "3"; public const string Build = "5"; - public const string Revision = "1662"; + public const string Revision = "1663"; 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 536ac6bf7..4ba5e671e 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ -%MINOR%=3 -%REVISION%=1662 %COREVERSION%=5 +%REVISION%=1663 +%MINOR%=3 %MAJOR%=3 diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index b3001b7cd..563a4c349 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.3.5.1662' +!define VERSION '3.3.5.1663' diff --git a/TestSuite/inheritanceFromListInt.pas b/TestSuite/inheritanceFromListInt.pas new file mode 100644 index 000000000..f2349a106 --- /dev/null +++ b/TestSuite/inheritanceFromListInt.pas @@ -0,0 +1,12 @@ +type + MyList = class(List) + public + end; + +begin + var l := new MyList; + l.Add(3); + l.Add(3); + l.Add(7); + Assert(l.IndexOf(7)=2); +end. \ No newline at end of file diff --git a/TestSuite/inheritanceFromListStudent.pas b/TestSuite/inheritanceFromListStudent.pas new file mode 100644 index 000000000..51a0b312d --- /dev/null +++ b/TestSuite/inheritanceFromListStudent.pas @@ -0,0 +1,13 @@ +type + Student = class + name: string; + end; + MyList = class(List) + public + end; + +begin + var l := new MyList; + l.Add(new Student); + Assert(l.IndexOf(l[0])=0); +end. \ No newline at end of file diff --git a/TreeConverter/TreeRealization/generics.cs b/TreeConverter/TreeRealization/generics.cs index 0d5c19e21..92dbe3126 100644 --- a/TreeConverter/TreeRealization/generics.cs +++ b/TreeConverter/TreeRealization/generics.cs @@ -1684,11 +1684,13 @@ namespace PascalABCCompiler.TreeRealization MethodInfo mi = instmeths[num];*/ + // SSM 2018.05.05 bug fix #664 var mdtok = cfn.method_info.MetadataToken; MethodInfo[] instmeths = ((compiled_type_node)inst_type)._compiled_type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance); MethodInfo mi = System.Array.Find(instmeths, m => m.MetadataToken == mdtok); + // SSM 2018.05.05 end bug fix #664 return compiled_function_node.get_compiled_method(mi); } diff --git a/TreeConverter/TreeRealization/types.cs b/TreeConverter/TreeRealization/types.cs index a63194237..1eaf44cbf 100644 --- a/TreeConverter/TreeRealization/types.cs +++ b/TreeConverter/TreeRealization/types.cs @@ -1943,8 +1943,8 @@ namespace PascalABCCompiler.TreeRealization { List sil = Scope.FindOnlyInType(name, CurrentScope);//:=,create,x - // SSM test!!! - if (base_type is compiled_generic_instance_type_node /*&& name == "IndexOf"*/) + // SSM 2018.04.05 + if (base_type is compiled_generic_instance_type_node) { //sil = (base_type as compiled_generic_instance_type_node).original_generic.find_in_type(name, CurrentScope); return sil;