This commit is contained in:
Бондарев Иван 2018-08-06 14:12:13 +02:00
parent 2026576845
commit 8bb4617d68
2 changed files with 27 additions and 1 deletions

View file

@ -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);

22
TestSuite/records11.pas Normal file
View file

@ -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.