fix #2310
This commit is contained in:
parent
34ddecdbd3
commit
e3febac2b8
23
TestSuite/lambda_capture_compiled_props.pas
Normal file
23
TestSuite/lambda_capture_compiled_props.pas
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
{$reference PresentationFramework.dll}
|
||||
{$apptype windows}
|
||||
var i: integer;
|
||||
|
||||
type
|
||||
t1 = class(System.Windows.Window)
|
||||
|
||||
procedure p1;
|
||||
begin
|
||||
var p := procedure->
|
||||
begin
|
||||
Dispatcher.Invoke(()->begin Inc(i) end);
|
||||
end;
|
||||
p;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
begin
|
||||
var o := new t1;
|
||||
o.p1;
|
||||
assert(i = 1);
|
||||
end.
|
||||
|
|
@ -226,14 +226,16 @@ namespace TreeConverter.LambdaExpressions.Closure
|
|||
var acceptableVarType = si.sym_info.semantic_node_type == semantic_node_type.local_variable ||
|
||||
si.sym_info.semantic_node_type == semantic_node_type.local_block_variable ||
|
||||
si.sym_info.semantic_node_type == semantic_node_type.common_parameter ||
|
||||
si.sym_info.semantic_node_type == semantic_node_type.class_field
|
||||
si.sym_info.semantic_node_type == semantic_node_type.class_field ||
|
||||
si.sym_info.semantic_node_type == semantic_node_type.basic_property_node
|
||||
;
|
||||
//trjuk, chtoby ne perelopachivat ves kod. zamenjaem ident na self.ident
|
||||
// Использую этот трюк для нестатических полей предков - они не захватываются из-за плохого алгоритма захвата
|
||||
// aab 12.06.19 begin
|
||||
// Добавил такое же переименование для статичесских полей класса. Теперь захват работает
|
||||
if ((si.sym_info.semantic_node_type == semantic_node_type.class_field || si.sym_info.semantic_node_type == semantic_node_type.common_method_node
|
||||
|| si.sym_info.semantic_node_type == semantic_node_type.common_event || si.sym_info.semantic_node_type == semantic_node_type.common_property_node) && InLambdaContext)
|
||||
|| si.sym_info.semantic_node_type == semantic_node_type.common_event || si.sym_info.semantic_node_type == semantic_node_type.common_property_node
|
||||
|| si.sym_info.semantic_node_type == semantic_node_type.basic_property_node) && InLambdaContext)
|
||||
{
|
||||
dot_node dn = null;
|
||||
// Поменял принцип добавления имени класса для статических полей и функций
|
||||
|
|
@ -325,7 +327,7 @@ namespace TreeConverter.LambdaExpressions.Closure
|
|||
}
|
||||
|
||||
|
||||
if (!(acceptableVarType) && InLambdaContext)
|
||||
if (!acceptableVarType && InLambdaContext)
|
||||
{
|
||||
_visitor.AddError(new ThisTypeOfVariablesCannotBeCaptured(_visitor.get_location(id)));
|
||||
return;
|
||||
|
|
|
|||
Loading…
Reference in a new issue