2005-09-19 Chris Toshok <toshok@ximian.com>
[mono.git] / mcs / mcs / statement.cs
index 8277e894d88e82069b05a85d13cc751d5c0a8569..d717fba709339e2335e66f816595c62d231f2b4e 100644 (file)
@@ -812,7 +812,7 @@ namespace Mono.CSharp {
 
                        object val = c.GetValue ();
                        if (val == null)
-                               val = c;
+                               val = SwitchLabel.NullStringCase;
                                        
                        sl = (SwitchLabel) ec.Switch.Elements [val];
 
@@ -1917,7 +1917,7 @@ namespace Mono.CSharp {
 
                                        if (!unreachable_shown && (RootContext.WarningLevel >= 2)) {
                                                Report.Warning (
-                                                       162, loc, "Unreachable code detected");
+                                                       162, s.loc, "Unreachable code detected");
                                                unreachable_shown = true;
                                        }
                                }
@@ -2301,6 +2301,8 @@ namespace Mono.CSharp {
                Label il_label_code;
                bool  il_label_code_set;
 
+               public static readonly object NullStringCase = new object ();
+
                //
                // if expr == null, then it is the default case.
                //
@@ -2358,7 +2360,7 @@ namespace Mono.CSharp {
                        }
 
                        if (required_type == TypeManager.string_type && e is NullLiteral) {
-                               converted = e;
+                               converted = NullStringCase;
                                return true;
                        }
 
@@ -2856,7 +2858,7 @@ namespace Mono.CSharp {
 
                        ig.Emit (OpCodes.Ldloc, val);
                        
-                       if (Elements.Contains (NullLiteral.Null)){
+                       if (Elements.Contains (SwitchLabel.NullStringCase)){
                                ig.Emit (OpCodes.Brfalse, null_target);
                        } else
                                ig.Emit (OpCodes.Brfalse, default_target);
@@ -2895,7 +2897,7 @@ namespace Mono.CSharp {
                                        if (sl.Label != null){
                                                object lit = sl.Converted;
 
-                                               if (lit is NullLiteral){
+                                               if (lit == SwitchLabel.NullStringCase){
                                                        null_found = true;
                                                        if (label_count == 1)
                                                                ig.Emit (OpCodes.Br, next_test);
@@ -3881,7 +3883,7 @@ namespace Mono.CSharp {
                {
                        if (!TypeManager.ImplementsInterface (expr_type, TypeManager.idisposable_type)){
                                if (Convert.ImplicitConversion (ec, expr, TypeManager.idisposable_type, loc) == null) {
-                                       Report.Error (1674, loc, "`{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'",
+                                       Report.Error (1674, loc, "`{0}': type used in a using statement must be implicitly convertible to `System.IDisposable'",
                                                TypeManager.CSharpName (expr_type));
                                        return false;
                                }