**** Merged r387370-r38910 from MCS ****
authorMartin Baulig <martin@novell.com>
Wed, 26 Jan 2005 07:33:13 +0000 (07:33 -0000)
committerMartin Baulig <martin@novell.com>
Wed, 26 Jan 2005 07:33:13 +0000 (07:33 -0000)
svn path=/trunk/mcs/; revision=39541

mcs/gmcs/ChangeLog
mcs/gmcs/attribute.cs
mcs/gmcs/cs-parser.jay
mcs/gmcs/ecore.cs
mcs/gmcs/expression.cs
mcs/gmcs/typemanager.cs

index c74eac0e0bc5096eee4bd5b4f5375ab1117331c9..0df9c21cf4c2fc36055d65072329503f6d57142f 100644 (file)
@@ -1,8 +1,49 @@
+2005-01-13  Miguel de Icaza  <miguel@ximian.com>
+
+       * ecore.cs (IsAccessorAccessible): Accessibility to private fields
+       of a different type is only allowed to private fields of a
+       containing type, not on fields of a base class.
+
+       See test-174.cs and error cs0122-9.cs
+
+2005-01-13  Raja R Harinath  <rharinath@novell.com>
+
+       Fix test-335.cs (bug #58126).
+       * cs-parser.jay (argument): Split out non-expression parts of the
+       rule into 'non_simple_argument'.
+       (invocation_expression): Support parenthesized invocations with
+       multiple arguments, and with single non-simple arguments.
+
+2005-01-13  Raja R Harinath  <rharinath@novell.com>
+
+       * cs-tokenizer.cs (xtoken): Reset 'comments_seen' in a couple more
+       places.
+
+2005-01-12  Raja R Harinath  <rharinath@novell.com>
+
+       Fix cs0038-1.cs, cs1640-6.cs.
+       * ecore.cs (Expression.Resolve): Remove special-case for
+       SimpleName in error-handling.
+       (Expression.almostMatchedMembers): Relax access permission to
+       protected.
+       (Expression.MemberLookupFailed): Handle duplicates in
+       almostMatchedMembers list.
+       (SimpleName.DoSimpleNameResolve): Catch CS0038 errors earlier.
+       * expression.cs (New.DoResolve): Report CS1540 for more cases.
+       * typemanager.cs (GetFullNameSignature): Use the MethodBase
+       overload if the passed in MemberInfo is a MethodBase.
+
 2005-01-25  Martin Baulig  <martin@ximian.com>
 
        * doc.cs
        (DocUtil.emptyParamList): Removed; use `Type.EmptyTypes' instead.
 
+2005-01-12  Marek Safar  <marek.safar@seznam.cz>
+
+       Fix #70749
+       * attribute.cs (ExtractSecurityPermissionSet): Don't report error
+       for non-CAS & merge permission sets properly.
+
 2005-01-11  Raja R Harinath  <rharinath@novell.com>
 
        Improve standard-compliance of simple name and member access 
index 4d3a2dd48b875f88647bc8fd2d1b6e672cf18c12..e0e81083ffc78c44d58d1cd899e244cf5e3b000f 100644 (file)
@@ -820,13 +820,11 @@ namespace Mono.CSharp {
                        }
 
                        IPermission perm = sa.CreatePermission ();
-                       SecurityAction action;
+                       SecurityAction action = GetSecurityActionValue ();
 
                        // IS is correct because for corlib we are using an instance from old corlib
-                       if (perm is System.Security.CodeAccessPermission) {
-                               action = GetSecurityActionValue ();
-                       } else {
-                               switch (GetSecurityActionValue ()) {
+                       if (!(perm is System.Security.CodeAccessPermission)) {
+                               switch (action) {
                                        case SecurityAction.Demand:
                                                action = (SecurityAction)13;
                                                break;
@@ -836,18 +834,18 @@ namespace Mono.CSharp {
                                        case SecurityAction.InheritanceDemand:
                                                action = (SecurityAction)15;
                                                break;
-                                       default:
-                                               Error_AttributeEmitError ("Invalid SecurityAction for non-Code Access Security permission");
-                                               return;
                                }
                        }
 
                        PermissionSet ps = (PermissionSet)permissions [action];
                        if (ps == null) {
-                               ps = new PermissionSet (PermissionState.None);
+                               ps = new PermissionSet (sa.Unrestricted ? PermissionState.Unrestricted : PermissionState.None);
                                permissions.Add (action, ps);
+                       } else if (!ps.IsUnrestricted () && sa.Unrestricted) {
+                               ps = ps.Union (new PermissionSet (PermissionState.Unrestricted));
+                               permissions [action] = ps;
                        }
-                       ps.AddPermission (sa.CreatePermission ());
+                       ps.AddPermission (perm);
                }
 
                object GetValue (object value)
index cb0b929bd4490a183b3e939a4c8ea4bfc2593604..956225cf49fefc10e59f05385cd84e8999cebc8e 100644 (file)
@@ -2721,6 +2721,18 @@ invocation_expression
          {
                $$ = new InvocationOrCast ((Expression) $1, (Expression) $3, lexer.Location);
          }
+       | parenthesized_expression_0 CLOSE_PARENS_OPEN_PARENS OPEN_PARENS non_simple_argument CLOSE_PARENS
+         {
+               ArrayList args = new ArrayList (1);
+               args.Add ($4);
+               $$ = new Invocation ((Expression) $1, args, lexer.Location);
+         }
+       | parenthesized_expression_0 CLOSE_PARENS_OPEN_PARENS OPEN_PARENS argument_list COMMA argument CLOSE_PARENS
+         {
+               ArrayList args = ((ArrayList) $4);
+               args.Add ($6);
+               $$ = new Invocation ((Expression) $1, args, lexer.Location);
+         }
        ;
 
 opt_argument_list
@@ -2751,7 +2763,14 @@ argument
          {
                $$ = new Argument ((Expression) $1, Argument.AType.Expression);
          }
-       | REF variable_reference 
+       | non_simple_argument
+         {
+               $$ = $1;
+         }
+       ;
+
+non_simple_argument
+       : REF variable_reference 
          { 
                $$ = new Argument ((Expression) $2, Argument.AType.Ref);
          }
index 6289b55a7235a1a3a4e0658b6d781f12dfa05423..4fb48ea2434a804d5654c938b07583b720961938 100644 (file)
@@ -230,9 +230,9 @@ namespace Mono.CSharp {
                        //
                        if (ma == MethodAttributes.Private) {
                                Type declaring_type = mi.DeclaringType;
-                                       
+
                                if (invocation_type != declaring_type)
-                                       return TypeManager.IsNestedFamilyAccessible (invocation_type, declaring_type);
+                                       return TypeManager.IsNestedChildOf (invocation_type, declaring_type);
 
                                return true;
                        }
@@ -372,12 +372,8 @@ namespace Mono.CSharp {
 
                        ec.DoFlowAnalysis = old_do_flow_analysis;
 
-                       if (e == null) {
-                               if (this is SimpleName)
-                                       MemberLookupFailed (ec, null, ec.ContainerType, ((SimpleName) this).Name, 
-                                                           ec.DeclSpace.Name, loc);
+                       if (e == null)
                                return null;
-                       }
 
                        if ((e is TypeExpr) || (e is ComposedCast) || (e is Namespace)) {
                                if ((flags & ResolveFlags.Type) == 0) {
@@ -585,8 +581,7 @@ namespace Mono.CSharp {
                        return null;
                }
 
-
-               private static ArrayList almostMatchedMembers = new ArrayList (4);
+               protected static ArrayList almostMatchedMembers = new ArrayList (4);
 
                //
                // FIXME: Probably implement a cache for (t,name,current_access_set)?
@@ -741,13 +736,25 @@ namespace Mono.CSharp {
                                        // base class (CS1540).  If the qualifier_type is a base of the
                                        // ec.ContainerType and the lookup succeeds with the latter one,
                                        // then we are in this situation.
-                                       foreach (MemberInfo m in almostMatchedMembers)
+                                       for (int i = 0; i < almostMatchedMembers.Count; ++i) {
+                                               MemberInfo m = (MemberInfo) almostMatchedMembers [i];
+                                               for (int j = 0; j < i; ++j) {
+                                                       if (m == almostMatchedMembers [j]) {
+                                                               m = null;
+                                                               break;
+                                                       }
+                                               }
+                                               if (m == null)
+                                                       continue;
+
+                                               Report.SymbolRelatedToPreviousError (m);
                                                Report.Error (1540, loc, 
                                                              "Cannot access protected member `{0}' via a qualifier of type `{1}';"
                                                              + " the qualifier must be of type `{2}' (or derived from it)", 
                                                              TypeManager.GetFullNameSignature (m),
                                                              TypeManager.CSharpName (qualifier_type),
                                                              TypeManager.CSharpName (ec.ContainerType));
