+2007-12-27 Marek Safar <marek.safar@gmail.com>
+
+ * 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 <marek.safar@gmail.com>
A fix for bug #346379
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;
// 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];
}
}
#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;
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);
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);
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
};
if (t == typeof (ArglistParameter))
return "__arglist";
+
+ if (t == typeof (AnonymousMethod))
+ return "anonymous method";
return CSharpName (GetFullName (t));
}