This commit is contained in:
Бондарев Иван 2018-09-16 13:36:39 +02:00
parent 9e9056aa46
commit 0636dd2ee0
2 changed files with 14 additions and 2 deletions

View file

@ -6859,7 +6859,10 @@ namespace PascalABCCompiler.NETGenerator
is_dot_expr = false; is_dot_expr = false;
EmitArguments(parameters, real_parameters); EmitArguments(parameters, real_parameters);
MethodInfo mi = value.compiled_method.method_info; MethodInfo mi = value.compiled_method.method_info;
if (value.compiled_method.comperehensive_type.is_value_type || !value.virtual_call && value.compiled_method.polymorphic_state == polymorphic_state.ps_virtual || value.compiled_method.polymorphic_state == polymorphic_state.ps_static) if (value.compiled_method.comperehensive_type.is_value_type ||
//value.compiled_method.comperehensive_type is ICompiledTypeNode && (value.compiled_method.comperehensive_type as ICompiledTypeNode).compiled_type == TypeFactory.EnumType ||
!value.virtual_call && value.compiled_method.polymorphic_state == polymorphic_state.ps_virtual ||
value.compiled_method.polymorphic_state == polymorphic_state.ps_static)
{ {
il.EmitCall(OpCodes.Call, mi, null); il.EmitCall(OpCodes.Call, mi, null);
} }
@ -7396,7 +7399,7 @@ namespace PascalABCCompiler.NETGenerator
//(ssyy) 07.12.2007 При боксировке нужно вызывать Ldsfld вместо Ldsflda. //(ssyy) 07.12.2007 При боксировке нужно вызывать Ldsfld вместо Ldsflda.
//Дополнительная проверка введена именно для этого. //Дополнительная проверка введена именно для этого.
bool box_awaited = bool box_awaited =
(ctn2 != null && ctn2.compiled_type == TypeFactory.ObjectType || tn2.IsInterface) && !(real_parameters[i] is SemanticTree.INullConstantNode) (ctn2 != null && (ctn2.compiled_type == TypeFactory.ObjectType || ctn2.compiled_type == TypeFactory.EnumType) || tn2.IsInterface) && !(real_parameters[i] is SemanticTree.INullConstantNode)
&& (ctn3.is_value_type || ctn3.is_generic_parameter); && (ctn3.is_value_type || ctn3.is_generic_parameter);
if (!box_awaited && (ctn2 != null && ctn2.compiled_type == TypeFactory.ObjectType || tn2.IsInterface) && !(real_parameters[i] is SemanticTree.INullConstantNode) if (!box_awaited && (ctn2 != null && ctn2.compiled_type == TypeFactory.ObjectType || tn2.IsInterface) && !(real_parameters[i] is SemanticTree.INullConstantNode)
&& ctn4 != null && ctn4.is_value_type) && ctn4 != null && ctn4.is_value_type)

9
TestSuite/enum4.pas Normal file
View file

@ -0,0 +1,9 @@
type
[System.FlagsAttribute]
TEnum = (X=1, Y=2);
begin
var enum := TEnum.X;
assert(enum.HasFlag(TEnum.X) = true);
assert(enum.HasFlag(TEnum.Y) = false);
end.