Fix #72756.
authorRaja R Harinath <harinath@hurrynot.org>
Mon, 21 Feb 2005 12:03:22 +0000 (12:03 -0000)
committerRaja R Harinath <harinath@hurrynot.org>
Mon, 21 Feb 2005 12:03:22 +0000 (12:03 -0000)
* mcs/ecore.cs (Expression.MemberLookupFailed): Add argument to
disable the error message when the extended MemberLookup also fails.
(Expression.MemberLookupFinal): Update.
(SimpleName.DoSimpleNameResolve): Update.
* mcs/expression.cs (MemberAccess.ResolveNamespaceOrType):
Don't use MemberLookupFinal.
(New.DoResolve): Update.
(BaseAccess.CommonResolve): Update.
* tests/test-350.cs: New test from #72756.

svn path=/trunk/mcs/; revision=40977

mcs/mcs/ChangeLog
mcs/mcs/ecore.cs
mcs/mcs/expression.cs
mcs/tests/ChangeLog
mcs/tests/Makefile
mcs/tests/test-350.cs [new file with mode: 0644]

index 62c773272f0fbeecceed6de0370a401860a201e4..502e61d5e9928501b9cb81e99c1dca16fe07ed85 100644 (file)
@@ -1,3 +1,16 @@
+2005-02-21  Raja R Harinath  <rharinath@novell.com>
+
+       Fix #72756.
+       * ecore.cs (Expression.MemberLookupFailed): Add argument to
+       disable the error message when the extended MemberLookup also
+       fails.
+       (Expression.MemberLookupFinal): Update.
+       (SimpleName.DoSimpleNameResolve): Update.
+       * expression.cs (MemberAccess.ResolveNamespaceOrType):
+       Don't use MemberLookupFinal.
+       (New.DoResolve): Update.
+       (BaseAccess.CommonResolve): Update.
+
 2005-02-21  Raja R Harinath  <rharinath@novell.com>
 
        Fix #72732.
index 91195bf79e7b2a43bae5e93efeea4d685c4617f6..aef9a49d8ec416568e767f27b97332927e8217e3 100644 (file)
@@ -706,14 +706,15 @@ namespace Mono.CSharp {
 
                        if (e == null && errors == Report.Errors)
                                // No errors were reported by MemberLookup, but there was an error.
-                               MemberLookupFailed (ec, qualifier_type, queried_type, name, null, loc);
+                               MemberLookupFailed (ec, qualifier_type, queried_type, name, null, true, loc);
 
                        return e;
                }
 
                public static void MemberLookupFailed (EmitContext ec, Type qualifier_type,
                                                       Type queried_type, string name,
-                                                      string class_name, Location loc)
+                                                      string class_name, bool complain_if_none_found, 
+                                                      Location loc)
                {
                        if (almostMatchedMembers.Count != 0) {
                                if (qualifier_type == null) {
@@ -760,6 +761,9 @@ namespace Mono.CSharp {
                                                                  BindingFlags.NonPublic, name, null);
 
                        if (lookup == null) {
+                               if (!complain_if_none_found)
+                                       return;
+
                                if (class_name != null)
                                        Report.Error (103, loc, "The name `" + name + "' could not be " +
                                                      "found in `" + class_name + "'");
@@ -2164,7 +2168,7 @@ namespace Mono.CSharp {
                                        almostMatchedMembers = almost_matched;
                                if (almost_matched_type == null)
                                        almost_matched_type = ec.ContainerType;
-                               MemberLookupFailed (ec, null, almost_matched_type, ((SimpleName) this).Name, ec.DeclSpace.Name, loc);
+                               MemberLookupFailed (ec, null, almost_matched_type, ((SimpleName) this).Name, ec.DeclSpace.Name, true, loc);
                                return null;
                        }
 
index a9429cd9a09eb9f44ead65d99786df62e22d35f9..07f4d6c9d436fcace5565f5ca20166a40d48c448 100644 (file)
@@ -5910,7 +5910,7 @@ namespace Mono.CSharp {
 
                        if (method == null) {
                                if (almostMatchedMembers.Count != 0) {
-                                       MemberLookupFailed (ec, type, type, ".ctor", null, loc);
+                                       MemberLookupFailed (ec, type, type, ".ctor", null, true, loc);
                                        return null;
                                }
 
@@ -7548,10 +7548,14 @@ namespace Mono.CSharp {
                                return null;
                        }
                        
-                       Expression member_lookup = MemberLookupFinal (ec, expr_type, expr_type, Identifier, loc);
-                       if (!silent && member_lookup == null) {
-                               Report.Error (234, loc, "The type name `{0}' could not be found in type `{1}'", 
-                                             Identifier, new_expr.FullName);
+                       Expression member_lookup = MemberLookup (ec, expr_type, expr_type, Identifier, loc);
+                       if (member_lookup == null) {
+                               int errors = Report.Errors;
+                               MemberLookupFailed (ec, expr_type, expr_type, Identifier, null, false, loc);
+
+                               if (!silent && errors == Report.Errors)
+                                       Report.Error (234, loc, "The type name `{0}' could not be found in type `{1}'", 
+                                                     Identifier, new_expr.FullName);
                                return null;
                        }
 
@@ -8543,7 +8547,7 @@ namespace Mono.CSharp {
                        member_lookup = MemberLookup (ec, ec.ContainerType, null, base_type, member,
                                                      AllMemberTypes, AllBindingFlags, loc);
                        if (member_lookup == null) {
-                               MemberLookupFailed (ec, base_type, base_type, member, null, loc);
+                               MemberLookupFailed (ec, base_type, base_type, member, null, true, loc);
                                return null;
                        }
 
index 9b8b6f4b785f46fee61664b00f860c6f2271c36b..18ad884df4b9f14119d6864726aafcf2165d56a7 100644 (file)
@@ -1,3 +1,7 @@
+2005-02-21  Raja R Harinath  <rharinath@novell.com>
+
+       * test-350.cs: New test from #72756.
+
 2005-02-18  Marek Safar <marek.safar@seznam.cz>
 
        * test-349.cs: New test.
index 6814721f41c8a4ab1830096ae9f62851d9ce2350..34a1ea604ba0806df75b1556d675606b0699758a 100644 (file)
@@ -70,9 +70,9 @@ TEST_SOURCES_common = \
        test-291 test-292 test-293 test-294 test-295 test-296 test-297 test-298 test-299 test-300 \
        test-301 test-302 test-303 test-304 test-305 test-306 test-307          test-309 test-310 \
                 test-312 test-313 test-314 test-315 test-316 test-317 test-318          test-320 \
-       test-321          test-323 test-324 test-325 test-326 test-327 test-328           \
+       test-321          test-323 test-324 test-325 test-326 test-327 test-328                   \
                                                                                         test-340 \
-                         test-343 \
+                         test-343                                                       test-350 \
        cls-test-0 cls-test-1 cls-test-2 cls-test-3 cls-test-5 cls-test-6 cls-test-7 cls-test-10  \
        cls-test-11 cls-test-12 cls-test-14 cls-test-15 cls-test-16 \
        2test-1  2test-2  2test-3  2test-4  2test-5  2test-6  2test-7  2test-8  2test-9  2test-10 \
diff --git a/mcs/tests/test-350.cs b/mcs/tests/test-350.cs
new file mode 100644 (file)
index 0000000..1daf45a
--- /dev/null
@@ -0,0 +1,16 @@
+using System;
+
+public class A
+{
+    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property)]
+    public class BAttribute : Attribute
+    {
+    }
+}
+
+
+[A.B()]
+public class C
+{
+       static void Main () {}
+}