2007-01-10 Chris Toshok <toshok@ximian.com>
[mono.git] / mcs / mcs / statement.cs
index 57b1c5536e817fe208f38d7b412ea9f6a510d2c2..e2d0752152fda1a988d891c25d17076a686d6865 100644 (file)
@@ -1024,6 +1024,7 @@ namespace Mono.CSharp {
 
                Flags flags;
                ReadOnlyContext ro_context;
+               LocalBuilder builder;
                
                public LocalInfo (Expression type, string name, Block block, Location l)
                {
@@ -1035,7 +1036,7 @@ namespace Mono.CSharp {
 
                public LocalInfo (DeclSpace ds, Block block, Location l)
                {
-                       VariableType = ds.TypeBuilder;
+                       VariableType = ds.IsGeneric ? ds.CurrentType : ds.TypeBuilder;
                        Block = block;
                        Location = l;
                }
@@ -1047,7 +1048,6 @@ namespace Mono.CSharp {
                                var = theblock.ScopeInfo.GetCapturedVariable (this);
 
                        if (var == null) {
-                               LocalBuilder builder;
                                if (Pinned)
                                        //
                                        // This is needed to compile on both .NET 1.x and .NET 2.x
@@ -1061,6 +1061,12 @@ namespace Mono.CSharp {
                        }
                }
 
+               public void EmitSymbolInfo (EmitContext ec, string name)
+               {
+                       if (builder != null)
+                               ec.DefineLocalVariable (name, builder);
+               }
+
                public bool IsThisAssigned (EmitContext ec, Location loc)
                {
                        if (VariableInfo == null)
@@ -2231,8 +2237,19 @@ namespace Mono.CSharp {
                        DoEmit (ec);
                        ec.Mark (EndLocation, true); 
 
-                       if (emit_debug_info && is_lexical_block)
-                               ec.EndScope ();
+                       if (emit_debug_info) {
+                               if (is_lexical_block)
+                                       ec.EndScope ();
+
+                               if (variables != null) {
+                                       foreach (DictionaryEntry de in variables) {
+                                               string name = (string) de.Key;
+                                               LocalInfo vi = (LocalInfo) de.Value;
+
+                                               vi.EmitSymbolInfo (ec, name);
+                                       }
+                               }
+                       }
 
                        ec.CurrentBlock = prev_block;
                }
@@ -3771,7 +3788,7 @@ namespace Mono.CSharp {
                                                return false;
 
                                        if (!Convert.ImplicitConversionExists (ec, e, expr_type)) {
-                                               e.Error_ValueCannotBeConverted (e.Location, expr_type, false);
+                                               e.Error_ValueCannotBeConverted (ec, e.Location, expr_type, false);
                                                return false;
                                        }
 
@@ -4906,6 +4923,11 @@ namespace Mono.CSharp {
                                                                TypeManager.CSharpName (t), TypeManager.CSharpSignature (mi));
                                                        return false;
                                                }
+
+                                               // Always prefer generics enumerators
+                                               if (TypeManager.IsGenericType(mi.ReturnType))
+                                                       continue;
+
                                                Report.SymbolRelatedToPreviousError (result);
                                                Report.SymbolRelatedToPreviousError (mi);
                                                Report.Warning (278, 2, loc, "`{0}' contains ambiguous implementation of `{1}' pattern. Method `{2}' is ambiguous with method `{3}'",