Author: marek
Date: 2007-12-27 04:36:47 -0500 (Thu, 27 Dec 2007)
New Revision: 91921

Modified:
   trunk/mcs/mcs/ChangeLog
   trunk/mcs/mcs/ecore.cs
   trunk/mcs/mcs/expression.cs
   trunk/mcs/mcs/generic.cs
   trunk/mcs/mcs/report.cs
   trunk/mcs/mcs/typemanager.cs
Log:
2007-12-27  Marek Safar  <[EMAIL PROTECTED]>

        * ecore.cs: Report type inference errors only when arguments count 
matches
        parameter count.
        
        * generic.cs (NullCoalescingOperator): Cannot be applied to null.
        
        * expression.cs, report.cs: New warning.
        
        * typemanager.cs: Catch anonymous method type too.
        


Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog     2007-12-27 09:33:54 UTC (rev 91920)
+++ trunk/mcs/mcs/ChangeLog     2007-12-27 09:36:47 UTC (rev 91921)
@@ -1,3 +1,14 @@
+2007-12-27  Marek Safar  <[EMAIL PROTECTED]>
+
+       * ecore.cs: Report type inference errors only when arguments count 
matches
+       parameter count.
+       
+       * generic.cs (NullCoalescingOperator): Cannot be applied to null.
+       
+       * expression.cs, report.cs: New warning.
+       
+       * typemanager.cs: Catch anonymous method type too.
+
 2007-12-23  Marek Safar  <[EMAIL PROTECTED]>
 
        A fix for bug #346379

Modified: trunk/mcs/mcs/ecore.cs
===================================================================
--- trunk/mcs/mcs/ecore.cs      2007-12-27 09:33:54 UTC (rev 91920)
+++ trunk/mcs/mcs/ecore.cs      2007-12-27 09:36:47 UTC (rev 91921)
@@ -4005,33 +4005,33 @@
                                                        return null;
                                        }
 
-                                       if (TypeManager.IsGenericMethod 
(best_candidate)) {
-                                               if (type_arguments == null) {
-                                                       Report.Error (411, loc,
-                                                               "The type 
arguments for method `{0}' cannot be inferred from " +
-                                                               "the usage. Try 
specifying the type arguments explicitly",
-                                                               
TypeManager.CSharpSignature (best_candidate));
-                                                       return null;
-                                               }
-
-                                               Type [] g_args = 
TypeManager.GetGenericArguments (best_candidate);
-                                               if (type_arguments.Count != 
g_args.Length) {
-                                                       
Report.SymbolRelatedToPreviousError (best_candidate);
-                                                       Report.Error (305, loc, 
"Using the generic method `{0}' requires `{1}' type argument(s)",
-                                                               
TypeManager.CSharpSignature (best_candidate),
-                                                               
g_args.Length.ToString ());
-                                                       return null;
-                                               }
-                                       } else {
-                                               if (type_arguments != null) {
-                                                       
Namespace.Error_TypeArgumentsCannotBeUsed (best_candidate, loc);
-                                                       return null;
-                                               }
-                                       }
-                                       
                                        ParameterData pd = 
TypeManager.GetParameterData (best_candidate);
                                        bool cand_params = candidate_to_form != 
