GenericTypeExpr ct = iface as GenericTypeExpr;
if (ct != null) {
- if (!ct.CheckConstraints (this) || !ct.VerifyVariantTypeParameters ())
+ // TODO: passing `this' is wrong, should be base type iface instead
+ TypeManager.CheckTypeVariance (ct.Type, Variance.Covariant, this);
+
+ if (!ct.CheckConstraints (this))
return false;
}
}
}
public sealed class Struct : ClassOrStruct {
+
+ bool is_unmanaged, has_unmanaged_check_done;
+
// <summary>
// Modifiers allowed in a struct declaration
// </summary>
if (requires_delayed_unmanagedtype_check)
return true;
+ if (has_unmanaged_check_done)
+ return is_unmanaged;
+
+ has_unmanaged_check_done = true;
+
foreach (FieldBase f in fields) {
if ((f.ModFlags & Modifiers.STATIC) != 0)
continue;
// struct S { S* s; }
Type mt = f.MemberType;
if (mt == null) {
+ has_unmanaged_check_done = false;
requires_delayed_unmanagedtype_check = true;
return true;
}
return false;
}
+ is_unmanaged = true;
return true;
}
if ((ModFlags & Modifiers.PARTIAL) != 0) {
for (int i = 0; i < Parameters.Count; ++i) {
- if (Parameters.FixedParameters[i].ModFlags == Parameter.Modifier.OUT) {
+ IParameterData p = Parameters.FixedParameters [i];
+ if (p.ModFlags == Parameter.Modifier.OUT) {
Report.Error (752, Location, "`{0}': A partial method parameters cannot use `out' modifier",
GetSignatureForError ());
- break;
}
+
+ if (p.HasDefaultValue && IsPartialImplementation)
+ ((Parameter) p).Warning_UselessOptionalParameter ();
}
}
}
return true;
if (Parameters.HasExtensionMethodType) {
- if (Parent.IsStaticClass && !Parent.IsGeneric) {
+ if (Parent.PartialContainer.IsStaticClass && !Parent.IsGeneric) {
if (!Parent.IsTopLevel)
Report.Error (1109, Location, "`{0}': Extension methods cannot be defined in a nested class",
GetSignatureForError ());
{
caching_flags |= Flags.PartialDefinitionExists;
methodDefinition.MethodBuilder = MethodBuilder;
+
+ for (int i = 0; i < methodDefinition.Parameters.Count; ++i ) {
+ Parameters [i].DefaultValue = methodDefinition.Parameters [i].DefaultValue;
+ }
+
if (methodDefinition.attributes == null)
return;
"accessible than field `" + GetSignatureForError () + "'");
}
}
-#if GMCS_SOURCE
- if (MemberType.IsGenericParameter && (MemberType.GenericParameterAttributes & GenericParameterAttributes.Contravariant) != 0) {
- Report.Error (-33, Location, "Contravariant type parameters can only be used in input positions");
- }
-#endif
+
+ TypeManager.CheckTypeVariance (MemberType, Variance.Covariant, this);
}
protected bool IsTypePermitted ()
return true;
}
- if ((ModFlags & (Modifiers.NEW | Modifiers.OVERRIDE)) == 0) {
+ if ((ModFlags & (Modifiers.NEW | Modifiers.OVERRIDE | Modifiers.BACKING_FIELD)) == 0) {
Report.SymbolRelatedToPreviousError (conflict_symbol);
Report.Warning (108, 2, Location, "`{0}' hides inherited member `{1}'. Use the new keyword if hiding was intended",
GetSignatureForError (), TypeManager.GetFullNameSignature (conflict_symbol));
MemberType == TypeManager.sbyte_type || MemberType == TypeManager.byte_type ||
MemberType == TypeManager.short_type || MemberType == TypeManager.ushort_type ||
MemberType == TypeManager.int32_type || MemberType == TypeManager.uint32_type ||
- MemberType == TypeManager.float_type)
+ MemberType == TypeManager.float_type ||
+ MemberType == TypeManager.intptr_type || MemberType == TypeManager.uintptr_type)
return true;
if (TypeManager.IsEnumType (MemberType))
GetSignatureForError ());
}
- if (!HasBackingField)
+ if (!HasBackingField) {
+ SetMemberIsUsed ();
return true;
+ }
// FIXME: We are unable to detect whether generic event is used because
// we are using FieldExpr instead of EventExpr for event access in that
// case. When this issue will be fixed this hack can be removed.
if (TypeManager.IsGenericType (MemberType))
- SetMemberIsUsed();
+ SetMemberIsUsed ();
if (Add.IsInterfaceImplementation)
SetMemberIsUsed ();