This commit is contained in:
Ivan Bondarev 2023-01-22 10:37:37 +01:00
parent 91df93410b
commit 22b77e38af
2 changed files with 16 additions and 1 deletions

View file

@ -838,7 +838,7 @@ namespace PascalABCCompiler.NETGenerator {
public bool IsConstructedGenericType(Type t)
{
if (t is TypeBuilder || t is GenericTypeParameterBuilder || t is EnumBuilder)
if (t is TypeBuilder || t is GenericTypeParameterBuilder || t is EnumBuilder || t.GetType().FullName == "System.Reflection.Emit.TypeBuilderInstantiation")
return true;
if (t.IsGenericType)
foreach (Type gt in t.GetGenericArguments())

15
TestSuite/foreach10.pas Normal file
View file

@ -0,0 +1,15 @@
type
// Обязательно пользовательский шаблонный тип
t1<T> = class end;
begin
// Обязательно массив
// foreach по "a.AsEnumerable" не падает
var a: array of t1<byte> := Arr(new t1<byte>);
var i := 0;
foreach var x in a do
begin
Inc(i);
end;
assert(i = 1);
end.