Merge pull request #409 from Alkarex/patch-1
[mono.git] / mcs / mcs / attribute.cs
index 46c0116bd18b3e60c6d89ebb463a946e99528a41..4fbc993a55a882591eb2192cfbe79fa163027afe 100644 (file)
@@ -144,6 +144,12 @@ namespace Mono.CSharp {
                        }
                }
 
+               public bool ResolveError {
+                       get {
+                               return resolve_error;
+                       }
+               }
+
                public ATypeNameExpression TypeExpression {
                        get {
                                return expression;
@@ -276,7 +282,7 @@ namespace Mono.CSharp {
                /// <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);
@@ -311,9 +317,12 @@ namespace Mono.CSharp {
                        }
 
                        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;
                        }
 
@@ -327,6 +336,9 @@ namespace Mono.CSharp {
                                return;
                        }
 
+                       if (comparisonOnly)
+                               return;
+
                        resolve_error = true;
 
                        if (t1 != null) {
@@ -346,10 +358,10 @@ namespace Mono.CSharp {
                        resolve_printer.Merge (prev_recorder);
                }
 
-               public TypeSpec ResolveType ()
+               public TypeSpec ResolveTypeForComparison ()
                {
                        if (Type == null && !resolve_error)
-                               ResolveAttributeType ();
+                               ResolveAttributeType (true);
                        return Type;
                }
 
@@ -425,7 +437,7 @@ namespace Mono.CSharp {
                        arg_resolved = true;
 
                        if (Type == null) {
-                               ResolveAttributeType ();
+                               ResolveAttributeType (false);
                                if (Type == null)
                                        return null;
                        }
@@ -1193,6 +1205,16 @@ namespace Mono.CSharp {
                        }
                }
 
+               public bool HasResolveError()
+               {
+                       foreach (var a in Attrs) {
+                               if (a.ResolveError)
+                                       return true;
+                       }
+
+                       return false;
+               }
+
                public Attribute Search (PredefinedAttribute t)
                {
                        return Search (null, t);
@@ -1204,7 +1226,7 @@ namespace Mono.CSharp {
                                if (explicitTarget != null && a.ExplicitTarget != explicitTarget)
                                        continue;
 
-                               if (a.ResolveType () == t)
+                               if (a.ResolveTypeForComparison () == t)
                                        return a;
                        }
                        return null;
@@ -1218,7 +1240,7 @@ namespace Mono.CSharp {
                        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);