This commit is contained in:
Ivan Bondarev 2021-10-24 11:45:19 +02:00
parent 91096e39d1
commit 20c227ded1
3 changed files with 28 additions and 2 deletions

View file

@ -0,0 +1,18 @@
unit u_staticconstr2;
type
t1<T> = partial class
static i: integer;
end;
t1<T> = partial class
static constructor;
begin
Inc(i);
end;
end;
begin
end.

View file

@ -0,0 +1,5 @@
uses u_staticconstr2;
begin
new t1<byte>;
assert(t1&<byte>.i = 1);
end.

View file

@ -3262,8 +3262,11 @@ namespace PascalABCCompiler.TreeConverter
visit_procedure_header(_constructor);
if (context.top_function != null)
{
(context.top_function as common_method_node).is_constructor = true;
(context.top_function as common_method_node).cont_type.static_constr = context.top_function as common_method_node;
common_method_node static_constr = context.top_function as common_method_node;
static_constr.is_constructor = true;
if (context.converted_type.IsPartial && context.converted_type.static_constr != null)//remove auto generated static constructor from partial class
context.converted_type.methods.RemoveElement(context.converted_type.static_constr);
static_constr.cont_type.static_constr = context.top_function as common_method_node;
}
return;
}