This commit is contained in:
Бондарев Иван 2017-11-26 14:36:02 +01:00
parent aec1606528
commit af1ac9b1c5
3 changed files with 15 additions and 4 deletions

View file

@ -1338,7 +1338,7 @@ namespace PascalABCCompiler.NETGenerator
{
ITypeNode ctn = fld.type;
TypeInfo ti = helper.GetTypeReference(ctn);
if (ctn is ICommonTypeNode && ti.tp.IsValueType && ti.tp is TypeBuilder)
if (ctn is ICommonTypeNode && ti.tp.IsValueType && ti.tp is TypeBuilder && tb != ti.tp)
{
BuildCloseTypeOrder((ICommonTypeNode)ctn, (TypeBuilder)ti.tp);
}
@ -1724,7 +1724,7 @@ namespace PascalABCCompiler.NETGenerator
cfn.type.type_special_kind == type_special_kind.binary_file ||
cfn.type.type_special_kind == type_special_kind.set_type))
return true;
if (cfn.type.type_special_kind == type_special_kind.record && cfn.type is ICommonTypeNode)
if (cfn.polymorphic_state != polymorphic_state.ps_static && cfn.type.type_special_kind == type_special_kind.record && cfn.type is ICommonTypeNode)
if (NeedAddCloneMethods(cfn.type as ICommonTypeNode))
return true;
}

11
TestSuite/records6.pas Normal file
View file

@ -0,0 +1,11 @@
type
r1=record
a: integer;
class Empty:r1;
end;
begin
var r: r1;
r.a := 2;
assert(r1.Empty.a = 0);
end.

View file

@ -15185,7 +15185,7 @@ namespace PascalABCCompiler.TreeConverter
check_for_type_allowed(tn,get_location(_var_def_statement.vars_type));
if (_var_def_statement.vars_type is function_header || _var_def_statement.vars_type is procedure_header)
check_delegate_on_generic_parameters(tn as common_type_node, get_location(_var_def_statement.vars_type));
if (context.converting_block() == block_type.type_block && context.converted_type.is_value_type)
if (context.converting_block() == block_type.type_block && context.converted_type.is_value_type && _var_def_statement.var_attr != SyntaxTree.definition_attribute.Static)
CheckForCircuralInRecord(tn, get_location(_var_def_statement.vars_type));
if (_var_def_statement.inital_value != null)
if (is_event) AddError(new NotSupportedError(get_location(_var_def_statement.inital_value)));
@ -15206,7 +15206,7 @@ namespace PascalABCCompiler.TreeConverter
tn = inital_value.type;
if (tn is null_type_node)
AddError(cn.location, "CAN_NOT_DEDUCE_TYPE_{0}", tn.name);
if (context.converting_block() == block_type.type_block && context.converted_type.is_value_type)
if (context.converting_block() == block_type.type_block && context.converted_type.is_value_type && _var_def_statement.var_attr != SyntaxTree.definition_attribute.Static)
CheckForCircuralInRecord(tn, get_location(_var_def_statement));
}
if (inital_value != null && inital_value is typed_expression)