fix #1993
This commit is contained in:
parent
828db9e1fb
commit
76f5a62572
16
TestSuite/lambda_closure_class_fields_8.pas
Normal file
16
TestSuite/lambda_closure_class_fields_8.pas
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
type
|
||||
t0<t> = class
|
||||
public static a1: byte := 2;
|
||||
end;
|
||||
t1 = class(t0<integer>)
|
||||
private procedure p1;
|
||||
begin
|
||||
var a2: word := 3;
|
||||
var pp1: ()->integer := ()-> a1 + a2;
|
||||
Assert(pp1=5);
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
t1.Create.p1
|
||||
end.
|
||||
|
|
@ -195,10 +195,29 @@ namespace TreeConverter.LambdaExpressions.Closure
|
|||
|| si.sym_info.semantic_node_type == semantic_node_type.common_event || si.sym_info.semantic_node_type == semantic_node_type.common_property_node) && InLambdaContext)
|
||||
{
|
||||
dot_node dn = null;
|
||||
if (si.sym_info.semantic_node_type == semantic_node_type.class_field && (si.sym_info as class_field).IsStatic
|
||||
|| si.sym_info.semantic_node_type == semantic_node_type.common_method_node && (si.sym_info as common_method_node).IsStatic)
|
||||
// Поменял принцип добавления имени класса для статических полей и функций
|
||||
Func<common_type_node, addressed_value> getClassIdent = (classNode) =>
|
||||
{
|
||||
dn = new dot_node(new ident(si.scope.Name.Remove(0, 6), id.source_context), new ident(id.name, id.source_context), id.source_context);
|
||||
if (classNode.name.Contains("<"))
|
||||
{
|
||||
var classIdent = new ident(classNode.name.Remove(classNode.name.IndexOf("<")));
|
||||
var templateParams = new template_param_list(classNode.instance_params.Select(x => x.name).Aggregate("", (acc, elem) => acc += elem));
|
||||
return new ident_with_templateparams(classIdent, templateParams);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ident(classNode.name);
|
||||
}
|
||||
};
|
||||
if (si.sym_info is class_field classField && classField.IsStatic)
|
||||
{
|
||||
dn = new dot_node(getClassIdent(classField.cont_type),
|
||||
new ident(id.name, id.source_context), id.source_context);
|
||||
}
|
||||
else if (si.sym_info is common_method_node commonMethodNode && commonMethodNode.IsStatic)
|
||||
{
|
||||
dn = new dot_node(getClassIdent(commonMethodNode.cont_type),
|
||||
new ident(id.name, id.source_context), id.source_context);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1869,8 +1869,20 @@ namespace PascalABCCompiler.TreeRealization
|
|||
{
|
||||
foreach (SymbolInfo si in start)
|
||||
{
|
||||
definition_node dnode = ConvertMember(si.sym_info);
|
||||
rez_si = new SymbolInfo(dnode, si.access_level, si.symbol_kind);
|
||||
// aab 13.06.19 begin
|
||||
// Поправил странное поведение для локальных переменных, у которых не generic тип
|
||||
// Исправление для #1993
|
||||
if (si.sym_info is local_block_variable variable && !variable.type.is_generic_parameter)
|
||||
{
|
||||
rez_si = si;
|
||||
}
|
||||
else
|
||||
{
|
||||
definition_node dnode = ConvertMember(si.sym_info);
|
||||
rez_si = new SymbolInfo(dnode, si.access_level, si.symbol_kind);
|
||||
rez_si.scope = si.scope;
|
||||
}
|
||||
// aab 13.06.19 end
|
||||
//Дополняем список SymbolInfo преобразованным значением
|
||||
if (rez_start == null)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue