CallerMask = CallerMemberName | CallerLineNumber | CallerFilePath
}
- static readonly string[] attribute_targets = new string[] { "param" };
- static readonly string[] attribute_targets_primary = new string[] { "param", "field" };
+ static readonly string[] attribute_targets = new [] { "param" };
FullNamedExpression texpr;
Modifier modFlags;
protected int idx;
public bool HasAddressTaken;
- Constructor primary_constructor;
TemporaryVariableReference expr_tree_variable;
HoistedParameter hoisted_variant;
public override string[] ValidAttributeTargets {
get {
- return primary_constructor != null ? attribute_targets_primary : attribute_targets;
+ return attribute_targets;
}
}
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
{
- if (a.Target == AttributeTargets.Field) {
- var field = MemberCache.FindMember (primary_constructor.Spec.DeclaringType, MemberFilter.Field (name, parameter_type), BindingRestriction.DeclaredOnly);
- ((Field)field.MemberDefinition).ApplyAttributeBuilder (a, ctor, cdata, pa);
- return;
- }
-
if (a.Type == pa.In && ModFlags == Modifier.OUT) {
a.Report.Error (36, a.Location, "An out parameter cannot have the `In' attribute");
return;
if (attributes != null)
attributes.AttachTo (this, rc);
- var ctor = rc.CurrentMemberDefinition as Constructor;
- if (ctor != null && ctor.IsPrimaryConstructor)
- primary_constructor = ctor;
-
parameter_type = texpr.ResolveAsType (rc);
if (parameter_type == null)
return null;
if (TypeSpecComparer.IsEqual (default_expr.Type, parameter_type) ||
(default_expr is NullConstant && TypeSpec.IsReferenceType (parameter_type) && !parameter_type.IsGenericParameter) ||
- parameter_type.BuiltinType == BuiltinTypeSpec.Type.Object) {
+ parameter_type.BuiltinType == BuiltinTypeSpec.Type.Object ||
+ parameter_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
return;
}
return sb.ToString ();
}
+ public static bool HasSameParameterDefaults (AParametersCollection a, AParametersCollection b)
+ {
+ if (a == null)
+ return b == null;
+
+ for (int i = 0; i < a.Count; ++i) {
+ if (a.FixedParameters [i].HasDefaultValue != b.FixedParameters [i].HasDefaultValue)
+ return false;
+ }
+
+ return true;
+ }
+
public bool HasArglist {
get { return has_arglist; }
}
for (int i = 0; i < parameters.Length; ++i) {
Parameter p = (Parameter) parameters [i];
+ if (p.Type != null)
+ p.Type.CheckObsoleteness (m, p.Location);
+
//
// Try not to enter default values resolution if there are is not any default value possible
//
expr = Child;
- if (!(expr is Constant || expr is DefaultValueExpression || (expr is New && ((New) expr).IsDefaultStruct))) {
- rc.Report.Error (1736, Location,
- "The expression being assigned to optional parameter `{0}' must be a constant or default value",
- p.Name);
+ if (!(expr is Constant || expr is DefaultValueExpression || (expr is New && ((New) expr).IsGeneratedStructConstructor))) {
+ if (!(expr is ErrorExpression)) {
+ rc.Report.Error (1736, Location,
+ "The expression being assigned to optional parameter `{0}' must be a constant or default value",
+ p.Name);
+ }
return;
}