From 3df3bd5aaa3b1c0b513e2309c49f391310f1fc0f Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Wed, 1 Oct 2008 08:56:52 +0000 Subject: [PATCH] 2008-10-01 Marek Safar A fix for bug #429264 * assign.cs, anonymous.cs, ecore.cs: More type mutators added. * delegate.cs: Removed unnecessary casts. svn path=/trunk/mcs/; revision=114549 --- mcs/mcs/ChangeLog | 7 +++++++ mcs/mcs/anonymous.cs | 14 +++++++++++++- mcs/mcs/assign.cs | 5 +++++ mcs/mcs/delegate.cs | 8 +++++--- mcs/mcs/ecore.cs | 7 +++++++ 5 files changed, 37 insertions(+), 4 deletions(-) diff --git a/mcs/mcs/ChangeLog b/mcs/mcs/ChangeLog index 5bda587dbf3..d2fd7503679 100644 --- a/mcs/mcs/ChangeLog +++ b/mcs/mcs/ChangeLog @@ -1,3 +1,10 @@ +2008-10-01 Marek Safar + + A fix for bug #429264 + * assign.cs, anonymous.cs, ecore.cs: More type mutators added. + + * delegate.cs: Removed unnecessary casts. + 2008-09-30 Marek Safar A fix for bug #352151 diff --git a/mcs/mcs/anonymous.cs b/mcs/mcs/anonymous.cs index 792224df6d6..5f697594938 100644 --- a/mcs/mcs/anonymous.cs +++ b/mcs/mcs/anonymous.cs @@ -1531,7 +1531,19 @@ namespace Mono.CSharp { MethodInfo delegate_method = method.MethodBuilder; #if GMCS_SOURCE if (storey != null && storey.MemberName.IsGeneric) { - delegate_method = TypeBuilder.GetMethod (Storey.Instance.Type, delegate_method); + Type t = storey.Instance.Type; + + // + // Mutate anonymous method instance type if we are in nested + // hoisted generic anonymous method storey + // + if (ec.CurrentAnonymousMethod != null && + ec.CurrentAnonymousMethod.Storey != null && + ec.CurrentAnonymousMethod.Storey.IsGeneric) { + t = storey.GetGenericStorey ().MutateType (t); + } + + delegate_method = TypeBuilder.GetMethod (t, delegate_method); } #endif ig.Emit (OpCodes.Ldftn, delegate_method); diff --git a/mcs/mcs/assign.cs b/mcs/mcs/assign.cs index 5496cf64b01..e3d74427615 100644 --- a/mcs/mcs/assign.cs +++ b/mcs/mcs/assign.cs @@ -299,6 +299,11 @@ namespace Mono.CSharp { ig.Emit (OpCodes.Ldloca, builder); } + public override void MutateHoistedGenericType (AnonymousMethodStorey storey) + { + type = storey.MutateType (type); + } + public bool PointsToAddress { get { return is_address; diff --git a/mcs/mcs/delegate.cs b/mcs/mcs/delegate.cs index f1aff89e588..7fa7f6da673 100644 --- a/mcs/mcs/delegate.cs +++ b/mcs/mcs/delegate.cs @@ -799,9 +799,11 @@ namespace Mono.CSharp { if (!delegate_method.DeclaringType.IsSealed && delegate_method.IsVirtual && !method_group.IsBase) { ec.ig.Emit (OpCodes.Dup); - ec.ig.Emit (OpCodes.Ldvirtftn, (MethodInfo) delegate_method); - } else - ec.ig.Emit (OpCodes.Ldftn, (MethodInfo) delegate_method); + ec.ig.Emit (OpCodes.Ldvirtftn, delegate_method); + } else { + ec.ig.Emit (OpCodes.Ldftn, delegate_method); + } + ec.ig.Emit (OpCodes.Newobj, constructor_method); } diff --git a/mcs/mcs/ecore.cs b/mcs/mcs/ecore.cs index 85d9121fb95..1fa125853e1 100644 --- a/mcs/mcs/ecore.cs +++ b/mcs/mcs/ecore.cs @@ -1388,6 +1388,7 @@ namespace Mono.CSharp { public override void MutateHoistedGenericType (AnonymousMethodStorey storey) { + type = storey.MutateType (type); child.MutateHoistedGenericType (storey); } @@ -3297,6 +3298,12 @@ namespace Mono.CSharp { base.EmitCall (ec, arguments); } + public override void MutateHoistedGenericType (AnonymousMethodStorey storey) + { + extension_argument.Expr.MutateHoistedGenericType (storey); + base.MutateHoistedGenericType (storey); + } + public override MethodGroupExpr OverloadResolve (EmitContext ec, ref ArrayList arguments, bool may_fail, Location loc) { if (arguments == null) -- 2.11.4.GIT