This commit is contained in:
Ivan Bondarev 2021-04-11 11:54:18 +02:00
parent daca8873cb
commit 1b611fd47f
6 changed files with 80 additions and 8 deletions

View file

@ -0,0 +1,8 @@
type
t1 = abstract class(System.Collections.IEnumerator)
// Падает только если НЕ указать System.Collections
public property IEnumerator.Current: object read nil;
end;
begin end.

View file

@ -0,0 +1,8 @@
type
t1 = abstract class(System.Collections.IEnumerator)
// Падает только если НЕ указать System.Collections
public property System.Collections<integer>.IEnumerator.Current: object read nil;
end;
begin end.

View file

@ -0,0 +1,7 @@
type
t1<T> = abstract class(System.Collections.Generic.IEnumerator<T>)
public property IEnumerator<integer>.Current: integer read 2;
end;
begin end.

View file

@ -0,0 +1,8 @@
type
t1 = abstract class(System.Collections.IEnumerator)
public property System.Collections.IEnumerator<integer>.Current: object read nil;
end;
begin end.

View file

@ -0,0 +1,26 @@
type
t1<T> = class(System.Collections.Generic.IEnumerator<T>)
public property IEnumerator<T>.Current: T read T(object(2));
public property System.Collections.IEnumerator.Current: object read 3;
public function System.Collections.IEnumerator.MoveNext: boolean;
begin
end;
public procedure System.Collections.IEnumerator.Reset;
begin
end;
public procedure System.IDisposable.Dispose;
begin
end;
end;
begin
var obj := new t1<integer>;
assert((obj as IEnumerator<integer>).Current = 2);
assert(integer((obj as System.Collections.IEnumerator).Current) = 3);
end.

View file

@ -4279,19 +4279,34 @@ namespace PascalABCCompiler.TreeConverter
AddError(new NameCannotHaveGenericParameters(_simple_property.property_name.ln[i].name, get_location(_simple_property.property_name.ln[i])));
var ntr = new SyntaxTree.named_type_reference();
if (_simple_property.property_name.ln[_simple_property.property_name.ln.Count - 1] is template_type_name)
{
template_type_reference ttr = new template_type_reference();
ttr.params_list = new template_param_list();
ttr.params_list.source_context = _simple_property.property_name.ln[_simple_property.property_name.ln.Count - 1].source_context;
foreach (ident id in (_simple_property.property_name.ln[_simple_property.property_name.ln.Count - 1] as template_type_name).template_args.idents)
ttr.params_list.params_list.Add(new named_type_reference(id.name, id.source_context));
for (var i = 0; i < _simple_property.property_name.ln.Count; i++)
{
ntr.Add(_simple_property.property_name.ln[i]);
}
ttr.name = ntr;
ttr.source_context = _simple_property.property_name.source_context;
ntr = ttr;
}
else
for (var i = 0; i < _simple_property.property_name.ln.Count; i++)
{
ntr.Add(new ident(_simple_property.property_name.ln[i].name+
(_simple_property.property_name.ln[i] is template_type_name ? "`"+(_simple_property.property_name.ln[i] as template_type_name).template_args.Count :""), _simple_property.property_name.ln[i].source_context));
ntr.Add(_simple_property.property_name.ln[i]);
}
type_node tn = find_type(ntr, get_location(_simple_property.property_name));
List<SymbolInfo> sil = context.find_definition_node(ntr, get_location(_simple_property.property_name), true);
if (!(sil[0].sym_info as type_node).IsInterface)
if (!tn.IsInterface)
AddError(get_location(_simple_property.property_name), "EXPECTED_INTERFACE");
name = (sil[0].sym_info as type_node).BaseFullName + "." + name;
expl_interface = sil[0].sym_info as type_node;
sil = expl_interface.find_in_type(_simple_property.property_name.name);
name = tn.BaseFullName + "." + name;
expl_interface = tn;
List<SymbolInfo> sil = expl_interface.find_in_type(_simple_property.property_name.name);
if (sil == null)
AddError(new MemberIsNotDeclaredInType(_simple_property.property_name, get_location(_simple_property.property_name), expl_interface));
if (!(sil[0].sym_info is property_node))