This commit is contained in:
Ivan Bondarev 2024-03-27 20:51:01 +01:00
parent 98ecc8a608
commit 031f868124
2 changed files with 18 additions and 1 deletions

13
TestSuite/foreach14.pas Normal file
View file

@ -0,0 +1,13 @@
type c1 = class end;
var i := 0;
begin
var d := new Dictionary<c1, Action0>;
d.Add(new c1, ()->begin i := 1 end);
foreach var v in d.Values do
//Ошибка: Невозможно явно преобразовать тип c1 к типу System.Action
Action0(v).Invoke();
assert(i = 1);
end.

View file

@ -18469,7 +18469,11 @@ namespace PascalABCCompiler.TreeConverter
break;
}
}
if (elem_type == null)
if (ct.Name == "ValueCollection" && ct.IsNested && ct.GetGenericArguments().Length == 2)
{
elem_type = ip[1];
}
else if (elem_type == null)
elem_type = ip[0];
}