--- /dev/null
+// CS0619: `Y' is obsolete: `ooo'
+// Line: 6
+
+using System;
+
+class X : I<Y>
+{
+}
+
+interface I<T>
+{
+
+}
+
+[Obsolete("ooo", true)]
+class Y
+{
+}
return null;
}
- ObsoleteAttribute obsolete_attr = Type.GetAttributeObsolete ();
- if (obsolete_attr != null) {
- AttributeTester.Report_ObsoleteMessage (obsolete_attr, Type.GetSignatureForError (), Location, Report);
- }
+ Type.CheckObsoleteness (context, expression.StartLocation);
ResolveContext rc = null;
return false;
}
- ObsoleteAttribute obsolete_attr;
-
if (member is PropertyExpr) {
var pi = ((PropertyExpr) member).PropertyInfo;
return false;
}
- obsolete_attr = pi.GetAttributeObsolete ();
+// if (!context.IsObsolete)
+ pi.CheckObsoleteness (ec, member.StartLocation);
+
pi.MemberDefinition.SetIsAssigned ();
} else {
var fi = ((FieldExpr) member).Spec;
return false;
}
- obsolete_attr = fi.GetAttributeObsolete ();
+// if (!context.IsObsolete)
+ fi.CheckObsoleteness (ec, member.StartLocation);
+
fi.MemberDefinition.SetIsAssigned ();
}
- if (obsolete_attr != null && !context.IsObsolete)
- AttributeTester.Report_ObsoleteMessage (obsolete_attr, member.GetSignatureForError (), member.Location, Report);
-
if (a.Type != member.Type) {
a.Expr = Convert.ImplicitConversionRequired (ec, a.Expr, member.Type, a.Expr.Location);
}
if (compiled_iface != null)
compiled_iface.Define ();
- ObsoleteAttribute oa = iface_type.GetAttributeObsolete ();
- if (oa != null && !IsObsolete)
- AttributeTester.Report_ObsoleteMessage (oa, iface_type.GetSignatureForError (), Location, Report);
+ iface_type.CheckObsoleteness (this, Location);
if (iface_type.Arity > 0) {
// TODO: passing `this' is wrong, should be base type iface instead
// Run checks skipped during DefineType (e.g FullNamedExpression::ResolveAsType)
//
if (base_type_expr != null) {
- ObsoleteAttribute obsolete_attr = base_type.GetAttributeObsolete ();
- if (obsolete_attr != null && !IsObsolete)
- AttributeTester.Report_ObsoleteMessage (obsolete_attr, base_type.GetSignatureForError (), base_type_expr.Location, Report);
+ base_type.CheckObsoleteness (this, base_type_expr.Location);
if (IsGenericOrParentIsGeneric && base_type.IsAttribute) {
Report.Error (698, base_type_expr.Location,
return obsolete;
}
- /// <summary>
- /// Checks for ObsoleteAttribute presence. It's used for testing of all non-types elements
- /// </summary>
- public virtual void CheckObsoleteness (Location loc)
- {
- ObsoleteAttribute oa = GetAttributeObsolete ();
- if (oa != null)
- AttributeTester.Report_ObsoleteMessage (oa, GetSignatureForError (), loc, Report);
- }
-
//
// Checks whether the type P is as accessible as this member
//
#endregion
+ public virtual void CheckObsoleteness (IMemberContext mc, Location loc)
+ {
+ var oa = GetAttributeObsolete ();
+ if (oa == null)
+ return;
+
+ if (!mc.IsObsolete)
+ AttributeTester.Report_ObsoleteMessage (oa, GetSignatureForError (), loc, mc.Module.Compiler.Report);
+ }
+
public virtual ObsoleteAttribute GetAttributeObsolete ()
{
if ((state & (StateFlags.Obsolete | StateFlags.Obsolete_Undetected)) == 0)
// require type dependencies to be set but we are in process of resolving them
//
if (!(mc is TypeDefinition.BaseContext) && !(mc is UsingAliasNamespace.AliasContext)) {
- ObsoleteAttribute obsolete_attr = type.GetAttributeObsolete ();
- if (obsolete_attr != null && !mc.IsObsolete) {
- AttributeTester.Report_ObsoleteMessage (obsolete_attr, te.GetSignatureForError (), Location, mc.Module.Compiler.Report);
- }
+ type.CheckObsoleteness (mc, fne.StartLocation);
}
return type;
ImportedTypeDefinition.Error_MissingDependency (rc, dep, loc);
}
- if (!rc.IsObsolete) {
- ObsoleteAttribute oa = member.GetAttributeObsolete ();
- if (oa != null)
- AttributeTester.Report_ObsoleteMessage (oa, member.GetSignatureForError (), loc, rc.Report);
- }
+ member.CheckObsoleteness (rc, loc);
if (!(member is FieldSpec))
member.MemberDefinition.SetIsUsed ();
if (InstanceExpression is TypeExpr) {
var t = InstanceExpression.Type;
do {
- ObsoleteAttribute oa = t.GetAttributeObsolete ();
- if (oa != null && !rc.IsObsolete) {
- AttributeTester.Report_ObsoleteMessage (oa, t.GetSignatureForError (), loc, rc.Report);
- }
+ t.CheckObsoleteness (rc, loc);
t = t.DeclaringType;
} while (t != null);
//
// Check ObsoleteAttribute on the best method
//
- ObsoleteAttribute oa = best_candidate.GetAttributeObsolete ();
- if (oa != null && !rc.IsObsolete)
- AttributeTester.Report_ObsoleteMessage (oa, best_candidate.GetSignatureForError (), loc, rc.Report);
+ best_candidate.CheckObsoleteness (rc, loc);
best_candidate.MemberDefinition.SetIsUsed ();
}
spec.MemberDefinition.SetIsUsed ();
- if (!ec.IsObsolete) {
- ObsoleteAttribute oa = spec.GetAttributeObsolete ();
- if (oa != null)
- AttributeTester.Report_ObsoleteMessage (oa, spec.GetSignatureForError (), loc, ec.Report);
- }
+ spec.CheckObsoleteness (ec, loc);
if ((spec.Modifiers & (Modifiers.ABSTRACT | Modifiers.EXTERN)) != 0)
Error_AssignmentEventOnly (ec);
protected override MethodGroupExpr DoResolveOverload (ResolveContext rc)
{
- if (!rc.IsObsolete) {
- var member = mg.BestCandidate;
- ObsoleteAttribute oa = member.GetAttributeObsolete ();
- if (oa != null)
- AttributeTester.Report_ObsoleteMessage (oa, member.GetSignatureForError (), loc, rc.Report);
- }
+ mg.BestCandidate.CheckObsoleteness (rc, loc);
return mg;
}
protected override Expression DoResolve (ResolveContext ec)
{
- ObsoleteAttribute oa = method.GetAttributeObsolete ();
- if (oa != null)
- AttributeTester.Report_ObsoleteMessage (oa, GetSignatureForError (), loc, ec.Report);
+ method.CheckObsoleteness (ec, source.Location);
eclass = ExprClass.Value;
return this;
continue;
if (obsoleteCheck) {
- ObsoleteAttribute obsolete_attr = t.GetAttributeObsolete ();
- if (obsolete_attr != null)
- AttributeTester.Report_ObsoleteMessage (obsolete_attr, t.GetSignatureForError (), c.Location, context.Module.Compiler.Report);
+ t.CheckObsoleteness (context, c.Location);
}
ConstraintChecker.Check (context, t, c.Location);
return definition.GetMetaInfo ().MakeGenericType (all.ToArray ());
}
+ public override void CheckObsoleteness (IMemberContext mc, Location loc)
+ {
+ base.CheckObsoleteness (mc, loc);
+
+ foreach (var ta in TypeArguments)
+ ta.CheckObsoleteness (mc, loc);
+ }
+
public override ObsoleteAttribute GetAttributeObsolete ()
{
return open_type.GetAttributeObsolete ();
}
if (base_override.IsGeneric) {
- ObsoleteAttribute oa;
foreach (var base_tp in base_tparams) {
- oa = base_tp.BaseType.GetAttributeObsolete ();
- if (oa != null) {
- AttributeTester.Report_ObsoleteMessage (oa, base_tp.BaseType.GetSignatureForError (), Location, Report);
- }
+ base_tp.BaseType.CheckObsoleteness (this, Location);
if (base_tp.InterfacesDefined != null) {
foreach (var iface in base_tp.InterfacesDefined) {
- oa = iface.GetAttributeObsolete ();
- if (oa != null) {
- AttributeTester.Report_ObsoleteMessage (oa, iface.GetSignatureForError (), Location, Report);
- }
+ iface.CheckObsoleteness (this, Location);
}
}
}