bug fix #804
This commit is contained in:
parent
449563bc1b
commit
aed5af2618
|
|
@ -4225,6 +4225,8 @@ namespace CodeCompletion
|
|||
_foreach_stmt.in_what.visit(this);
|
||||
if (returned_scope != null)
|
||||
returned_scope = returned_scope.GetElementType();
|
||||
if (returned_scope == null)
|
||||
returned_scope = TypeTable.obj_type;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4239,7 +4239,21 @@ namespace CodeCompletion
|
|||
public override TypeScope GetElementType()
|
||||
{
|
||||
if (elementType != null) return elementType;
|
||||
if (baseScope != null) return baseScope.GetElementType();
|
||||
TypeScope elem_ts = null;
|
||||
if (baseScope != null)
|
||||
{
|
||||
elem_ts = baseScope.GetElementType();
|
||||
if (elem_ts != null)
|
||||
return elem_ts;
|
||||
}
|
||||
|
||||
if (implemented_interfaces != null)
|
||||
foreach (TypeScope ts in implemented_interfaces)
|
||||
{
|
||||
elem_ts = ts.GetElementType();
|
||||
if (elem_ts != null)
|
||||
return elem_ts;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
14
TestSuite/intellisense_tests/foreach2.pas
Normal file
14
TestSuite/intellisense_tests/foreach2.pas
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
type
|
||||
t1 = class(System.Collections.Generic.IEnumerable<real>)
|
||||
end;
|
||||
|
||||
t2 = class(System.Collections.IEnumerable)
|
||||
public function GetEnumerator: System.Collections.IEnumerator := Arr(new object).GetEnumerator;
|
||||
end;
|
||||
|
||||
begin
|
||||
foreach var o{@var o: real;@} in new t1 do
|
||||
writeln(o.GetType);
|
||||
foreach var o{@var o: Object;@} in new t2 do
|
||||
writeln(o.GetType);
|
||||
end.
|
||||
14
TestSuite/intellisense_tests/foreach3.pas
Normal file
14
TestSuite/intellisense_tests/foreach3.pas
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
function test: sequence of char;
|
||||
begin
|
||||
yield 'a';
|
||||
end;
|
||||
|
||||
function test2<T>: sequence of array of T;
|
||||
begin
|
||||
yield new T[2];
|
||||
end;
|
||||
begin
|
||||
foreach var c in test do
|
||||
writeln(c{@var c: char;@});
|
||||
foreach var o{@var o: array of real;@} in test2&<real> do;
|
||||
end.
|
||||
|
|
@ -5401,7 +5401,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
sil = nsn.find(id_right.name);
|
||||
if (templ_args_count != 0)
|
||||
{
|
||||
SymbolInfo conv = ConvertTypeToInstance(sil.FirstOrDefault(), iwt.template_params.params_list, get_location(id_right));
|
||||
SymbolInfo conv = ConvertTypeToInstance(sil?.FirstOrDefault(), iwt.template_params.params_list, get_location(id_right));
|
||||
if (conv != null)
|
||||
{
|
||||
sil = new List<SymbolInfo> { conv };
|
||||
|
|
|
|||
Loading…
Reference in a new issue