2006-10-12 Martin Baulig <martin@ximian.com>
authorMartin Baulig <martin@novell.com>
Thu, 12 Oct 2006 18:04:57 +0000 (18:04 -0000)
committerMartin Baulig <martin@novell.com>
Thu, 12 Oct 2006 18:04:57 +0000 (18:04 -0000)
* anonymous.cs
(AnonymousContainer.Resolve): Inflate the `ReturnType'.  Fixes #79592.

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

mcs/mcs/ChangeLog
mcs/mcs/anonymous.cs
mcs/mcs/codegen.cs
mcs/tests/gtest-anon-13.cs [new file with mode: 0755]

index 9c015ffd06e7a9635f31837aabada1a2e7775fd4..91561ee362bf465c0dbc56bdc247e6a3400aec77 100644 (file)
@@ -1,3 +1,8 @@
+2006-10-12  Martin Baulig  <martin@ximian.com>
+
+       * anonymous.cs
+       (AnonymousContainer.Resolve): Inflate the `ReturnType'.  Fixes #79592.
+       
 2006-10-12  Martin Baulig  <martin@ximian.com>
 
        * statement.cs
index 463bca02be709215be50dde1d8e232c462290ee6..89bc65cf9f65977a8e5a7416fb47e8b4d6d3a17b 100644 (file)
@@ -1161,7 +1161,7 @@ namespace Mono.CSharp {
                public readonly ToplevelBlock Block;
 
                public readonly int ModFlags;
-               public readonly Type ReturnType;
+               public Type ReturnType;
                public readonly TypeContainer Host;
 
                //
@@ -1212,6 +1212,18 @@ namespace Mono.CSharp {
                        Report.Debug (64, "RESOLVE ANONYMOUS METHOD", this, Location, ec,
                                      RootScope, Parameters, ec.IsStatic);
 
+                       if (ReturnType != null) {
+                               TypeExpr return_type_expr;
+                               if (RootScope != null)
+                                       return_type_expr = RootScope.InflateType (ReturnType);
+                               else
+                                       return_type_expr = new TypeExpression (ReturnType, Location);
+                               return_type_expr = return_type_expr.ResolveAsTypeTerminal (ec, false);
+                               if ((return_type_expr == null) || (return_type_expr.Type == null))
+                                       return false;
+                               ReturnType = return_type_expr.Type;
+                       }
+
                        aec = new EmitContext (
                                ec.ResolveContext, ec.TypeContainer,
                                RootScope != null ? RootScope : Host, Location, null, ReturnType,
index e4d1b300f1b89fc3295a501444951a1ddc74944e..4fdc92b3e6597a3676c604d415de6fbd23b8cdb4 100644 (file)
@@ -288,7 +288,7 @@ namespace Mono.CSharp {
                ///   The value that is allowed to be returned or NULL if there is no
                ///   return type.
                /// </summary>
-               public Type ReturnType;
+               public readonly Type ReturnType;
 
                /// <summary>
                ///   Points to the Type (extracted from the TypeContainer) that
diff --git a/mcs/tests/gtest-anon-13.cs b/mcs/tests/gtest-anon-13.cs
new file mode 100755 (executable)
index 0000000..99d55bc
--- /dev/null
@@ -0,0 +1,18 @@
+using System;
+using System.Runtime.InteropServices;
+using System.Collections.Generic;
+
+class X
+{
+       public delegate T ModuleBinder<T> (object o);
+
+       public ModuleBinder<TDelegate> CreateMethodUnscoped<TDelegate> ()
+       {
+               return delegate (object o) {
+                       return (TDelegate)(object)null;
+               };
+       }
+
+       static void Main ()
+       { }
+}