From 07d35c674a79e79ac3dd8a6cff698cd1031e65af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=BE=D0=BD=D0=B4=D0=B0=D1=80=D0=B5=D0=B2=20=D0=98?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD?= Date: Mon, 11 Sep 2017 21:06:16 +0200 Subject: [PATCH] bug fix #485 --- CodeCompletion/SymTable.cs | 3 ++- TestSuite/extensionmethods22.pas | 13 +++++++++++++ TreeConverter/TreeRealization/types.cs | 13 +++++++++---- 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 TestSuite/extensionmethods22.pas diff --git a/CodeCompletion/SymTable.cs b/CodeCompletion/SymTable.cs index 7e01c61fc..bf477a073 100644 --- a/CodeCompletion/SymTable.cs +++ b/CodeCompletion/SymTable.cs @@ -443,7 +443,8 @@ namespace CodeCompletion public void AddUsedUnit(SymScope unit) { - used_units.Add(unit); + if (!hasUsesCycle(unit)) + used_units.Add(unit); } public virtual string GetFullName() diff --git a/TestSuite/extensionmethods22.pas b/TestSuite/extensionmethods22.pas new file mode 100644 index 000000000..a1c076598 --- /dev/null +++ b/TestSuite/extensionmethods22.pas @@ -0,0 +1,13 @@ +type BallInfo = class + x: integer; +end; + +begin + var a : array of BallInfo; + a := new BallInfo[2](new BallInfo, new BallInfo); + var s := 0; + a[0].x := 1; + a[1].x := 2; + a.ForEach(x->begin s += x.x end); + assert(s = 3); +end. \ No newline at end of file diff --git a/TreeConverter/TreeRealization/types.cs b/TreeConverter/TreeRealization/types.cs index 306343e3a..3d64b32bf 100644 --- a/TreeConverter/TreeRealization/types.cs +++ b/TreeConverter/TreeRealization/types.cs @@ -1963,15 +1963,20 @@ namespace PascalABCCompiler.TreeRealization { return base_generic_instance.ConvertSymbolInfo(si); } - else if (si == null) + else //if (si == null) { if (ImplementingInterfaces != null) { foreach (type_node ii_tn in ImplementingInterfaces) { - si = ii_tn.find_in_type(name, CurrentScope); - if (si != null) - return si; + SymbolInfoList isi = ii_tn.find_in_type(name, CurrentScope); + if (isi != null) + { + if (si == null) + si = isi; + else + si.Add(isi); + } } } }