fix #2338
This commit is contained in:
parent
ca19b334fc
commit
b665b1f811
25
TestSuite/lambdas_static_events.pas
Normal file
25
TestSuite/lambdas_static_events.pas
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
type
|
||||
t1 = static class
|
||||
static event ev1: ()->();
|
||||
|
||||
static procedure p1;
|
||||
begin
|
||||
var p := procedure->
|
||||
begin
|
||||
|
||||
ev1();
|
||||
|
||||
end;
|
||||
p;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
begin
|
||||
var i := 0;
|
||||
t1.ev1 += procedure() -> begin
|
||||
Inc(i);
|
||||
end;
|
||||
t1.p1;
|
||||
assert(i = 1);
|
||||
end.
|
||||
|
|
@ -262,6 +262,11 @@ namespace TreeConverter.LambdaExpressions.Closure
|
|||
dn = new dot_node(getClassIdent(commonMethodNode.cont_type),
|
||||
new ident(id.name, id.source_context), id.source_context);
|
||||
}
|
||||
else if (si.sym_info is common_event commonEvent && commonEvent.is_static)
|
||||
{
|
||||
dn = new dot_node(getClassIdent(commonEvent.cont_type),
|
||||
new ident(id.name, id.source_context), id.source_context);
|
||||
}
|
||||
else
|
||||
{
|
||||
dn = new dot_node(new ident("self", id.source_context), new ident(id.name, id.source_context), id.source_context);
|
||||
|
|
|
|||
|
|
@ -9212,8 +9212,13 @@ namespace PascalABCCompiler.TreeConverter
|
|||
private expression_node create_static_expression(type_node tn, SyntaxTree.ident id_right,
|
||||
List<SymbolInfo> si_right)
|
||||
{
|
||||
definition_node dn = context.check_name_node_type(id_right.name, si_right?.FirstOrDefault(), get_location(id_right), general_node_type.variable_node,
|
||||
general_node_type.function_node, general_node_type.property_node, general_node_type.constant_definition);
|
||||
definition_node dn = null;
|
||||
if (si_right?.FirstOrDefault().sym_info is common_event && (si_right?.FirstOrDefault().sym_info as common_event).cont_type == tn)
|
||||
dn = context.check_name_node_type(id_right.name, si_right?.FirstOrDefault(), get_location(id_right), general_node_type.variable_node,
|
||||
general_node_type.function_node, general_node_type.property_node, general_node_type.constant_definition, general_node_type.event_node);
|
||||
else
|
||||
dn = context.check_name_node_type(id_right.name, si_right?.FirstOrDefault(), get_location(id_right), general_node_type.variable_node,
|
||||
general_node_type.function_node, general_node_type.property_node, general_node_type.constant_definition);
|
||||
switch (dn.general_node_type)
|
||||
{
|
||||
case general_node_type.variable_node:
|
||||
|
|
@ -9279,6 +9284,12 @@ namespace PascalABCCompiler.TreeConverter
|
|||
check_property_no_params(pn, lloc);
|
||||
return create_static_method_call(fn, lloc, tn, false);
|
||||
}
|
||||
case general_node_type.event_node:
|
||||
{
|
||||
|
||||
static_event_reference ser = new static_event_reference((event_node)dn, get_location(id_right));
|
||||
return ser;
|
||||
}
|
||||
}
|
||||
throw new CompilerInternalError("Error in creating static expression.");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue