From 0435ec3f5adaed2ba5ffc63183928b970c8e9020 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: Wed, 18 Jul 2018 20:57:58 +0200 Subject: [PATCH] fixed fix #974 --- CodeCompletion/DomSyntaxTreeVisitor.cs | 20 +++++++++++++------- NETGenerator/NETGenerator.cs | 4 ++-- TestSuite/generics20.pas | 14 +++++++------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/CodeCompletion/DomSyntaxTreeVisitor.cs b/CodeCompletion/DomSyntaxTreeVisitor.cs index 030d8e6d9..bc3742967 100644 --- a/CodeCompletion/DomSyntaxTreeVisitor.cs +++ b/CodeCompletion/DomSyntaxTreeVisitor.cs @@ -4881,11 +4881,10 @@ namespace CodeCompletion } public override void visit(ident_with_templateparams node) { + bool tmp_search_all = search_all; node.name.visit(this); - if ((search_all || returned_scope == null) && returned_scopes.Count > 0) + if ((tmp_search_all || returned_scope == null) && returned_scopes.Count > 0) { - ProcScope ps = returned_scopes[0] as ProcScope; - TypeScope ts = returned_scopes[0] as TypeScope; List template_params = new List(); foreach (type_definition td in node.template_params.params_list) { @@ -4897,10 +4896,17 @@ namespace CodeCompletion return; } } - if (ps != null) - returned_scopes[0] = ps.GetInstance(template_params); - else - returned_scopes[0] = ts.GetInstance(template_params); + for (int i = 0; i < returned_scopes.Count; i++) + { + ProcScope ps = returned_scopes[i] as ProcScope; + TypeScope ts = returned_scopes[i] as TypeScope; + + if (ps != null) + returned_scopes[i] = ps.GetInstance(template_params); + else + returned_scopes[i] = ts.GetInstance(template_params); + } + } else if (returned_scope is ProcScope) { diff --git a/NETGenerator/NETGenerator.cs b/NETGenerator/NETGenerator.cs index e50552d75..a6847b398 100644 --- a/NETGenerator/NETGenerator.cs +++ b/NETGenerator/NETGenerator.cs @@ -6853,9 +6853,9 @@ namespace PascalABCCompiler.NETGenerator il.EmitCall(OpCodes.Call, mi, null); if (tmp_dot) { - if (mi.ReturnType.IsValueType && !NETGeneratorTools.IsPointer(mi.ReturnType)) + if (value.type.is_value_type && !NETGeneratorTools.IsPointer(mi.ReturnType)) { - LocalBuilder lb = il.DeclareLocal(mi.ReturnType); + LocalBuilder lb = il.DeclareLocal(helper.GetTypeReference(value.type).tp); il.Emit(OpCodes.Stloc, lb); il.Emit(OpCodes.Ldloca, lb); } diff --git a/TestSuite/generics20.pas b/TestSuite/generics20.pas index 8283b295a..bd416fd40 100644 --- a/TestSuite/generics20.pas +++ b/TestSuite/generics20.pas @@ -1,14 +1,14 @@ function Deconstruct(d: Dictionary): (K, V); begin - //var kk := d.First.Key; - //var vv := d.First.Value; - //Result := (kk, vv); + var kk := d.First.Key; + var vv := d.First.Value; + Result := (kk, vv); end; begin var d := new Dictionary; - //d[1] := 2; - //var t := Deconstruct(d); - //assert(t.Item1 = 1); - //assert(t.Item2 = 2); + d[1] := 2; + var t := Deconstruct(d); + assert(t.Item1 = 1); + assert(t.Item2 = 2); end. \ No newline at end of file