* expression.cs, attribute.cs, parameter.cs: More attribute type
checks.
svn path=/trunk/mcs/; revision=155258
2010-04-12 Marek Safar <marek.safar@gmail.com>
- * expression.cs, attribute.cs: More attribute type checks.
+ * expression.cs, attribute.cs, parameter.cs: More attribute type
+ checks.
2010-04-12 Marek Safar <marek.safar@gmail.com>
if (resolve_error)
return null;
- return ((Constant) PosArguments[0].Expr).GetValue () as Type;
+ return GetArgumentType ();
}
public bool CheckTarget ()
public Constant GetParameterDefaultValue (out Type type)
{
var expr = PosArguments[0].Expr;
- type = expr.Type;
if (expr is TypeCast)
expr = ((TypeCast) expr).Child;
+ type = expr.Type;
return expr as Constant;
}
return;
}
- var val = c.GetValue ();
- if (parameter_type == TypeManager.object_type ||
- (val == null && !TypeManager.IsGenericParameter (parameter_type) && TypeManager.IsReferenceType (parameter_type)) ||
- (val != null && TypeManager.TypeToCoreType (val.GetType ()) == parameter_type))
- builder.SetConstant (val);
+ if (arg_type == parameter_type || parameter_type == TypeManager.object_type ||
+ (c.IsNull && TypeManager.IsReferenceType (parameter_type) && !TypeManager.IsGenericParameter (parameter_type)))
+ builder.SetConstant (c.GetValue ());
else
a.Report.Error (1908, a.Location, "The type of the default value should match the type of the parameter");
+
return;
}