diff --git a/NETGenerator/NETGenerator.cs b/NETGenerator/NETGenerator.cs index ad5a64eee..8ac3d0f83 100644 --- a/NETGenerator/NETGenerator.cs +++ b/NETGenerator/NETGenerator.cs @@ -7136,9 +7136,9 @@ namespace PascalABCCompiler.NETGenerator ICompiledTypeNode ctn2 = parameters[i].type as ICompiledTypeNode; ITypeNode ctn3 = real_parameters[i].type; ITypeNode ctn4 = real_parameters[i].conversion_type; - if (ctn2 != null && !(real_parameters[i] is SemanticTree.INullConstantNode) && (ctn3.is_value_type || ctn3.is_generic_parameter) && ctn2.compiled_type == TypeFactory.ObjectType) + if (ctn2 != null && !(real_parameters[i] is SemanticTree.INullConstantNode) && (ctn3.is_value_type || ctn3.is_generic_parameter) && (ctn2.compiled_type == TypeFactory.ObjectType || ctn2.IsInterface)) il.Emit(OpCodes.Box, helper.GetTypeReference(ctn3).tp); - else if (ctn2 != null && !(real_parameters[i] is SemanticTree.INullConstantNode) && ctn4 != null && (ctn4.is_value_type || ctn4.is_generic_parameter) && ctn2.compiled_type == TypeFactory.ObjectType) + else if (ctn2 != null && !(real_parameters[i] is SemanticTree.INullConstantNode) && ctn4 != null && (ctn4.is_value_type || ctn4.is_generic_parameter) && (ctn2.compiled_type == TypeFactory.ObjectType || ctn2.IsInterface)) il.Emit(OpCodes.Box, helper.GetTypeReference(ctn4).tp); is_addr = false; } diff --git a/TestSuite/boxing5.pas b/TestSuite/boxing5.pas new file mode 100644 index 000000000..d746fef84 --- /dev/null +++ b/TestSuite/boxing5.pas @@ -0,0 +1,4 @@ +begin + var seg := System.ArraySegment&.Create(new integer[3](2,3,4), 0, 2); + assert(seg.Sum = 5); +end. \ No newline at end of file