diff --git a/NETGenerator/NETGenerator.cs b/NETGenerator/NETGenerator.cs index a6847b398..77479434b 100644 --- a/NETGenerator/NETGenerator.cs +++ b/NETGenerator/NETGenerator.cs @@ -6919,7 +6919,11 @@ namespace PascalABCCompiler.NETGenerator { il.Emit(OpCodes.Box, helper.GetTypeReference(value.obj.conversion_type).tp); } - else if (value.obj.type.is_value_type && !(value.obj is IAddressedExpressionNode) && !(value.obj is IThisNode) && !(value.obj is ICommonMethodCallNode) && !(value.obj is ICommonStaticMethodCallNode) && !(value.obj is ICommonConstructorCall) && !(value.obj is ICommonNamespaceFunctionCallNode) && !(value.obj is ICommonNestedInFunctionFunctionCallNode)) + else if (value.obj.type.is_value_type && !(value.obj is IAddressedExpressionNode) && !(value.obj is IThisNode) + && !(value.obj is ICommonMethodCallNode) && !(value.obj is ICommonStaticMethodCallNode) + && !(value.obj is ICommonConstructorCall) && !(value.obj is ICommonNamespaceFunctionCallNode) + && !(value.obj is ICommonNestedInFunctionFunctionCallNode) + && !(value.obj.conversion_type != null && !value.obj.conversion_type.is_value_type)) { LocalBuilder lb = il.DeclareLocal(helper.GetTypeReference(value.obj.type).tp); il.Emit(OpCodes.Stloc, lb); diff --git a/TestSuite/records11.pas b/TestSuite/records11.pas new file mode 100644 index 000000000..871d3729d --- /dev/null +++ b/TestSuite/records11.pas @@ -0,0 +1,22 @@ +type + r1 = record + + public X, Y: integer; + + public constructor create(X, Y: integer); + begin + self.X := X; + self.Y := Y; + end; + + public function f1 := self.X; + + end; + +begin + var o:object := new r1(1,2); + assert(r1(o).f1 = 1); + assert(r1(o).ToString() = 'records11.r1'); + o := DateTime.Now; + assert(DateTime(o).Kind = DateTime.Now.Kind); +end. \ No newline at end of file