}
}
+ public bool ResolveError {
+ get {
+ return resolve_error;
+ }
+ }
+
public ATypeNameExpression TypeExpression {
get {
return expression;
/// <summary>
/// Tries to resolve the type of the attribute. Flags an error if it can't, and complain is true.
/// </summary>
- void ResolveAttributeType ()
+ void ResolveAttributeType (bool comparisonOnly)
{
SessionReportPrinter resolve_printer = new SessionReportPrinter ();
ReportPrinter prev_recorder = Report.SetPrinter (resolve_printer);
}
if (t1_is_attr && t2_is_attr && t1 != t2) {
- Report.Error (1614, Location, "`{0}' is ambiguous between `{1}' and `{2}'. Use either `@{0}' or `{0}Attribute'",
- GetSignatureForError (), expression.GetSignatureForError (), expanded.GetSignatureForError ());
- resolve_error = true;
+ if (!comparisonOnly) {
+ Report.Error (1614, Location, "`{0}' is ambiguous between `{1}' and `{2}'. Use either `@{0}' or `{0}Attribute'",
+ GetSignatureForError (), expression.GetSignatureForError (), expanded.GetSignatureForError ());
+ resolve_error = true;
+ }
+
return;
}
return;
}
+ if (comparisonOnly)
+ return;
+
resolve_error = true;
if (t1 != null) {
resolve_printer.Merge (prev_recorder);
}
- public TypeSpec ResolveType ()
+ public TypeSpec ResolveTypeForComparison ()
{
if (Type == null && !resolve_error)
- ResolveAttributeType ();
+ ResolveAttributeType (true);
return Type;
}
arg_resolved = true;
if (Type == null) {
- ResolveAttributeType ();
+ ResolveAttributeType (false);
if (Type == null)
return null;
}
}
}
+ public bool HasResolveError()
+ {
+ foreach (var a in Attrs) {
+ if (a.ResolveError)
+ return true;
+ }
+
+ return false;
+ }
+
public Attribute Search (PredefinedAttribute t)
{
return Search (null, t);
if (explicitTarget != null && a.ExplicitTarget != explicitTarget)
continue;
- if (a.ResolveType () == t)
+ if (a.ResolveTypeForComparison () == t)
return a;
}
return null;
List<Attribute> ar = null;
foreach (Attribute a in Attrs) {
- if (a.ResolveType () == t) {
+ if (a.ResolveTypeForComparison () == t) {
if (ar == null)
ar = new List<Attribute> (Attrs.Count);
ar.Add (a);
{
// for extern static method must be specified either DllImport attribute or MethodImplAttribute.
// We are more strict than csc and report this as an error because SRE does not allow emit that
- if ((ModFlags & Modifiers.EXTERN) != 0 && !is_external_implementation) {
+ if ((ModFlags & Modifiers.EXTERN) != 0 && !is_external_implementation && (OptAttributes == null || !OptAttributes.HasResolveError ())) {
if (this is Constructor) {
Report.Warning (824, 1, Location,
"Constructor `{0}' is marked `external' but has no external implementation specified", GetSignatureForError ());
return null;
//
- // Check ObsoleteAttribute on the best method
+ // Don't run possibly expensive checks in probing mode
//
- ObsoleteAttribute oa = best_candidate.GetAttributeObsolete ();
- if (oa != null && !rc.IsObsolete)
- AttributeTester.Report_ObsoleteMessage (oa, best_candidate.GetSignatureForError (), loc, rc.Report);
+ if (!rc.IsInProbingMode) {
+ //
+ // 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.MemberDefinition.SetIsUsed ();
+ best_candidate.MemberDefinition.SetIsUsed ();
+ }
args = best_candidate_args;
return (T) best_candidate;