+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
}
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;
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)
{
$$ = 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
{
$$ = 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);
}
//
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;
}
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) {
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)?
// 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 ();
//
DeclSpace lookup_ds = ec.DeclSpace;
+ Type almost_matched_type = null;
+ ArrayList almost_matched = null;
do {
if (lookup_ds.TypeBuilder == null)
break;
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;
}
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",
/// </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)