Author: miguel
Date: 2006-07-20 02:01:05 -0400 (Thu, 20 Jul 2006)
New Revision: 62792

Modified:
   trunk/mcs/gmcs/ChangeLog
   trunk/mcs/gmcs/anonymous.cs
   trunk/mcs/mcs/ChangeLog
   trunk/mcs/mcs/anonymous.cs
Log:

Hari tracked down the source of this bug:

        #78786

2006-07-20  Miguel de Icaza  <[EMAIL PROTECTED]>

        * anonymous.cs: Cache the resolved anonymous delegate, and return
        this so that the ResolveTopBlock is only triggered once, not
        twice.

        Currently we trigger ResolvetopBlock twice due to a first pass of
        argument check compatibility, and a second pass that does the
        actual resolution.   



Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog    2006-07-20 03:49:26 UTC (rev 62791)
+++ trunk/mcs/gmcs/ChangeLog    2006-07-20 06:01:05 UTC (rev 62792)
@@ -1,3 +1,13 @@
+2006-07-20  Miguel de Icaza  <[EMAIL PROTECTED]>
+
+       * anonymous.cs: Cache the resolved anonymous delegate, and return
+       this so that the ResolveTopBlock is only triggered once, not
+       twice.
+
+       Currently we trigger ResolvetopBlock twice due to a first pass of
+       argument check compatibility, and a second pass that does the
+       actual resolution.   
+
 2006-07-16  Marek Safar  <[EMAIL PROTECTED]>
 
        A fix for #70506

Modified: trunk/mcs/gmcs/anonymous.cs
===================================================================
--- trunk/mcs/gmcs/anonymous.cs 2006-07-20 03:49:26 UTC (rev 62791)
+++ trunk/mcs/gmcs/anonymous.cs 2006-07-20 06:01:05 UTC (rev 62792)
@@ -213,6 +213,13 @@
        {
                TypeContainer host;
 
+               //
+               // The value return by the Compatible call, this ensure that
+               // the code works even if invoked more than once (Resolve called
+               // more than once, due to the way Convert.ImplicitConversion 
works
+               //
+               Expression anonymous_delegate;
+
                public AnonymousMethod (TypeContainer host, Parameters 
parameters, ToplevelBlock container,
                                        ToplevelBlock block, Location l)
                        : base (parameters, container, block, l)
@@ -331,6 +338,9 @@
                //
                public Expression Compatible (EmitContext ec, Type 
delegate_type)
                {
+                       if (anonymous_delegate != null)
+                               return anonymous_delegate;
+                       
                        //
                        // At this point its the first time we know the return 
type that is 
                        // needed for the anonymous method.  We create the 
method here.
@@ -421,9 +431,11 @@
                        ContainerAnonymousMethod = ec.CurrentAnonymousMethod;
                        ContainingBlock = ec.CurrentBlock;
 
-                       if (aec.ResolveTopBlock (ec, Block, Parameters, null, 
out unreachable))
-                               return new AnonymousDelegate (this, 
delegate_type, loc).Resolve (ec);
-
+                       if (aec.ResolveTopBlock (ec, Block, Parameters, null, 
out unreachable)){
+                               anonymous_delegate = new AnonymousDelegate (
+                                       this, delegate_type, loc).Resolve (ec);
+                               return anonymous_delegate;
+                       }
                        return null;
                }
 

Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog     2006-07-20 03:49:26 UTC (rev 62791)
+++ trunk/mcs/mcs/ChangeLog     2006-07-20 06:01:05 UTC (rev 62792)
@@ -1,3 +1,13 @@
+2006-07-20  Miguel de Icaza  <[EMAIL PROTECTED]>
+
+       * anonymous.cs: Cache the resolved anonymous delegate, and return
+       this so that the ResolveTopBlock is only triggered once, not
+       twice.
+
+       Currently we trigger ResolvetopBlock twice due to a first pass of
+       argument check compatibility, and a second pass that does the
+       actual resolution.   
+       
 2006-07-16  Marek Safar  <[EMAIL PROTECTED]>
 
        A fix for #70506

Modified: trunk/mcs/mcs/anonymous.cs
===================================================================
--- trunk/mcs/mcs/anonymous.cs  2006-07-20 03:49:26 UTC (rev 62791)
+++ trunk/mcs/mcs/anonymous.cs  2006-07-20 06:01:05 UTC (rev 62792)
@@ -207,6 +207,13 @@
        {
                TypeContainer host;
 
+               //
+               // The value return by the Compatible call, this ensure that
+               // the code works even if invoked more than once (Resolve called
+               // more than once, due to the way Convert.ImplicitConversion 
works
+               //
+               Expression anonymous_delegate;
+
                public AnonymousMethod (TypeContainer host, Parameters 
parameters, ToplevelBlock container,
                                        ToplevelBlock block, Location l)
                        : base (parameters, container, block, l)
@@ -299,6 +306,9 @@
                //
                public Expression Compatible (EmitContext ec, Type 
delegate_type)
                {
+                       if (anonymous_delegate != null)
+                               return anonymous_delegate;
+                       
                        //
                        // At this point its the first time we know the return 
type that is 
                        // needed for the anonymous method.  We create the 
method here.
@@ -375,9 +385,11 @@
                        ContainerAnonymousMethod = ec.CurrentAnonymousMethod;
                        ContainingBlock = ec.CurrentBlock;
 
-                       if (aec.ResolveTopBlock (ec, Block, Parameters, null, 
out unreachable))
-                               return new AnonymousDelegate (this, 
delegate_type, loc).Resolve (ec);
-
+                       if (aec.ResolveTopBlock (ec, Block, Parameters, null, 
out unreachable)){
+                               anonymous_delegate = new AnonymousDelegate (
+                                       this, delegate_type, loc).Resolve (ec);
+                               return anonymous_delegate;
+                       }
                        return null;
                }
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to