This commit is contained in:
Ivan Bondarev 2024-08-13 14:43:49 +02:00
parent e3ee0fed4c
commit 4f0b0f8ba0
2 changed files with 13 additions and 1 deletions

View file

@ -8268,7 +8268,7 @@ namespace PascalABCCompiler.NETGenerator
private bool EmitBox(IExpressionNode from, Type LocalType)
{
if ((from.type.is_value_type || from.type.is_generic_parameter) && !(from is SemanticTree.INullConstantNode) && (LocalType == TypeFactory.ObjectType || TypeIsInterface(LocalType)))
if ((from.type.is_value_type || from.type.is_generic_parameter) && !(from is SemanticTree.INullConstantNode) && (LocalType == TypeFactory.ObjectType || TypeIsInterface(LocalType) || LocalType == TypeFactory.EnumType))
{
il.Emit(OpCodes.Box, helper.GetTypeReference(from.type).tp);//упаковка
return true;

12
TestSuite/enum10.pas Normal file
View file

@ -0,0 +1,12 @@
type
Days = (mon,Tue,Wed,Thi,Fri,Sat,Sun);
procedure MyPrint(obj: object);
begin
assert(obj.ToString() = 'Fri');
end;
begin
var en: System.Enum;
en := fri;
MyPrint(en);
end.