null && candidate_to_form.Contains (best_candidate);
                                        if (arg_count == pd.Count || 
pd.HasParams) {
+                                               if (TypeManager.IsGenericMethod 
(best_candidate)) {
+                                                       if (type_arguments == 
null) {
+                                                               Report.Error 
(411, loc,
+                                                                       "The 
type arguments for method `{0}' cannot be inferred from " +
+                                                                       "the 
usage. Try specifying the type arguments explicitly",
+                                                                       
TypeManager.CSharpSignature (best_candidate));
+                                                               return null;
+                                                       }
+                                                               
+                                                       Type [] g_args = 
TypeManager.GetGenericArguments (best_candidate);
+                                                       if 
(type_arguments.Count != g_args.Length) {
+                                                               
Report.SymbolRelatedToPreviousError (best_candidate);
+                                                               Report.Error 
(305, loc, "Using the generic method `{0}' requires `{1}' type argument(s)",
+                                                                       
TypeManager.CSharpSignature (best_candidate),
+                                                                       
g_args.Length.ToString ());
+                                                               return null;
+                                                       }
+                                               } else {
+                                                       if (type_arguments != 
null) {
+                                                               
Namespace.Error_TypeArgumentsCannotBeUsed (best_candidate, loc);
+                                                               return null;
+                                                       }
+                                               }
+                                               
                                                if (VerifyArgumentsCompat (ec, 
Arguments, arg_count, best_candidate, cand_params, may_fail, loc))
                                                        throw new 
InternalErrorException ("Overload verification expected failure");
                                                return null;

Modified: trunk/mcs/mcs/expression.cs
===================================================================
--- trunk/mcs/mcs/expression.cs 2007-12-27 09:33:54 UTC (rev 91920)
+++ trunk/mcs/mcs/expression.cs 2007-12-27 09:36:47 UTC (rev 91921)
@@ -1153,7 +1153,7 @@
                                // If E is a method group or the null literal, 
of if the type of E is a reference
                                // type or a nullable type and the value of E 
is null, the result is false
                                //
-                               if (((Constant) expr).GetValue () == null)
+                               if (expr.IsNull)
                                        return CreateConstantResult (false);
                        } else if (TypeManager.IsNullableType (d) && 
!TypeManager.ContainsGenericParameters (d)) {
                                d = TypeManager.GetTypeArguments (d) [0];
@@ -1319,7 +1319,11 @@
                                }
                        }
 #endif
-
+                       if (expr.IsNull && TypeManager.IsNullableType (type)) {
+                               Report.Warning (458, 2, loc, "The result of the 
expression is always `null' of type `{0}'",
+                                       TypeManager.CSharpName (type));
+                       }
+                       
                        Expression e = Convert.ImplicitConversion (ec, expr, 
type, loc);
                        if (e != null){
                                expr = e;

Modified: trunk/mcs/mcs/generic.cs
===================================================================
--- trunk/mcs/mcs/generic.cs    2007-12-27 09:33:54 UTC (rev 91920)
+++ trunk/mcs/mcs/generic.cs    2007-12-27 09:36:47 UTC (rev 91921)
@@ -3856,11 +3856,6 @@
 
                                Type ltype = left.Type, rtype = right.Type;
 
-                               if (!TypeManager.IsNullableType (ltype) && 
ltype.IsValueType) {
-                                       Binary.Error_OperatorCannotBeApplied 
(loc, "??", ltype, rtype);
-                                       return null;
-                               }
-
                                if (TypeManager.IsNullableType (ltype)) {
                                        NullableInfo info = new NullableInfo 
(ltype);
 
@@ -3874,6 +3869,11 @@
                                                type = expr.Type;
                                                return this;
                                        }
+                               } else {
+                                       if (left.IsNull || ltype.IsValueType) {
+                                               
Binary.Error_OperatorCannotBeApplied (loc, "??", ltype, rtype);
+                                               return null;
+                                       }
                                }
 
                                expr = Convert.ImplicitConversion (ec, right, 
ltype, loc);

Modified: trunk/mcs/mcs/report.cs
===================================================================
--- trunk/mcs/mcs/report.cs     2007-12-27 09:33:54 UTC (rev 91920)
+++ trunk/mcs/mcs/report.cs     2007-12-27 09:36:47 UTC (rev 91921)
@@ -101,7 +101,7 @@
                        2002, 2023, 2029,
                        3005, 3012, 3018, 3019, 3021, 3022, 3023, 3026, 3027,
 #if GMCS_SOURCE
-                       402, 414, 693, 1058, 1700, 3024
+                       402, 414, 458, 693, 1058, 1700, 3024
 #endif
                };
 

Modified: trunk/mcs/mcs/typemanager.cs
===================================================================
--- trunk/mcs/mcs/typemanager.cs        2007-12-27 09:33:54 UTC (rev 91920)
+++ trunk/mcs/mcs/typemanager.cs        2007-12-27 09:36:47 UTC (rev 91921)
@@ -625,6 +625,9 @@
 
                if (t == typeof (ArglistParameter))
                        return "__arglist";
+                       
+               if (t == typeof (AnonymousMethod))
+                       return "anonymous method";
 
                return CSharpName (GetFullName (t));
     }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to