2004-04-29 Martin Baulig <martin@ximian.com>
authorMartin Baulig <martin@novell.com>
Thu, 29 Apr 2004 16:06:52 +0000 (16:06 -0000)
committerMartin Baulig <martin@novell.com>
Thu, 29 Apr 2004 16:06:52 +0000 (16:06 -0000)
* class.cs (Event.Define): Don't emit the field and don't set
RTSpecialName and SpecialName for events on interfaces.  Fixes
#57703.

svn path=/trunk/mcs/; revision=26306

mcs/mcs/ChangeLog
mcs/mcs/class.cs

index abd7d2637d15f804280027521b4ee537786bb2e7..66e876c12558d7e41618cdbca77e1a2e6b1b0715 100755 (executable)
@@ -1,3 +1,9 @@
+2004-04-29  Martin Baulig  <martin@ximian.com>
+
+       * class.cs (Event.Define): Don't emit the field and don't set
+       RTSpecialName and SpecialName for events on interfaces.  Fixes
+       #57703. 
+
 2004-04-29  Raja R Harinath  <rharinath@novell.com>
 
        Refactor Attribute.ApplyAttributes.
index 4dbcac9b545bf989d8b0ae3b72ee94c3189ea3a4..dde5d6dbdaae120c3aa0b93b3baf8876ee1f456b 100755 (executable)
@@ -5417,9 +5417,9 @@ namespace Mono.CSharp {
                                is_iface ? AllowedInterfaceModifiers : AllowedModifiers,
                                name, init, attrs, loc)
                {
+                       IsInterface = is_iface;
                        Add = new AddDelegateMethod (this, add);
                        Remove = new RemoveDelegateMethod (this, remove);
-                       IsInterface = is_iface;
                        this.ds = ds;
                }
 
@@ -5430,7 +5430,12 @@ namespace Mono.CSharp {
 
                public override bool Define (TypeContainer container)
                {
-                       EventAttributes e_attr = EventAttributes.RTSpecialName | EventAttributes.SpecialName;
+                       EventAttributes e_attr;
+                       if (IsInterface)
+                               e_attr = EventAttributes.None;
+                       else
+                               e_attr = EventAttributes.RTSpecialName |
+                                       EventAttributes.SpecialName;
 
                        if (!DoDefine (container))
                                return false;
@@ -5471,7 +5476,8 @@ namespace Mono.CSharp {
                                EventBuilder = new MyEventBuilder (this,
                                        container.TypeBuilder, Name, e_attr, MemberType);
                                        
-                               if (Add.Accessor == null && Remove.Accessor == null) {
+                               if (Add.Accessor == null && Remove.Accessor == null &&
+                                   !IsInterface) {
                                        FieldBuilder = container.TypeBuilder.DefineField (
                                                Name, MemberType,
                                                FieldAttributes.Private | ((ModFlags & Modifiers.STATIC) != 0 ? FieldAttributes.Static : 0));
@@ -5502,8 +5508,10 @@ namespace Mono.CSharp {
                                Attribute.ApplyAttributes (ec, EventBuilder, this, OptAttributes);
                        }
 
-                       Add.Emit (tc);
-                       Remove.Emit (tc);
+                       if (!IsInterface) {
+                               Add.Emit (tc);
+                               Remove.Emit (tc);
+                       }
 
                        base.Emit (tc);
                }