This commit is contained in:
Ivan Bondarev 2021-06-27 11:15:22 +02:00
parent e4a0a33d3e
commit bccd68f6bc
2 changed files with 6 additions and 2 deletions

View file

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

4
TestSuite/boxing5.pas Normal file
View file

@ -0,0 +1,4 @@
begin
var seg := System.ArraySegment&<integer>.Create(new integer[3](2,3,4), 0, 2);
assert(seg.Sum = 5);
end.