This commit is contained in:
parent
91096e39d1
commit
20c227ded1
18
TestSuite/units/u_staticconstr2.pas
Normal file
18
TestSuite/units/u_staticconstr2.pas
Normal 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.
|
||||
5
TestSuite/usesunits/use_staticconstr2.pas
Normal file
5
TestSuite/usesunits/use_staticconstr2.pas
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
uses u_staticconstr2;
|
||||
begin
|
||||
new t1<byte>;
|
||||
assert(t1&<byte>.i = 1);
|
||||
end.
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue