From d973adf739079a754013a7aabaf062c6e8362d58 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 12 Oct 2006 18:04:57 +0000 Subject: 2006-10-12 Martin Baulig * anonymous.cs (AnonymousContainer.Resolve): Inflate the `ReturnType'. Fixes #79592. svn path=/trunk/mcs/; revision=66620 --- mcs/mcs/ChangeLog | 5 +++++ mcs/mcs/anonymous.cs | 14 +++++++++++++- mcs/mcs/codegen.cs | 2 +- mcs/tests/gtest-anon-13.cs | 18 ++++++++++++++++++ 4 files changed, 37 insertions(+), 2 deletions(-) create mode 100755 mcs/tests/gtest-anon-13.cs diff --git a/mcs/mcs/ChangeLog b/mcs/mcs/ChangeLog index 9c015ffd06e..91561ee362b 100644 --- a/mcs/mcs/ChangeLog +++ b/mcs/mcs/ChangeLog @@ -1,3 +1,8 @@ +2006-10-12 Martin Baulig + + * anonymous.cs + (AnonymousContainer.Resolve): Inflate the `ReturnType'. Fixes #79592. + 2006-10-12 Martin Baulig * statement.cs diff --git a/mcs/mcs/anonymous.cs b/mcs/mcs/anonymous.cs index 463bca02be7..89bc65cf9f6 100644 --- a/mcs/mcs/anonymous.cs +++ b/mcs/mcs/anonymous.cs @@ -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, diff --git a/mcs/mcs/codegen.cs b/mcs/mcs/codegen.cs index e4d1b300f1b..4fdc92b3e65 100644 --- a/mcs/mcs/codegen.cs +++ b/mcs/mcs/codegen.cs @@ -288,7 +288,7 @@ namespace Mono.CSharp { /// The value that is allowed to be returned or NULL if there is no /// return type. /// - public Type ReturnType; + public readonly Type ReturnType; /// /// 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 index 00000000000..99d55bc821b --- /dev/null +++ b/mcs/tests/gtest-anon-13.cs @@ -0,0 +1,18 @@ +using System; +using System.Runtime.InteropServices; +using System.Collections.Generic; + +class X +{ + public delegate T ModuleBinder (object o); + + public ModuleBinder CreateMethodUnscoped () + { + return delegate (object o) { + return (TDelegate)(object)null; + }; + } + + static void Main () + { } +} -- cgit v1.2.3