projects
/
mono.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ebfae1e
)
[mcs] Adds workaround for repl enum declaration on .net SRE
author
Marek Safar
<marek.safar@gmail.com>
Wed, 26 Jul 2017 11:25:44 +0000
(13:25 +0200)
committer
Marek Safar
<marek.safar@gmail.com>
Wed, 26 Jul 2017 11:27:35 +0000
(13:27 +0200)
mcs/mcs/enum.cs
patch
|
blob
|
history
diff --git
a/mcs/mcs/enum.cs
b/mcs/mcs/enum.cs
index 3e1c3fc653091cd47f86df6b839d92c96a296127..8a2884023300f0e50657440dc14f89829759a0d2 100644
(file)
--- a/
mcs/mcs/enum.cs
+++ b/
mcs/mcs/enum.cs
@@
-22,10
+22,29
@@
using MetaType = System.Type;
using System.Reflection;
#endif
using System.Reflection;
#endif
-namespace Mono.CSharp {
+namespace Mono.CSharp
+{
public class EnumMember : Const
{
public class EnumMember : Const
{
+#if !STATIC
+ class MemberTypeDelegator : TypeDelegator
+ {
+ Type underlyingType;
+
+ public MemberTypeDelegator (Type delegatingType, Type underlyingType)
+ : base (delegatingType)
+ {
+ this.underlyingType = underlyingType;
+ }
+
+ public override Type GetEnumUnderlyingType ()
+ {
+ return underlyingType;
+ }
+ }
+#endif
+
class EnumTypeExpr : TypeExpr
{
public override TypeSpec ResolveAsType (IMemberContext ec, bool allowUnboundTypeArguments)
class EnumTypeExpr : TypeExpr
{
public override TypeSpec ResolveAsType (IMemberContext ec, bool allowUnboundTypeArguments)
@@
-85,8
+104,17
@@
namespace Mono.CSharp {
if (!ResolveMemberType ())
return false;
if (!ResolveMemberType ())
return false;
+ MetaType ftype = MemberType.GetMetaInfo ();
+#if !STATIC
+ //
+ // Workaround for .net SRE limitation which cannot define field of unbaked enum type
+ // which is how all enums are declared
+ //
+ ftype = new MemberTypeDelegator (ftype, ((Enum)Parent).UnderlyingType.GetMetaInfo ());
+#endif
+
const FieldAttributes attr = FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal;
const FieldAttributes attr = FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal;
- FieldBuilder = Parent.TypeBuilder.DefineField (Name,
MemberType.GetMetaInfo ()
, attr);
+ FieldBuilder = Parent.TypeBuilder.DefineField (Name,
ftype
, attr);
spec = new ConstSpec (Parent.Definition, this, MemberType, FieldBuilder, ModFlags, initializer);
Parent.MemberCache.AddMember (spec);
spec = new ConstSpec (Parent.Definition, this, MemberType, FieldBuilder, ModFlags, initializer);
Parent.MemberCache.AddMember (spec);