2002-10-19 Miguel de Icaza <miguel@ximian.com>
authorMiguel de Icaza <miguel@gnome.org>
Sat, 19 Oct 2002 20:21:49 +0000 (20:21 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Sat, 19 Oct 2002 20:21:49 +0000 (20:21 -0000)
* ecore.cs (FieldExpr.AddressOf): We had a special code path for
init-only variables, but this path did not take into account that
there might be also instance readonly variables.  Correct this
problem.

This fixes bug 32253

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

mcs/mcs/ChangeLog
mcs/mcs/ecore.cs

index e7f2a3fc943cdeb6c30f28f74d5d6c85eaa2fbcc..05ae35e39c67a2cb93b39f711d200fa20c08b65b 100755 (executable)
@@ -1,5 +1,12 @@
 2002-10-19  Miguel de Icaza  <miguel@ximian.com>
 
+       * ecore.cs (FieldExpr.AddressOf): We had a special code path for
+       init-only variables, but this path did not take into account that
+       there might be also instance readonly variables.  Correct this
+       problem. 
+
+       This fixes bug 32253
+
        * delegate.cs (NewDelegate.DoResolve): Catch creation of unsafe
        delegates as well.
 
index 02c6e8d276053234a7599ab894b66f2069f4a874..e68541868afd434325d7fc40d242ae03cdb1453b 100755 (executable)
@@ -4073,17 +4073,13 @@ namespace Mono.CSharp {
                        // Handle initonly fields specially: make a copy and then
                        // get the address of the copy.
                        //
-                       if (FieldInfo.IsInitOnly){
-                               if (ec.IsConstructor) {
-                                       ig.Emit (OpCodes.Ldsflda, FieldInfo);
-                               } else {
-                                       LocalBuilder local;
+                       if (FieldInfo.IsInitOnly && !ec.IsConstructor){
+                               LocalBuilder local;
                                
-                                       Emit (ec);
-                                       local = ig.DeclareLocal (type);
-                                       ig.Emit (OpCodes.Stloc, local);
-                                       ig.Emit (OpCodes.Ldloca, local);
-                               }
+                               Emit (ec);
+                               local = ig.DeclareLocal (type);
+                               ig.Emit (OpCodes.Stloc, local);
+                               ig.Emit (OpCodes.Ldloca, local);
                                return;
                        }