Исправлено две ошибки foreach var, при которых не выводились типы

This commit is contained in:
miks1965 2016-02-22 12:30:17 +03:00
parent 7da241728d
commit 94c0db534a
8 changed files with 52 additions and 6 deletions

View file

@ -15,7 +15,7 @@ internal static class RevisionClass
public const string Major = "3";
public const string Minor = "1";
public const string Build = "0";
public const string Revision = "1172";
public const string Revision = "1173";
public const string MainVersion = Major + "." + Minor;
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;

View file

@ -1,4 +1,4 @@
%MINOR%=1
%REVISION%=1172
%COREVERSION%=0
%REVISION%=1173
%MINOR%=1
%MAJOR%=3

Binary file not shown.

View file

@ -1 +1 @@
!define VERSION '3.1.0.1172'
!define VERSION '3.1.0.1173'

17
TestSuite/foreachvar1.pas Normal file
View file

@ -0,0 +1,17 @@
{begin
var s := [1,2,3];
foreach var x in s do
begin
var y := x + x;
end;
end.}
type
TPair = auto class
Key: string;
Value: integer;
end;
begin
var A := Arr(new TPair('a',3),new TPair('c',1),new TPair('b',4));
foreach var p in A do
writeln(p.Key, '->', p.Value);
end.

View file

@ -0,0 +1,7 @@
begin
var s := [1,2,3];
foreach var x in s do
begin
var y := x + x;
end;
end.

View file

@ -16179,6 +16179,7 @@ namespace PascalABCCompiler.TreeConverter
// IEnumerable<integer>, Range(1,10), Dictionary<string,integer>: tn = compiled_type_node
// IEnumerable<T>: tn = compiled_generic_instance_type_node
// FibGen = class(IEnumerable,IEnumerator): tn = common_type_node, en = compiled_type_node
// array of Person: tn = common_type_node
{
System.Type ct;
if (tn is compiled_type_node)
@ -16198,7 +16199,7 @@ namespace PascalABCCompiler.TreeConverter
r = ct.GetInterface(IEnTstring);
if (r != null)
{
Type arg1 = r.GetGenericArguments().First();
Type arg1 = r.GetGenericArguments().First(); // тип параметра IEnumerable
var str = arg1.GetGenericArguments().Count();
if (tn is compiled_type_node)
{
@ -16230,7 +16231,7 @@ namespace PascalABCCompiler.TreeConverter
}
else
{
if (tn.element_type != null) // значит, это массив любой размерности - 02.02.16 SSM
if (tn.element_type != null) // значит, это массив любой размерности - 02.02.16 SSM - еще может быть множество set of T - 22.02.16 SSM
{
elem_type = tn.element_type;
return true;
@ -16265,6 +16266,27 @@ namespace PascalABCCompiler.TreeConverter
{
if (tn == null || tn is null_type_node || tn.ImplementingInterfaces == null)
return false;
if (tn.element_type != null) // еще может быть множество set of T - 22.02.16 SSM
{
elem_type = tn.element_type;
return true;
}
foreach (SemanticTree.ITypeNode itn in tn.ImplementingInterfaces) // Ищем интерфейс IEnumerable<T> и возвращаем T в качестве elem_type
{
if (itn is compiled_generic_instance_type_node)
{
var itnc = (itn as compiled_generic_instance_type_node);
var tt = (itnc.original_generic as compiled_type_node).compiled_type;
if (tt == typeof(System.Collections.Generic.IEnumerable<>))
{
elem_type = itnc.generic_parameters[0] as common_type_node;
return true;
}
}
}
foreach (SemanticTree.ITypeNode itn in tn.ImplementingInterfaces)
{
//if (itn == ctn)

Binary file not shown.