+                                       }
                                        return;
                                }
                                almostMatchedMembers.Clear ();
@@ -2156,6 +2163,8 @@ namespace Mono.CSharp {
                        //
 
                        DeclSpace lookup_ds = ec.DeclSpace;
+                       Type almost_matched_type = null;
+                       ArrayList almost_matched = null;
                        do {
                                if (lookup_ds.TypeBuilder == null)
                                        break;
@@ -2164,14 +2173,33 @@ namespace Mono.CSharp {
                                if (e != null)
                                        break;
 
+                               if (almost_matched == null && almostMatchedMembers.Count > 0) {
+                                       almost_matched_type = lookup_ds.TypeBuilder;
+                                       almost_matched = (ArrayList) almostMatchedMembers.Clone ();
+                               }
+
                                lookup_ds =lookup_ds.Parent;
                        } while (lookup_ds != null);
 
                        if (e == null && ec.ContainerType != null)
                                e = MemberLookup (ec, ec.ContainerType, Name, loc);
 
-                       if (e == null)
-                               return ResolveAsTypeStep (ec);
+                       if (e == null) {
+                               if (almost_matched == null && almostMatchedMembers.Count > 0) {
+                                       almost_matched_type = ec.ContainerType;
+                                       almost_matched = (ArrayList) almostMatchedMembers.Clone ();
+                               }
+                               e = ResolveAsTypeStep (ec);
+                       }
+
+                       if (e == null) {
+                               if (almost_matched != null)
+                                       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);
+                               return null;
+                       }
 
                        if (e is TypeExpr)
                                return e;
index 9274f8d2b917e766db72a2ad496739d14bb772b3..b0874849ab475668c0f4777ea4985a4db54cdae8 100644 (file)
@@ -5897,11 +5897,16 @@ namespace Mono.CSharp {
                                }
 
                                method = Invocation.OverloadResolve (
-                                       ec, (MethodGroupExpr) ml, Arguments, false, loc);
+                                       ec, (MethodGroupExpr) ml, Arguments, true, loc);
                                
                        }
 
-                       if (method == null) { 
+                       if (method == null) {
+                               if (almostMatchedMembers.Count != 0) {
+                                       MemberLookupFailed (ec, type, type, ".ctor", null, loc);
+                                       return null;
+                               }
+
                                 if (!is_struct || Arguments.Count > 0) {
                                        Error (1501, String.Format (
                                            "New invocation: Can not find a constructor in `{0}' for this argument list",
index 1b358226c7423cfcfb1e927e4d13d33b4f20ebbc..b0b0664b994dd1305949c77f2496eee570c35e8b 100644 (file)
@@ -865,7 +865,10 @@ public partial class TypeManager {
        /// </summary>
        static public string GetFullNameSignature (MemberInfo mi)
        {
-               return mi.DeclaringType.FullName.Replace ('+', '.') + '.' + mi.Name;
+               // Unfortunately, there's no dynamic dispatch on the arguments of a function.
+               return (mi is MethodBase)
+                       ? GetFullNameSignature (mi as MethodBase) 
+                       : mi.DeclaringType.FullName.Replace ('+', '.') + '.' + mi.Name;
        }
                
        static public string GetFullNameSignature (MethodBase mb)